Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Authorization plugin: URL referer retrieving problem

0 views
Skip to first unread message

jordan...@gmail.com

unread,
Aug 29, 2006, 3:50:16 PM8/29/06
to
Hello all.

I am currently developping an authorization plugin.
The authorization is based on the URL referer.

In a few words, I would like to retrieve the client URL referer (if
available), and compare it to a list of referers authorized to access
to the content of my publication point.

In the AuthorizeEvent interface implementation, I combine the
UserContext and the GetStringValue method to retrieve the URL Referer:

string l__URLRefererString= string.Empty;
io__UserContext.GetStringValue
(
WMSDefines.WMS_USER_REFERER,
WMSDefines.WMS_USER_REFERER_ID,
out l__URLRefererString,
0
);

However, il still get the same problem, this method throws the
following exception:
Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))

Although the following code worked perfectly

string l__UserIPAddress = string.Empty;
io__UserContext.GetStringValue
(
WMSDefines.WMS_USER_IP_ADDRESS_STRING,
WMSDefines.WMS_USER_IP_ADDRESS_STRING_ID,
out l__UserIPAddress,
0
);

It seems that the value of WMS_USER_REFERER is not included in the User
Context, but the documentation indicates the opposite.
I tested to read my stream publication point via my Windows media
player. This gave me no URL referer (pretty normal in this case)
But I also tested to read my stream publication point via an embed
Windows media player object in HTML page. The result was the same.

Is there anyone who encountered such trouble?
To Summarize, how can retrieve the URL referer from my AuthorizeEvent
interface implementation?

Thanks in advance.

Jordan

jordan...@gmail.com

unread,
Sep 13, 2006, 12:05:38 PM9/13/06
to
Sorry to ask for this trouble again.

Is there any body that can help me with this trouble.

I am currently working on Windows Media service authorization plugin.

The goal of this plugin is pretty simple. Get the URL referrer of the
client request (if available), compare it to a specific one and if
identical, authorize the stream to be played.

All is working pretty good, but a critical problem cannot be solved:
the URLReferer retrieval.

I have try nearly everything, and I still not manage to retrieve the
URLReferer

I give you my whole class in the next libes( I justed removed the
plugin registration methods)

If you could just take a look in order to point me the good things to
do it would really be great.


Thanks in advance

Jordan

*****************************************************
using System;
using System.Collections;
using System.Xml;
using System.Runtime.InteropServices;
using System.Reflection;
using Microsoft.WindowsMediaServices.Interop;
using Microsoft.Win32;


namespace MyWMSNameSpace
{
[GuidAttribute("F0019290-5AFB-463c-AC17-E48589AC7A3C")]
public class MyWMSAuthorizationPlugin :
IWMSBasicPlugin,
IWMSEventAuthorizationPlugin
{

#region BasicPlugin implementations

void IWMSBasicPlugin.InitializePlugin
(
IWMSContext i__ServerContext,
WMSNamedValues i__NamedValues,
IWMSClassObject i__ClassFactory
)
{
}

void IWMSBasicPlugin.EnablePlugin
(
ref int io__Flags,
ref int io__HeartBeatPeriod
)
{
}

void IWMSBasicPlugin.DisablePlugin()
{
}

void IWMSBasicPlugin.ShutdownPlugin()
{
}

object IWMSBasicPlugin.GetCustomAdminInterface()
{
return 0;
}

void IWMSBasicPlugin.OnHeartbeat()
{
}

#endregion

#region AuthorizationPlugin implementations

object IWMSEventAuthorizationPlugin.GetAuthorizedEvents()
{
try
{
// Identify the events the plug-in can
authorize.
// I ONLY DEAL WITH THE WMS_EVENT_OPEN HERE,
BUT I
// TESTED WITH ALL THE EVENTS INCLUDED IN THE
ARRAY
// AND THE PROBLEM IS THE SAME.
WMS_EVENT_TYPE[] l__AuthorizeEvents =
{WMS_EVENT_TYPE.WMS_EVENT_OPEN};

return (object)l__AuthorizeEvents;
}
catch
{
// Throw E_FAIL to the server.
throw new COMException();
}
}

void IWMSEventAuthorizationPlugin.AuthorizeEvent
(
ref WMS_EVENT i__Event,
IWMSContext io__UserContext,
IWMSContext io__PresentationContext,
IWMSCommandContext io__CommandContext,
IWMSEventAuthorizationCallback i__ServerCallback,
object i__Context
)
{
// This variable is used to represent HRESULT error
codes.
// By default, this value is set to E_ACCESSDENIED
int l__AuthorizationResult =
unchecked((int)0x80070005);

try
{
//
// We retrieve the user IP address.
// THIS WORKS PERFECTLY, I REALLY GET THE
CLIENT IP
// ADDRESS


string l__UserIPAddress = string.Empty;
io__UserContext.GetStringValue
(
WMSDefines.WMS_USER_IP_ADDRESS_STRING,
WMSDefines.WMS_USER_IP_ADDRESS_STRING_ID,

out l__UserIPAddress,
0
);

//
// We retrieve the user URL referer from the
user context.
// THIS DOES NOT WORK. I GET AN EXCEPTION
SAYING
// Exception from HRESULT: 0x8002000B
(DISP_E_BADINDEX))
//
string l__URLRefererString = string.Empty;


io__UserContext.GetStringValue
(
WMSDefines.WMS_USER_REFERER,
WMSDefines.WMS_USER_REFERER_ID,
out l__URLRefererString,
0
);

// I ALSO TRIED THE FOLLOWING LINES, BUT THIS
NOT
// WORKED NEITHER
// IWMSContext l__CommandContext;
// io__CommandContext.GetCommandRequest(out
// l__CommandContext);
// l__CommandContext.GetStringValue
// (
//
WMSDefines.WMS_COMMAND_CONTEXT_REQUEST_URL,
//
WMSDefines.WMS_COMMAND_CONTEXT_REQUEST_URL_ID,
// out l__URLRefererString,
// 0
// );

// We check the validity of the URL referer
if (l__URLRefererString = "A certain value");
{
l__AuthorizationResult = 0;
}
else
{
// Pass the callback method the integer
// value of E_ACCESSDENIED.
l__AuthorizationResult =
unchecked((int)0x80070005);
}
}
finally
{
// Report the results of the authorization
// challenge back to the server.

i__ServerCallback.OnAuthorizeEvent(l__AuthorizationResult,
i__Context);
}
}

#endregion
}
}

