Search in sources :

Example 1 with JasyptPasswordEncryptor

use of org.apache.wss4j.common.crypto.JasyptPasswordEncryptor in project cxf by apache.

the class AbstractWSS4JStaxInterceptor method getPasswordEncryptor.

protected PasswordEncryptor getPasswordEncryptor(SoapMessage soapMessage, WSSSecurityProperties securityProperties) {
    PasswordEncryptor passwordEncryptor = (PasswordEncryptor) soapMessage.getContextualProperty(SecurityConstants.PASSWORD_ENCRYPTOR_INSTANCE);
    if (passwordEncryptor != null) {
        return passwordEncryptor;
    }
    CallbackHandler callbackHandler = securityProperties.getCallbackHandler();
    if (callbackHandler == null) {
        callbackHandler = (CallbackHandler) getProperties().get(ConfigurationConstants.PW_CALLBACK_REF);
    }
    if (callbackHandler != null) {
        return new JasyptPasswordEncryptor(callbackHandler);
    }
    return null;
}
Also used : CallbackHandler(javax.security.auth.callback.CallbackHandler) JasyptPasswordEncryptor(org.apache.wss4j.common.crypto.JasyptPasswordEncryptor) PasswordEncryptor(org.apache.wss4j.common.crypto.PasswordEncryptor) JasyptPasswordEncryptor(org.apache.wss4j.common.crypto.JasyptPasswordEncryptor)

Example 2 with JasyptPasswordEncryptor

use of org.apache.wss4j.common.crypto.JasyptPasswordEncryptor in project cxf by apache.

the class WSS4JUtils method getPasswordEncryptor.

public static PasswordEncryptor getPasswordEncryptor(Message message) {
    if (message == null) {
        return null;
    }
    PasswordEncryptor passwordEncryptor = (PasswordEncryptor) message.getContextualProperty(SecurityConstants.PASSWORD_ENCRYPTOR_INSTANCE);
    if (passwordEncryptor != null) {
        return passwordEncryptor;
    }
    Object o = SecurityUtils.getSecurityPropertyValue(SecurityConstants.CALLBACK_HANDLER, message);
    try {
        CallbackHandler callbackHandler = SecurityUtils.getCallbackHandler(o);
        if (callbackHandler != null) {
            return new JasyptPasswordEncryptor(callbackHandler);
        }
    } catch (Exception ex) {
        return null;
    }
    return null;
}
Also used : CallbackHandler(javax.security.auth.callback.CallbackHandler) JasyptPasswordEncryptor(org.apache.wss4j.common.crypto.JasyptPasswordEncryptor) PasswordEncryptor(org.apache.wss4j.common.crypto.PasswordEncryptor) JasyptPasswordEncryptor(org.apache.wss4j.common.crypto.JasyptPasswordEncryptor) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) IOException(java.io.IOException) XMLSecurityException(org.apache.xml.security.exceptions.XMLSecurityException)

Aggregations

CallbackHandler (javax.security.auth.callback.CallbackHandler)2 JasyptPasswordEncryptor (org.apache.wss4j.common.crypto.JasyptPasswordEncryptor)2 PasswordEncryptor (org.apache.wss4j.common.crypto.PasswordEncryptor)2 IOException (java.io.IOException)1 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)1 XMLSecurityException (org.apache.xml.security.exceptions.XMLSecurityException)1