Hi,

I was wondering if there is a way to retrieve the username, used by UsernameToken at the actual service class.

The idea is:
Since every message already provides a valid username I don't wanna pass it to the service port by parameter.

There was one example which I probably could use but I'm hoping that there is an easier way and I'm neither sure that this is always acting like expected.

--- example ---
// get the message context first
MessageContext msgContext = MessageContext.getCurrentContext();
Message reqMsg = msgContext.getRequestMessage();

Vector results = null;
// get the result Vector from the property
if ((results = (Vector) msgContext.getProperty(WSHandlerConstants.RECV_RESULTS))
             == null) {
            System.out.println("No security results!!");
}
System.out.println("Number of results: " + results.size());Retrieving
for (int i = 0; i < results.size(); i++) {
     WSHandlerResult hResult = (WSHandlerResult)results.get(i);
     String actor = hResult.getActor();
     Vector hResults = hResult.getResults();
     for (int j = 0; j < hResults.size(); j++) {
WSSecurityEngineResult eResult = (WSSecurityEngineResult) hResults.get(j);
        // Note: an encryption action does not have an associated principal
        // only Signature and UsernameToken actions return a principal
        if (eResult.getAction() != WSConstants.ENCR) {
                   System.out.println(eResult.getPrincipal().getName());
        }
    }
}


System.out.println(eResult.getPrincipal().getName()); is returning the username so far.

Thanks in advance
-Benjamin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to