I sign my messages using DirectReference method ; the problem is that i can't
get the certificate's common name using the code below. The same code works
fine if I use IssuerSerial method.

public class SecurityHandler extends AbstractHandler {
        private static final Log Log = LogFactory.getLog(SecurityHandler.class);

        public void invoke(MessageContext context) throws Exception {
                try {
                Vector result = (Vector)
context.getProperty(WSHandlerConstants.RECV_RESULTS);
                if (result != null) {
                        for (int i = 0; i < result.size(); i++)
                        {
                            WSHandlerResult res = (WSHandlerResult) 
result.get(i);
                            for (int j = 0; j < res.getResults().size(); j++)
                            {
                                WSSecurityEngineResult secRes = 
(WSSecurityEngineResult)
res.getResults().get(j);
                                int action  = secRes.getAction();
                
                                // SIGNATURE
                                if( ( action & WSConstants.SIGN ) > 0 ){
                                    //X509Certificate cert = 
secRes.getCertificate();
                                    X500Name principal = (X500Name) 
secRes.getPrincipal();
                                    // Do something whith cert
                                    Log.info("Signature for : "  +
principal.getCommonName());
                                   
context.getInMessage().setProperty("net.gicm.astral.commonname",
principal.getCommonName());
                                }
                            }
                        }
                }
                } catch (Throwable e) {
                Log.error("Erreur lors de la récupération du common name du
certificat", e);
        }
        }
}
-- 
View this message in context: 
http://www.nabble.com/WS-Security-%3A-getting-commmon-name-with-DirectReference-or-IssuerSerial-method-tf3397006.html#a9458054
Sent from the XFire - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply via email to