Apr 5, 2011

Axis2/Rampart - Access the authentication details within the service class

In certain cases, it is required to access the username of the authenticated service consumer or the alias of the certificate which was used for signature verification of the messages within the service class in Axis2/Rampart.

These information is available as properties in the Axis2 message context. You can get hold of the Axis2 message context in the following manner.


MessageContext msgCtx = MessageContext.getCurrentMessageContext();


To access the username of the authenticated user ;


msgCtx.getProperty(RampartMessageData.USERNAME);

(This is available since 1.5 release of Rampart.)


To access the certificate alias of the public key which was used to validate the signature of the message (In Asymmetric Binding case) ;


msgCtx.getProperty(RampartMessageData.SIGNATURE_CERT_ALIAS);

(This will be available from Rampart 1.6 release onwards which will be out soon)

0 comments:

Post a Comment