users@grizzly.java.net

Re: Getting Subject or Principal

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Tue, 28 Jul 2009 18:34:33 +0200

Hi,

> As you can see I"m using a ProtocolChain mode with 3 Filters:
>
> final ProtocolChain protocolChain = new DefaultProtocolChain();
>
> protocolChain.addFilter(parserFilter1);
> protocolChain.addFilter(reqcontrolFilter);
> protocolChain.addFilter(new ProcessRequestFilter());
Ok.


> In the parserFilter1 implementing the ProtocolParser I get a message
> from
> buffer using hasNextMessage & getNextMessage.
> In the next Filter (reqcontrolFilter) I store the selectionKey and the
> selectorhandler related to the request (it happens in the
> retrieveConnectionHandler(context) method). So the
> (reqcontrolFilter) looks
> like:
> public boolean execute(Context context) throws IOException {
>
> ClientConnectionHandler client =
> retrieveConnectionHandler(context);
> MySimpleRequest request = (MySimpleRequest)
> context.removeAttribute(ProtocolParser.MESSAGE);
> request.setClientConnectionHandler(client);
>
> return true;
> }
Ok.
>
> At this step I"d like to know the Principal (the user) because some
> of them
> doesn"t have a permission to execute the MySimpleRequest. :)
> In the third filter called ProcessRequestFilter the request will be
> processed.
Principal for GrizzlyRequest, as I understand, it's user, recognized
by a web server. If you have own protocol - it's up to you to define
user/principal, basing on protocol/usecase specific user authorization.

Thanks.

WBR,
Alexey.

>
> Thanks,
>
> Best regards,
> alaska
>
>
>
> Oleksiy Stashok wrote:
>>
>> Hi Alaska,
>>
>> can you pls. provide more details on your usecase?
>> Cause, if it's not web server related Principal - then not sure I
>> understand what you're looking for :)
>>
>> Thanks.
>>
>> WBR,
>> Alexey.
>>
>> On Jul 28, 2009, at 15:29 , Alaska wrote:
>>
>>>
>>> Hello Alexey,
>>>
>>> I don"t use the GrizzlyRequest, I get a request from teh context:
>>> context.removeAttribute(ProtocolParser.MESSAGE);
>>>
>>> How can I get a Principal related to this request?
>>>
>>> Thanx,
>>> alaska
>>>
>>>
>>>
>>> Oleksiy Stashok wrote:
>>>>
>>>> Hi,
>>>>
>>>>> I'm looking for any possibility to get the Subject or Principal
>>>>> from
>>>>> the
>>>>> ProtocolChain"s context (or ssl-context).
>>>>> I"ve seen you have the GrizzlyRequest.getUserPrincipal()-method
>>>>> returning
>>>>> java.security.principal in the grizzly 2.0 version. I"m looking
>>>>> for
>>>>> the same
>>>>> method but for the 1.9.17-Snapshot.
>>>> Hmm, strange, I still see:
>>>>
>>>> GrizzlyRequest:
>>>> /**
>>>> * Return the principal that has been authenticated for this
>>>> Request.
>>>> */
>>>> public Principal getUserPrincipal() {
>>>> return (userPrincipal);
>>>> }
>>>>
>>>> in the trunk (1.9.18-SNAPSHOT).
>>>>
>>>> WBR,
>>>> Alexey.
>>>>
>>>>
>>>>>
>>>>> Thank you in advance,
>>>>> alaska
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Getting-Subject-or-Principal-tp24647980p24647980.html
>>>>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Getting-Subject-or-Principal-tp24647980p24698083.html
>>> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
>> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Getting-Subject-or-Principal-tp24647980p24701856.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>