private void extractBasic(String source, Set<Credential> credentials) { String encoded = source.substring(6, source.length()); String decoded = Base64.decodeToString(encoded, _charset); if (decoded.indexOf(':') != -1) { String[] split = decoded.split(":", 2); String name = split.length > 0 ? split[0] : null; if (name != null) { credentials.add(new NameCredential(name)); } String password = split.length > 1 ? split[1] : null; if (password != null) { credentials.add(new PasswordCredential(password)); } } }
/** * {@inheritDoc} */ @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { Set<Credential> credentials = getCredentials(); if (credentials == null) { throw BaseSecurityMessages.MESSAGES.credentialsNotSet(); } for (Callback cb : callbacks) { if (cb instanceof NameCallback) { for (Credential cred : credentials) { if (cred instanceof NameCredential) { ((NameCallback)cb).setName(((NameCredential)cred).getName()); } } } else if (cb instanceof PasswordCallback) { for (Credential cred : credentials) { if (cred instanceof PasswordCredential) { ((PasswordCallback)cb).setPassword(((PasswordCredential)cred).getPassword()); } } } } }
/** * {@inheritDoc} */ @Override public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException { Set<Credential> credentials = getCredentials(); if (credentials == null) { throw BaseSecurityMessages.MESSAGES.credentialsNotSet(); } for (Callback cb : callbacks) { if (cb instanceof NameCallback) { for (Credential cred : credentials) { if (cred instanceof NameCredential) { ((NameCallback)cb).setName(((NameCredential)cred).getName()); } } } else if (cb instanceof PasswordCallback) { for (Credential cred : credentials) { if (cred instanceof PasswordCredential) { ((PasswordCallback)cb).setPassword(((PasswordCredential)cred).getPassword()); } } } } }
private void extractDigest(String source, Set<Credential> credentials) { // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! // https://issues.jboss.org/browse/SWITCHYARD-1082 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Map<String,String> map = new HashMap<String,String>(); String everything = source.substring(6, source.length()).trim(); List<String> list = Strings.splitTrimToNull(everything, ",\n"); for (String pair : list) { String[] split = pair.split("=", 2); String key = split.length > 0 ? split[0] : null; String value = split.length > 1 ? split[1] : null; if (key != null && value != null) { if (value.startsWith("\"") && value.endsWith("\"")) { value = value.substring(1, value.length() - 1); } map.put(key, value); } } String username = map.get("username"); if (username != null) { credentials.add(new NameCredential(username)); } // TODO: complete per SWITCHYARD-1082 }
String name = split.length > 0 ? split[0] : null; if (name != null) { credentials.add(new NameCredential(name)); credentials.add(new NameCredential(username));
String name = XMLHelper.valueOf(usernameChildNode.getFirstChild()); if (name != null) { credentials.add(new NameCredential(name));
String name = XMLHelper.valueOf(usernameChildNode.getFirstChild()); if (name != null) { credentials.add(new NameCredential(name));