You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fx-dev@ws.apache.org by Konstantinos Pateras <kp...@googlemail.com> on 2007/05/18 01:36:03 UTC

Programmatically set encryption user in server

Hi all, I have set up Axis2 1.1.1 and Rampart 1.1 and configure it (I
followed the configuration instructions for Rampart 1.0 that are still
supported). I use UsernameToken and encryption  with a known key to
both parts but I want to set the encryption user programmatically in
server when it sends a response. This is because each user has its own
key stored in a database and is beeing retrieved in the
PasswordCallbackHandler.

Is there a way to do it like with
<encryptionUser>useReqSigCert</encryptionUser> that is used when the
incoming message is signed or can I get the calling user in
PasswordCallbackHandler when I send the response?

Another option is to pass a parameter to the constructor of the
PasswordCallbackHandler but I do not know where to instantiate the
handler in server.

I have tried the following in the PasswordCallbackHandler:

  MessageContext msgContext = MessageContext.getCurrentMessageContext();

but the msgContext is null in the response.

---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org


Re: Programmatically set encryption user in server

Posted by Konstantinos Pateras <kp...@googlemail.com>.
Hi Mark,

Thanks for your answer, but as far as I understand this code is for
the client, right? In the server you don't have a stub. In the client
I have done it already, my problem though is how to do it in the
server having exposed as web service POJO classes.

Please help...

On 5/18/07, Mark Badorrek <mb...@avoga.com.au> wrote:
>
> I've used to following code to programatically set the user for
> 'UsernameToken' in the security header.
>
>
>
>
> String username = "secretUser";
>
>  Options options = new Options();
>
>  stub._getServiceClient().setOptions(options);
>
>  stub._getServiceClient().setTargetEPR(new
> EndpointReference(endpoint));
>
>  options.setProperty(WSSHandlerConstants.OUTFLOW_SECURITY,
> getOutflowConfiguration(username));
>
> stub._getServiceClient().engageModule(new
> QName("rampart"));
> However, this is engaging rampart programatically. I haven't tried this
> using a 'axis2_client.xml' yet but hopefully this sort of thing will also
> work. I imagine that setting the encryption user wold be similar.
>
> Incidently, If anyone is aware of the 'proper' way to do this could you
> please show a code snippet?
>
> Cheers,
>
> Mark B
>
>
> ________________________________
>
> From: Konstantinos Pateras [mailto:kpateras@googlemail.com]
> Sent: Fri 5/18/2007 9:51 AM
> To: wss4j-dev@ws.apache.org
> Subject: Programmatically set encryption user in server
>
>
>
> Hi all, I have set up Axis2 1.1.1 and Rampart 1.1 and configure it (I
> followed the configuration instructions for Rampart 1.0 that are still
> supported). I use UsernameToken and encryption  with a known key to
> both parts but I want to set the encryption user programmatically in
> server when it sends a response. This is because each user has its own
> key stored in a database and is beeing retrieved in the
> PasswordCallbackHandler.
>
> Is there a way to do it like with
> <encryptionUser>useReqSigCert</encryptionUser> that is used
> when the
> incoming message is signed or can I get the calling user in
> PasswordCallbackHandler when I send the response?
>
> Another option is to pass a parameter to the constructor of the
> PasswordCallbackHandler but I do not know where to instantiate the
> handler in server.
>
> I have tried the following in the PasswordCallbackHandler:
>
>  MessageContext msgContext =
> MessageContext.getCurrentMessageContext();
>
> but the msgContext is null in the response.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: wss4j-dev-help@ws.apache.org
>
> Hi all, I have set up Axis2 1.1.1 and Rampart 1.1 and configure it (I
> followed the configuration instructions for Rampart 1.0 that are still
> supported). I use UsernameToken and encryption  with a known key to
> both parts but I want to set the encryption user programmatically in
> server when it sends a response. This is because each user has its own
> key stored in a database and is beeing retrieved in the
> PasswordCallbackHandler.
>
> Is there a way to do it like with
> <encryptionUser>useReqSigCert</encryptionUser> that is used
> when the
> incoming message is signed or can I get the calling user in
> PasswordCallbackHandler when I send the response?
>
> Another option is to pass a parameter to the constructor of the
> PasswordCallbackHandler but I do not know where to instantiate the
> handler in server.
>
> I have tried the following in the PasswordCallbackHandler:
>
>  MessageContext msgContext =
> MessageContext.getCurrentMessageContext();
>
> but the msgContext is null in the response.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: wss4j-dev-help@ws.apache.org
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org


Re: Programmatically set encryption user in server

Posted by Konstantinos Pateras <kp...@googlemail.com>.
Hi Mark,