Jordan

unread,
Sep 14, 2006, 1:21:02 PM9/14/06
to
Hello all.

I am currently developping an authorization plugin.
The authorization is based on the URL referer.

In a few words, I would like to retrieve the client URL referer (if
available), and compare it to a list of referers authorized to access
to the content of my publication point.

In the AuthorizeEvent interface implementation, I combine the
UserContext and the GetStringValue method to retrieve the URL Referer:

string l__URLRefererString= string.Empty;


io__UserContext.GetStringValue
(
WMSDefines.WMS_USER_REFERER,
WMSDefines.WMS_USER_REFERER_ID,
out l__URLRefererString,
0
);

However, il still get the same problem, this method throws the
following exception:


Exception from HRESULT: 0x8002000B (DISP_E_BADINDEX))

Although the following code worked perfectly

string l__UserIPAddress = string.Empty;


io__UserContext.GetStringValue
(
WMSDefines.WMS_USER_IP_ADDRESS_STRING,
WMSDefines.WMS_USER_IP_ADDRESS_STRING_ID,
out l__UserIPAddress,
0
);

It seems that the value of WMS_USER_REFERER is not included in the User

Jordan

unread,
Sep 14, 2006, 1:30:01 PM9/14/06
to
I want to be a bit more precise.

Thanks in advance

Jordan

#region BasicPlugin implementations

void IWMSBasicPlugin.DisablePlugin()
{
}

void IWMSBasicPlugin.ShutdownPlugin()
{
}

object IWMSBasicPlugin.GetCustomAdminInterface()
{
return 0;
}

void IWMSBasicPlugin.OnHeartbeat()
{
}

#endregion

#region AuthorizationPlugin implementations

string l__UserIPAddress = string.Empty;
io__UserContext.GetStringValue
(
WMSDefines.WMS_USER_IP_ADDRESS_STRING,
WMSDefines.WMS_USER_IP_ADDRESS_STRING_ID,

out l__UserIPAddress,
0
);

//


// We retrieve the user URL referer from the
user context.
// THIS DOES NOT WORK. I GET AN EXCEPTION
SAYING

// Exception from HRESULT: 0x8002000B
(DISP_E_BADINDEX))
//
string l__URLRefererString = string.Empty;


io__UserContext.GetStringValue
(
WMSDefines.WMS_USER_REFERER,
WMSDefines.WMS_USER_REFERER_ID,
out l__URLRefererString,
0
);

// I ALSO TRIED THE FOLLOWING LINES, BUT THIS

SpongeSong

unread,
Oct 2, 2006, 1:26:02 AM10/2/06
to
You can retrieve WMS_USER_REFERER message

when Event.Type == WMS_EVENT_PLAY

and when the client's WMP is version 9 or later


I made this plugin like your way about 1 year ago, and

When Client uses version 7 or 8, they can't access the contents,
where they were in correctly URL.

Only works WMP 9 or later

Genux

unread,
Mar 23, 2007, 8:40:54 AM3/23/07
to

Not sure if this helps now.. but if you use the presentation context,
you are able to get the URL requested from the resource.


String ClientRequest;

pPresentationCtx.GetStringValue(WMSDefines.WMS_PRESENT_REQUEST_NAME,
WMSDefines.WMS_PRESENT_REQUEST_NAME_ID, out ClientRequest, 0);

I shall post more on my website 'Coding Friends'
(http://www.codingfriends.com) when I get the time :)


--
Genux
------------------------------------------------------------------------
Genux's Profile: http://forums.techarena.in/member.php?userid=23764
View this thread: http://forums.techarena.in/showthread.php?t=587416

http://forums.techarena.in

0 new messages