Package org.apache.wss4j.common.ext

Examples of org.apache.wss4j.common.ext.WSPasswordCallback


    }

    @Override
    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        if (callbacks[0] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

            if (pc.getUsage() == WSPasswordCallback.Usage.DECRYPT
                    || pc.getUsage() == WSPasswordCallback.Usage.SIGNATURE
                    || pc.getUsage() == WSPasswordCallback.Usage.USERNAME_TOKEN
                    ) {
                pc.setPassword(username);
            } else if (pc.getUsage() == WSPasswordCallback.Usage.SECRET_KEY
                    || pc.getUsage() == WSPasswordCallback.Usage.SECURITY_CONTEXT_TOKEN) {
                pc.setKey(secret);
            } else if (pc.getUsage() == WSPasswordCallback.Usage.PASSWORD_ENCRYPTOR_PASSWORD) {
                pc.setPassword("this-is-a-secret");
            } else {
                throw new UnsupportedCallbackException(pc, "Unrecognized CallbackHandlerImpl");
            }
        }
    }
View Full Code Here


                    }
                    byte[] encryptedEphemeralKey = cipher.wrap(secretKey);
                   
                    if (((WSSSecurityProperties)getSecurityProperties()).getCallbackHandler() != null) {
                        // Store the Encrypted Key in the CallbackHandler for processing on the inbound side
                        WSPasswordCallback callback =
                            new WSPasswordCallback(securityToken.getId(), Usage.ENCRYPTED_KEY_TOKEN);
                        callback.setKey(encryptedEphemeralKey);
                        try {
                            ((WSSSecurityProperties)getSecurityProperties()).getCallbackHandler().handle(new Callback[]{callback});
                        } catch (IOException e) { // NOPMD
                            // Do nothing
                        } catch (UnsupportedCallbackException e) { // NOPMD
View Full Code Here

        this.secret = secret;
    }

    @Override
    public void handle(javax.security.auth.callback.Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

//        if (pc.getUsage() == org.apache.wss4j.dom.WSPasswordCallback.DECRYPT || pc.getUsage() == org.apache.wss4j.WSPasswordCallback.SIGNATURE) {
        if ("wss40rev".equals(pc.getIdentifier())) {
            pc.setPassword("security");
        } else {
            pc.setPassword("default");
        }
/*        } else {
            throw new UnsupportedCallbackException(pc, "Unrecognized CallbackHandlerImpl");
        }
*/
        if (pc.getUsage() == WSPasswordCallback.Usage.SECRET_KEY ||
                pc.getUsage() == WSPasswordCallback.Usage.SECURITY_CONTEXT_TOKEN) {
            pc.setKey(secret);
        }
    }
View Full Code Here

    /**
     * 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;
            }
        }
    }
View Full Code Here

     * Here, we attempt 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;
            }
        }
    }
View Full Code Here

     * 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];
            if (pc.getUsage() == WSPasswordCallback.Usage.PASSWORD_ENCRYPTOR_PASSWORD) {
                pc.setPassword("this-is-a-secret");
            } else {
                String pass = passwords.get(pc.getIdentifier());
                if (pass != null) {
                    pc.setPassword(pass);
                    return;
                } else {
                    pc.setPassword("password");
                }
            }
        }
    }
View Full Code Here

        (byte)0x34, (byte)0x04,
    };
   
    public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
        for (int i = 0; i < callbacks.length; i++) {
            WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
            if (pc.getUsage() == WSPasswordCallback.Usage.SECRET_KEY) {
                pc.setKey(KEY);
            }
        }
    }
View Full Code Here

    private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");
   
    public static class ServerPasswordCallback implements CallbackHandler {
        public void handle(Callback[] callbacks) throws IOException,
                UnsupportedCallbackException {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];

            if (pc.getIdentifier().equals("bob")) {
                // set the password on the callback. This will be compared to the
                // password which was sent from the client.
                pc.setPassword("pwd");
            }
        }
View Full Code Here

        private SecurityToken securityToken;
       
        @Override
        public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
            for (int i = 0; i < callbacks.length; i++) {
                WSPasswordCallback pc = (WSPasswordCallback)callbacks[i];
                if (securityToken != null && pc.getIdentifier().equals(securityToken.getId())) {
                    pc.setKey(securityToken.getSecret());
                } else {
                    new org.apache.cxf.systest.ws.common.KeystorePasswordCallback().handle(callbacks);
                }
                   
            }
View Full Code Here

    /**
     * Here, we attempt 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];

            // System.out.println("**************** Server checking id: "+pc.getIdentifer());

            String pass = passwords.get(pc.getIdentifier());
            if (pass != null) {
                pc.setPassword(pass);
                return;
            }
        }

        //
View Full Code Here

TOP

Related Classes of org.apache.wss4j.common.ext.WSPasswordCallback

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.