Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Ws Wiki" for change 
notification.

The following page has been changed by DavanumSrinivas:
http://wiki.apache.org/ws/FrontPage/WsFx/wss4jFAQ

------------------------------------------------------------------------------
   1. [#npe Spurious Null Pointer Exception]
   1. [#debug Where can I change the debug level of wss4j?]
   1. [#many I have many clients and one service (and i need 
signature+encryption). Is there a way to handle many client certs?]
+  1. [#username How do i extract user's name or certificate info from my web 
service?]
  
  
  [[Anchor(isWSS4J)]]
@@ -138, +139 @@

  
  As pointed out, usually no modification in client/service coding necessary, 
also no need to change the trust handling inside WSDoAllReceiver except that 
you need a very special certificate trust verification.
  
+ [[Anchor(username)]]
+ ==== How do i extract user's name or certificate info from my web service? 
====
+ {{{
+ MessageContext msgContext = MessageContext.getCurrentContext();
+ Vector results = (Vector) 
msgContext.getProperty(WSHandlerConstants.RECV_RESULTS);
+ log.trace("Potential number of usernames: " + results.size());
+ for (int i = 0; results != null && i < results.size(); i++) {
+     WSHandlerResult hResult = (WSHandlerResult) results.get(i);
+     Vector hResults = hResult.getResults();
+     for (int j = 0; j < hResults.size(); j++) {
+         WSSecurityEngineResult eResult = (WSSecurityEngineResult) 
hResults.get(j);
+         // An encryption or timestamp action does not have an associated 
principal
+         // only Signature and UsernameToken actions return a principal
+         if (eResult.getAction() != WSConstants.ENCR &&
+                   eResult.getAction() != WSConstants.TS) {
+             System.out.println("Principal's name: " + 
eResult.getPrincipal().getName());
+         }
+     }
+ }
+ }}}
+ 

Reply via email to