Search in sources :

Example 6 with WSPasswordCallback

use of org.apache.wss4j.common.ext.WSPasswordCallback in project tesb-rt-se by Talend.

the class ServiceKeystorePasswordCallback method handle.

public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
        String pass = (String) passwords.get(pc.getIdentifier());
        if (pass != null) {
            pc.setPassword(pass);
            return;
        }
    }
}
Also used : WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback)

Example 7 with WSPasswordCallback

use of org.apache.wss4j.common.ext.WSPasswordCallback in project tesb-rt-se by Talend.

the class WSPasswordCallbackHandlerTest method handleNotEncryptedPasswordTest.

@Test
public void handleNotEncryptedPasswordTest() throws Exception {
    String username = "username";
    String password = "password";
    WSPasswordCallbackHandler h = new WSPasswordCallbackHandler(username, password);
    Callback c = new WSPasswordCallback(username, 0);
    List<Callback> cs = new ArrayList<Callback>();
    cs.add(c);
    h.handle(cs.toArray(new Callback[0]));
}
Also used : WSPasswordCallbackHandler(org.talend.esb.security.saml.WSPasswordCallbackHandler) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Callback(javax.security.auth.callback.Callback) ArrayList(java.util.ArrayList) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Test(org.junit.Test)

Example 8 with WSPasswordCallback

use of org.apache.wss4j.common.ext.WSPasswordCallback in project tesb-rt-se by Talend.

the class PasswordCallbackHandlerTest method testPasswordCallbackHandler.

@Test
public void testPasswordCallbackHandler() throws Exception {
    PasswordCallbackHandler handler = new PasswordCallbackHandler();
    List<Callback> callbacksList = new ArrayList<Callback>();
    WSPasswordCallback callback = new WSPasswordCallback("id", 0);
    callback.setIdentifier("mystskey");
    callbacksList.add(callback);
    handler.handle(callbacksList.toArray(new Callback[callbacksList.size()]));
    assertSame("stskpass", callback.getPassword());
}
Also used : WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Callback(javax.security.auth.callback.Callback) ArrayList(java.util.ArrayList) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Test(org.junit.Test)

Example 9 with WSPasswordCallback

use of org.apache.wss4j.common.ext.WSPasswordCallback in project syncope by apache.

the class SAMLSPCallbackHandler method handle.

@Override
public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (Callback callback : callbacks) {
        if (callback instanceof WSPasswordCallback) {
            WSPasswordCallback wspc = (WSPasswordCallback) callback;
            wspc.setPassword(keyPass);
        }
    }
}
Also used : WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback) Callback(javax.security.auth.callback.Callback) WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback)

Example 10 with WSPasswordCallback

use of org.apache.wss4j.common.ext.WSPasswordCallback in project jbossws-cxf by jbossws.

the class KeystorePasswordCallback method handle.

/**
 * It attempts to get the password from the private
 * alias/passwords map.
 */
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
        String pass = passwords.get(pc.getIdentifier());
        if (pass != null) {
            pc.setPassword(pass);
            return;
        }
    }
}
Also used : WSPasswordCallback(org.apache.wss4j.common.ext.WSPasswordCallback)

Aggregations

WSPasswordCallback (org.apache.wss4j.common.ext.WSPasswordCallback)69 Callback (javax.security.auth.callback.Callback)22 CallbackHandler (javax.security.auth.callback.CallbackHandler)20 IOException (java.io.IOException)17 UnsupportedCallbackException (javax.security.auth.callback.UnsupportedCallbackException)14 WSSecurityException (org.apache.wss4j.common.ext.WSSecurityException)11 ArrayList (java.util.ArrayList)8 HashMap (java.util.HashMap)8 WSS4JOutInterceptor (org.apache.cxf.ws.security.wss4j.WSS4JOutInterceptor)8 QName (javax.xml.namespace.QName)7 Endpoint (org.apache.cxf.endpoint.Endpoint)7 Test (org.junit.Test)7 URL (java.net.URL)6 Service (javax.xml.ws.Service)6 SAAJOutInterceptor (org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor)6 Client (org.apache.cxf.endpoint.Client)6 Crypto (org.apache.wss4j.common.crypto.Crypto)6 PrivateKey (java.security.PrivateKey)3 X509Certificate (java.security.cert.X509Certificate)3 DestroyFailedException (javax.security.auth.DestroyFailedException)3