System.out.println("identifier: " + wsPasswordCallback.getIdentifer() + ", usage: " + wsPasswordCallback.getUsage()); if (wsPasswordCallback.getUsage() == WSPasswordCallback.USERNAME_TOKEN) { if (!"GrouperSystem".equals(wsPasswordCallback.getIdentifer())) { throw new IOException("unknown user: " + wsPasswordCallback.getIdentifer()); wsPasswordCallback.setPassword("mypass"); return true; if (wsPasswordCallback.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) { if (!"GrouperSystem".equals(wsPasswordCallback.getIdentifer())) { throw new IOException("unknown user: " + wsPasswordCallback.getIdentifer()); if (!"mypass".equals(wsPasswordCallback.getPassword())) { throw new IOException("password incorrect for user: " + wsPasswordCallback.getIdentifer());
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pc = (WSPasswordCallback) callbacks[0]; if (pc.getIdentifier().equals("joe")) { pc.setPassword("password"); } }
/** * Try to get the secret key from a CallbackHandler implementation * @param cb a CallbackHandler implementation * @return An array of bytes corresponding to the secret key (can be null) * @throws WSSecurityException */ private static byte[] getSecretKeyFromCallbackHandler( String id, CallbackHandler cb ) throws WSSecurityException { if (cb != null) { WSPasswordCallback pwcb = new WSPasswordCallback(id, WSPasswordCallback.SECRET_KEY); try { cb.handle(new Callback[]{pwcb}); } catch (Exception e1) { throw new WSSecurityException(WSSecurityException.FAILURE, "noKey", new Object[] { id }, e1); } return pwcb.getKey(); } return null; }
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[i]; String id = pwcb.getIdentifer(); if ("client".equals(id)) { pwcb.setPassword("apache"); } else if ("service".equals(id)) { pwcb.setPassword("apache"); } } } }
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[0]; String id = pwcb.getIdentifier(); int usage = pwcb.getUsage(); if (usage == WSPasswordCallback.SIGNATURE || usage == WSPasswordCallback.DECRYPT) { // Logic to get the private key password for signture or decryption if ("client".equals(id)) { pwcb.setPassword("automation"); } else if ("service".equals(id)) { pwcb.setPassword("automation"); } else if ("wso2carbon".equals(id)) { pwcb.setPassword("wso2carbon"); } else if ("alice".equals(id)) { pwcb.setPassword("password"); } else if ("bob".equals(id)) { pwcb.setPassword("password"); } } }
if (pc.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) { if (pc.getIdentifier().equals("Ron") && pc.getPassword().equals("noR")) { if (pc.getIdentifier().equals("joe") && pc.getPassword().equals("eoj")) { if (pc.getPassword().equals("sirhC")) { if (pc.getUsage() == WSPasswordCallback.KEY_NAME) { pc.setKey(key); } else if (pc.getIdentifier().equals("alice")) { pc.setPassword("password"); } else if (pc.getIdentifier().equals("bob")) { pc.setPassword("password"); } else if (pc.getIdentifier().equals("Ron")) { pc.setPassword("noR"); } else if (pc.getIdentifier().equals("joe")) { pc.setPassword("eoj"); } else if (pc.getIdentifier().equals("ip")) {
public void handle(Callback[] cb) throws IOException, UnsupportedCallbackException { ((WSPasswordCallback) cb[0]).setPassword(this.passwd); }
) throws WSSecurityException { WSPasswordCallback pwCb = new WSPasswordCallback(identifier, WSPasswordCallback.DECRYPT); try { Callback[] callbacks = new Callback[]{pwCb}; return pwCb.getPassword();
System.out.println("Callback usage is " + callback.getUsage()); if (callback.getUsage() == WSPasswordCallback.SIGNATURE) { System.out.println("callback of type SIGNATURE"); callback.setPassword(clientPassword); if (callback.getUsage() == WSPasswordCallback.KEY_NAME) { System.out.println("Callback for setting key not implemented"); if (callback.getUsage() == WSPasswordCallback.DECRYPT) { System.out.println("callback of type DECRYPT"); callback.setPassword(clientPassword);
WSPasswordCallback passwordCallback = handler.getPasswordCB(reqData.getUsername(), actionToDo, callbackHandler, reqData); username = passwordCallback.getIdentifier(); password = passwordCallback.getPassword();
String id = pc.getIdentifier(); if((pc.getUsage() == WSPasswordCallback.SECURITY_CONTEXT_TOKEN || pc.getUsage() == WSPasswordCallback.CUSTOM_TOKEN) && this.store != null) { Token tok; if(tok != null) { pc.setKey(tok.getSecret()); pc.setCustomToken((Element)tok.getToken()); throw new IOException(e.getMessage()); } else if (pc.getUsage() == WSPasswordCallback.SECRET_KEY){ try { pc.setKey(tok.getSecret()); pc.setCustomToken((Element)tok.getToken());
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException, AuthenticationException { for (int i = 0; i < callbacks.length; i++) { WSPasswordCallback pwcb = (WSPasswordCallback) callbacks[i]; MessageContext currentMessageContext = MessageContext.getCurrentMessageContext(); String id = pwcb.getIdentifer(); if (pwcb.getUsage() == WSPasswordCallback.USERNAME_TOKEN_UNKNOWN) { String password = pwcb.getPassword(); CredentialsCallbackHandler ccbh = new CredentialsCallbackHandler(); ccbh.add(new UsernamePasswordCredential(id, password)); if (m_securityConfig == null) { throw new AxisFault("No SecurityConfiguration found"); } if (getSecurityServiceConfig() == null) { throw new AxisFault("No ServiceConfiguration " + "found, please configure it appropriately."); } AuthenticationService auth = getSecurityServiceConfig() .getAuthenticationService(); auth.login(ccbh); } if (pwcb.getUsage() == WSPasswordCallback.SIGNATURE) { } } }
if (callbacks[i] instanceof WSPasswordCallback) { WSPasswordCallback wsPasswordCallback = (WSPasswordCallback) callbacks[i]; LOG.debug("identifier: "+wsPasswordCallback.getIdentifer()+", usage: "+wsPasswordCallback.getUsage());
WSPasswordCallback passwordCallback = handler.getPasswordCB(reqData.getUsername(), actionToDo, callbackHandler, reqData); wsSign.setUserInfo(reqData.getUsername(), passwordCallback.getPassword());
wsSign.setUserInfo(reqData.getSignatureUser(), passwordCallback.getPassword()); wsSign.setUseSingleCertificate(reqData.isUseSingleCert()); if (reqData.getSignatureParts().size() > 0) { if (passwordCallback.getKey() != null) { wsSign.setSecretKey(passwordCallback.getKey());
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { WSPasswordCallback pc = null; try { pc = (WSPasswordCallback) callbacks[0]; } catch (ClassCastException ce) { UnsupportedCallbackException exception = new UnsupportedCallbackException(pc, "callback method is not of type " + WSPasswordCallback.class.getName()); exception.setStackTrace(ce.getStackTrace()); // stack trace is preserved throw exception; } String username = pc.getIdentifier(); if (passwordCache.get(username) == null) { throw new UnsupportedCallbackException(pc, "Password not set in client. Call static method " + ProgrammedPasswordCallback.class.getName() + ".addUserNameAndPassword(\"<your username>\", \"<your password>\")"); } setPassword(pc, username); }
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (Callback callback : callbacks) { if (callback instanceof WSPasswordCallback) { WSPasswordCallback passwordCallback = (WSPasswordCallback) callback; if (passwordCallback.getUsage() == usage) { handle(passwordCallback); } } } }
/** * Construct a WSPasswordCallback instance * @param username The username * @param doAction The action to perform * @return a WSPasswordCallback instance * @throws WSSecurityException */ private WSPasswordCallback constructPasswordCallback( String username, int doAction ) throws WSSecurityException { int reason = WSPasswordCallback.UNKNOWN; switch (doAction) { case WSConstants.UT: case WSConstants.UT_SIGN: reason = WSPasswordCallback.USERNAME_TOKEN; break; case WSConstants.SIGN: reason = WSPasswordCallback.SIGNATURE; break; case WSConstants.ENCR: reason = WSPasswordCallback.SECRET_KEY; break; } return new WSPasswordCallback(username, reason); }
new WSPasswordCallback(id, WSPasswordCallback.CUSTOM_TOKEN); try { cb.handle(new Callback[]{pwcb}); Element assertionElem = pwcb.getCustomToken(); if (assertionElem != null) { return (Element)doc.importNode(assertionElem, true);
@Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { for (int i = 0; i < callbacks.length; i++) { if (callbacks[i] instanceof WSPasswordCallback) { WSPasswordCallback passwordCallback = (WSPasswordCallback) callbacks[i]; passwordCallback.setPassword(this.password); } else { throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback"); } } }