Example usage for javax.security.auth.callback UnsupportedCallbackException UnsupportedCallbackException

List of usage examples for javax.security.auth.callback UnsupportedCallbackException UnsupportedCallbackException

Introduction

In this page you can find the example usage for javax.security.auth.callback UnsupportedCallbackException UnsupportedCallbackException.

Prototype

public UnsupportedCallbackException(Callback callback, String msg) 

Source Link

Document

Constructs a UnsupportedCallbackException with the specified detail message.

Usage

From source file:wssec.TestWSSecurityUTDK.java

public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN
                    && "bob".equals(pc.getIdentifier())) {
                if (WSSecurityEngine.getInstance().getWssConfig().getPasswordsAreEncoded()) {
                    // "jux7xGGAjguKKHg9C+waOiLrCCE=" is the Base64 encoded SHA-1 hash of "security".
                    pc.setPassword("jux7xGGAjguKKHg9C+waOiLrCCE=");
                } else {
                    pc.setPassword("security");
                }/*from  w ww.j  a  v a  2 s  .co m*/
            } else {
                throw new IOException("Authentication failed");
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}

From source file:wssec.TestWSSecurityUTSignature.java

public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN
                    && "bob".equals(pc.getIdentifier())) {
                pc.setPassword("security");
            } else if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN && "bob".equals(pc.getIdentifier())) {
                pc.setPassword("security");
            } else {
                throw new IOException("Authentication failed");
            }/* ww  w .j ava 2 s. c o m*/
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}

From source file:wssec.TestWSSecurityWSS194.java

public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN && "alice".equals(pc.getIdentifier())) {
                pc.setPassword("verySecret");
            } else if (pc.getUsage() == WSPasswordCallback.SIGNATURE && "wss86".equals(pc.getIdentifier())) {
                pc.setPassword("security");
            } else {
                throw new IOException("Authentication failed");
            }//from  w ww  .ja  v  a  2 s  .com
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}

From source file:wssec.TestWSSecurityWSS199.java

public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            assertEquals(pc.getPasswordType(), WSConstants.PASSWORD_TEXT);
            if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) {
                if (!"wernerd".equals(pc.getIdentifier()) && !"verySecret".equals(pc.getPassword())) {
                    throw new IOException("Authentication failed");
                }//  w ww.j a v  a 2  s. c  om
            } else {
                throw new IOException("Authentication failed");
            }
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}

From source file:wssec.TestWSSecurityWSS234.java

public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
    for (int i = 0; i < callbacks.length; i++) {
        if (callbacks[i] instanceof WSPasswordCallback) {
            WSPasswordCallback pc = (WSPasswordCallback) callbacks[i];
            /*//from   w  w  w.ja v a2  s. co m
             * here call a function/method to lookup the password for
             * the given identifier (e.g. a user name or keystore alias)
             * e.g.: pc.setPassword(passStore.getPassword(pc.getIdentfifier))
             * for Testing we supply a fixed name here.
             */
            pc.setPassword("password");
        } else {
            throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
        }
    }
}