Thanks for your answer, but as far as I understand this code is for
the client, right? In the server you don't have a stub. In the client
I have done it already, my problem though is how to do it in the
server having exposed as web service POJO classes.

Please help...

On 5/18/07, Mark Badorrek <mb...@avoga.com.au> wrote:
>
> I've used to following code to programatically set the user for
> 'UsernameToken' in the security header.
>
>
>
>
> String username = "secretUser";
>
>  Options options = new Options();
>
>  stub._getServiceClient().setOptions(options);
>
>  stub._getServiceClient().setTargetEPR(new
> EndpointReference(endpoint));
>
>  options.setProperty(WSSHandlerConstants.OUTFLOW_SECURITY,
> getOutflowConfiguration(username));
>
> stub._getServiceClient().engageModule(new
> QName("rampart"));
> However, this is engaging rampart programatically. I haven't tried this
> using a 'axis2_client.xml' yet but hopefully this sort of thing will also
> work. I imagine that setting the encryption user wold be similar.
>
> Incidently, If anyone is aware of the 'proper' way to do this could you
> please show a code snippet?
>
> Cheers,
>
> Mark B
>
>
> ________________________________
>
> From: Konstantinos Pateras [mailto:kpateras@googlemail.com]
> Sent: Fri 5/18/2007 9:51 AM
> To: wss4j-dev@ws.apache.org
> Subject: Programmatically set encryption user in server
>
>
>
> Hi all, I have set up Axis2 1.1.1 and Rampart 1.1 and configure it (I
> followed the configuration instructions for Rampart 1.0 that are still
> supported). I use UsernameToken and encryption  with a known key to
> both parts but I want to set the encryption user programmatically in
> server when it sends a response. This is because each user has its own
> key stored in a database and is beeing retrieved in the
> PasswordCallbackHandler.
>
> Is there a way to do it like with
> <encryptionUser>useReqSigCert</encryptionUser> that is used
> when the
> incoming message is signed or can I get the calling user in
> PasswordCallbackHandler when I send the response?
>
> Another option is to pass a parameter to the constructor of the
> PasswordCallbackHandler but I do not know where to instantiate the
> handler in server.
>
> I have tried the following in the PasswordCallbackHandler:
>
>  MessageContext msgContext =
> MessageContext.getCurrentMessageContext();
>
> but the msgContext is null in the response.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: wss4j-dev-help@ws.apache.org
>
> Hi all, I have set up Axis2 1.1.1 and Rampart 1.1 and configure it (I
> followed the configuration instructions for Rampart 1.0 that are still
> supported). I use UsernameToken and encryption  with a known key to
> both parts but I want to set the encryption user programmatically in
> server when it sends a response. This is because each user has its own
> key stored in a database and is beeing retrieved in the
> PasswordCallbackHandler.
>
> Is there a way to do it like with
> <encryptionUser>useReqSigCert</encryptionUser> that is used
> when the
> incoming message is signed or can I get the calling user in
> PasswordCallbackHandler when I send the response?
>
> Another option is to pass a parameter to the constructor of the
> PasswordCallbackHandler but I do not know where to instantiate the
> handler in server.
>
> I have tried the following in the PasswordCallbackHandler:
>
>  MessageContext msgContext =
> MessageContext.getCurrentMessageContext();
>
> but the msgContext is null in the response.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
> For additional commands, e-mail: wss4j-dev-help@ws.apache.org
>
>
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org


RE: Programmatically set encryption user in server

Posted by Mark Badorrek <mb...@avoga.com.au>.
I've used to following code to programatically set the user for 'UsernameToken' in the security header.
 
 
String username = "secretUser";

 Options options = new Options();

 stub._getServiceClient().setOptions(options);

 stub._getServiceClient().setTargetEPR(new EndpointReference(endpoint));

 options.setProperty(WSSHandlerConstants.OUTFLOW_SECURITY, getOutflowConfiguration(username));

stub._getServiceClient().engageModule(new QName("rampart"));

However, this is engaging rampart programatically. I haven't tried this using a 'axis2_client.xml' yet but hopefully this sort of thing will also work. I imagine that setting the encryption user wold be similar.
 
Incidently, If anyone is aware of the 'proper' way to do this could you please show a code snippet?
 
Cheers,
 
Mark B

 
________________________________

From: Konstantinos Pateras [mailto:kpateras@googlemail.com]
Sent: Fri 5/18/2007 9:51 AM
To: wss4j-dev@ws.apache.org
Subject: Programmatically set encryption user in server



