Hi,

I'm reading information from signature header in service to get the alias of 
the certificate from one operation in my service. I'm using the code in [1] 
with rampart 1.3. When I use policy I don't have any problems but when I use 
rampart basic configuration, execution thread doesn't get out of env.build(); 
in Axis2Util.getDocumentFromSOAPEnvelope(msgCtx.getEnvelope(), true); in 
constructor RampartMessageData(msgContext, false); 

Shouldn't it work anyway? Can anybody tell me how can I get the rampart 
configuration from the services.xml to get the crypto element? I'm using [2] 
for that but I would like to know if there's any easier way to do that.

 
 Thanks,
 
 Jorge Fernández


[1]
public static String getAlias(MessageContext msgContext)throws 
RampartException,WSSecurityException{
        OMElement 
secHeader=msgContext.getEnvelope().getHeader().getFirstChildWithName(new 
QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";,
 "Security"));
        OMElement signature=secHeader.getFirstChildWithName(new 
QName("http://www.w3.org/2000/09/xmldsig#";, "Signature"));
        OMElement keyInfo=signature.getFirstChildWithName(new 
QName("http://www.w3.org/2000/09/xmldsig#";, "KeyInfo"));
        OMElement reference=keyInfo.getFirstChildWithName(new 
QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";,
 "SecurityTokenReference"));
        OMElement keyIdentifier=reference.getFirstChildWithName(new 
QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd";,
 "KeyIdentifier"));
        if(keyIdentifier==null)
            return null;
        String key=keyIdentifier.getText();
        RampartMessageData rmd = new RampartMessageData(msgContext, false);
        RampartPolicyData rpd = rmd.getPolicyData();
        if(rpd!=null) {
            Crypto 
crypto=RampartUtil.getSignatureCrypto(rpd.getRampartConfig(), 
msgContext.getAxisService().getClassLoader());
            String systemCode=crypto.getAliasForX509Cert(Base64.decode(key));
            return systemCode;
        }else
            return null;
    }


[2]
OMElement 
inflowSecConfig=MessageContext.getCurrentMessageContext().getOperationContext().getAxisOperation().getParameter("InflowSecurity").getParameterElement();
            OMElement 
action=(OMElement)inflowSecConfig.getChildElements().next();
            Iterator parameters=action.getChildElements();
            OMElement propertiesFile=null;
            String propertiesFileName=null;
            while((propertiesFile=(OMElement)parameters.next())!=null && 
!"signaturePropFile".equalsIgnoreCase(propertiesFileName)){
                propertiesFileName=propertiesFile.getLocalName();
            }



       
---------------------------------

Sé un Mejor Amante del Cine
¿Quieres saber cómo? ¡Deja que otras personas te ayuden!.

Reply via email to