Hi all, I have set up Axis2 1.1.1 and Rampart 1.1 and configure it (I
followed the configuration instructions for Rampart 1.0 that are still
supported). I use UsernameToken and encryption  with a known key to
both parts but I want to set the encryption user programmatically in
server when it sends a response. This is because each user has its own
key stored in a database and is beeing retrieved in the
PasswordCallbackHandler.

Is there a way to do it like with
<encryptionUser>useReqSigCert</encryptionUser> that is used when the
incoming message is signed or can I get the calling user in
PasswordCallbackHandler when I send the response?

Another option is to pass a parameter to the constructor of the
PasswordCallbackHandler but I do not know where to instantiate the
handler in server.

I have tried the following in the PasswordCallbackHandler:

 MessageContext msgContext = MessageContext.getCurrentMessageContext();

but the msgContext is null in the response.

---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org




RE: Programmatically set encryption user in server

Posted by Mark Badorrek <mb...@avoga.com.au>.
I've used to following code to programatically set the user for 'UsernameToken' in the security header.
 
 
String username = "secretUser";

 Options options = new Options();

 stub._getServiceClient().setOptions(options);

 stub._getServiceClient().setTargetEPR(new EndpointReference(endpoint));

 options.setProperty(WSSHandlerConstants.OUTFLOW_SECURITY, getOutflowConfiguration(username));

stub._getServiceClient().engageModule(new QName("rampart"));

However, this is engaging rampart programatically. I haven't tried this using a 'axis2_client.xml' yet but hopefully this sort of thing will also work. I imagine that setting the encryption user wold be similar.
 
Incidently, If anyone is aware of the 'proper' way to do this could you please show a code snippet?
 
Cheers,
 
Mark B

 
________________________________

From: Konstantinos Pateras [mailto:kpateras@googlemail.com]
Sent: Fri 5/18/2007 9:51 AM
To: wss4j-dev@ws.apache.org
Subject: Programmatically set encryption user in server



Hi all, I have set up Axis2 1.1.1 and Rampart 1.1 and configure it (I
followed the configuration instructions for Rampart 1.0 that are still
supported). I use UsernameToken and encryption  with a known key to
both parts but I want to set the encryption user programmatically in
server when it sends a response. This is because each user has its own
key stored in a database and is beeing retrieved in the
PasswordCallbackHandler.

Is there a way to do it like with
<encryptionUser>useReqSigCert</encryptionUser> that is used when the
incoming message is signed or can I get the calling user in
PasswordCallbackHandler when I send the response?

Another option is to pass a parameter to the constructor of the
PasswordCallbackHandler but I do not know where to instantiate the
handler in server.

I have tried the following in the PasswordCallbackHandler:

 MessageContext msgContext = MessageContext.getCurrentMessageContext();

but the msgContext is null in the response.

---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org




Programmatically set encryption user in server

Posted by Konstantinos Pateras <kp...@googlemail.com>.
Hi all, I have set up Axis2 1.1.1 and Rampart 1.1 and configure it (I
followed the configuration instructions for Rampart 1.0 that are still
supported). I use UsernameToken and encryption  with a known key to
both parts but I want to set the encryption user programmatically in
server when it sends a response. This is because each user has its own
key stored in a database and is beeing retrieved in the
PasswordCallbackHandler.

Is there a way to do it like with
<encryptionUser>useReqSigCert</encryptionUser> that is used when the
incoming message is signed or can I get the calling user in
PasswordCallbackHandler when I send the response?

Another option is to pass a parameter to the constructor of the
PasswordCallbackHandler but I do not know where to instantiate the
handler in server.

I have tried the following in the PasswordCallbackHandler:

 MessageContext msgContext = MessageContext.getCurrentMessageContext();

but the msgContext is null in the response.

---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org


Programmatically set encryption user in server

Posted by Konstantinos Pateras <kp...@googlemail.com>.
Hi all, I have set up Axis2 1.1.1 and Rampart 1.1 and configure it (I
followed the configuration instructions for Rampart 1.0 that are still
supported). I use UsernameToken and encryption  with a known key to
both parts but I want to set the encryption user programmatically in
server when it sends a response. This is because each user has its own
key stored in a database and is beeing retrieved in the
PasswordCallbackHandler.

Is there a way to do it like with
<encryptionUser>useReqSigCert</encryptionUser> that is used when the
incoming message is signed or can I get the calling user in
PasswordCallbackHandler when I send the response?

Another option is to pass a parameter to the constructor of the
PasswordCallbackHandler but I do not know where to instantiate the
handler in server.

I have tried the following in the PasswordCallbackHandler:

 MessageContext msgContext = MessageContext.getCurrentMessageContext();

but the msgContext is null in the response.

---------------------------------------------------------------------
To unsubscribe, e-mail: wss4j-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: wss4j-dev-help@ws.apache.org