/** * @return */ public String[] getAttributeNames() { return simpleCredentials.getAttributeNames(); }
public String[] getAttributeNames() { return registrySimpleCredentials.getAttributeNames(); }
/** * Return the credentials attributes. */ private Map<String, Object> getAttributeMap(SimpleCredentials creds) { HashMap<String, Object> map = new HashMap<String, Object>(); String[] keys = creds.getAttributeNames(); for (int i = 0; i < keys.length; i++) { map.put(keys[i], creds.getAttribute(keys[i])); } return map; }
private Map<String, Object> getAttributeMap( SimpleCredentials creds ) { HashMap<String, Object> map = new HashMap<String, Object>(); String[] keys = creds.getAttributeNames(); for (int i = 0; i < keys.length; i++) { map.put(keys[i], creds.getAttribute(keys[i])); } return map; }
/** * Return the credentials attributes. */ private Map<String, Object> getAttributeMap(SimpleCredentials creds) { HashMap<String, Object> map = new HashMap<String, Object>(); String[] keys = creds.getAttributeNames(); for (int i = 0; i < keys.length; i++) { map.put(keys[i], creds.getAttribute(keys[i])); } return map; }
@Override @NotNull public Map<String, ?> getAttributes(@NotNull Credentials credentials) { if (credentials instanceof SimpleCredentials) { final SimpleCredentials sc = (SimpleCredentials) credentials; return Maps.asMap(ImmutableSet.copyOf(sc.getAttributeNames()), new Function<String, Object>() { @Nullable @Override public Object apply(String input) { return sc.getAttribute(input); } }); } else { return Collections.emptyMap(); } }
@Override @Nonnull public Map<String, ?> getAttributes(@Nonnull Credentials credentials) { if (credentials instanceof SimpleCredentials) { final SimpleCredentials sc = (SimpleCredentials) credentials; return Maps.asMap(ImmutableSet.copyOf(sc.getAttributeNames()), new Function<String, Object>() { @Nullable @Override public Object apply(String input) { return sc.getAttribute(input); } }); } else { return Collections.emptyMap(); } }
private AuthInfo createAuthInfo(@NotNull Set<? extends Principal> principals) { Credentials creds; if (credentials instanceof ImpersonationCredentials) { creds = ((ImpersonationCredentials) credentials).getBaseCredentials(); } else { creds = credentials; } Map<String, Object> attributes = new HashMap<>(); Object shared = sharedState.get(SHARED_KEY_ATTRIBUTES); if (shared instanceof Map) { ((Map<?,?>) shared).forEach((key, value) -> attributes.put(key.toString(), value)); } else if (creds instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials) creds; for (String attrName : sc.getAttributeNames()) { attributes.put(attrName, sc.getAttribute(attrName)); } } return new AuthInfoImpl(userId, attributes, principals); } }
private AuthInfo createAuthInfo(@Nonnull Set<? extends Principal> principals) { Credentials creds; if (credentials instanceof ImpersonationCredentials) { creds = ((ImpersonationCredentials) credentials).getBaseCredentials(); } else { creds = credentials; } Map<String, Object> attributes = new HashMap<String, Object>(); Object shared = sharedState.get(SHARED_KEY_ATTRIBUTES); if (shared instanceof Map) { for (Object key : ((Map) shared).keySet()) { attributes.put(key.toString(), ((Map) shared).get(key)); } } else if (creds instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials) creds; for (String attrName : sc.getAttributeNames()) { attributes.put(attrName, sc.getAttribute(attrName)); } } return new AuthInfoImpl(userId, attributes, principals); } }
private AuthInfo createAuthInfo(@NotNull Set<? extends Principal> principals) { Credentials creds; if (credentials instanceof ImpersonationCredentials) { creds = ((ImpersonationCredentials) credentials).getBaseCredentials(); } else { creds = credentials; } Map<String, Object> attributes = new HashMap<>(); Object shared = sharedState.get(SHARED_KEY_ATTRIBUTES); if (shared instanceof Map) { ((Map<?,?>) shared).forEach((key, value) -> attributes.put(key.toString(), value)); } else if (creds instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials) creds; for (String attrName : sc.getAttributeNames()) { attributes.put(attrName, sc.getAttribute(attrName)); } } return new AuthInfoImpl(userId, attributes, principals); } }
/** * Build a new instance of <code>CryptedSimpleCredentials</code> from the * given {@link javax.jcr.SimpleCredentials SimpleCredentials} and create * the crypted password field using the {@link SecurityConstants#DEFAULT_DIGEST * default digest}. * * @param credentials * @throws NoSuchAlgorithmException * @throws UnsupportedEncodingException * @deprecated */ public CryptedSimpleCredentials(SimpleCredentials credentials) throws NoSuchAlgorithmException, UnsupportedEncodingException { userId = credentials.getUserID(); if (userId == null || userId.length() == 0) { throw new IllegalArgumentException(); } char[] pwd = credentials.getPassword(); if (pwd == null) { throw new IllegalArgumentException(); } String password = new String(pwd); hashedPassword = PasswordUtility.buildPasswordHash(password); String[] attNames = credentials.getAttributeNames(); attributes = new HashMap<String, Object>(attNames.length); for (String attName : attNames) { attributes.put(attName, credentials.getAttribute(attName)); } }
/** * Build a new instance of <code>CryptedSimpleCredentials</code> from the * given {@link javax.jcr.SimpleCredentials SimpleCredentials} and create * the crypted password field using the {@link SecurityConstants#DEFAULT_DIGEST * default digest}. * * @param credentials * @throws NoSuchAlgorithmException * @throws UnsupportedEncodingException * @deprecated */ public CryptedSimpleCredentials(SimpleCredentials credentials) throws NoSuchAlgorithmException, UnsupportedEncodingException { userId = credentials.getUserID(); if (userId == null || userId.length() == 0) { throw new IllegalArgumentException(); } char[] pwd = credentials.getPassword(); if (pwd == null) { throw new IllegalArgumentException(); } String password = new String(pwd); hashedPassword = PasswordUtility.buildPasswordHash(password); String[] attNames = credentials.getAttributeNames(); attributes = new HashMap<String, Object>(attNames.length); for (String attName : attNames) { attributes.put(attName, credentials.getAttribute(attName)); } }
/** * Create a separate token node underneath a dedicated token store within * the user home node. That token node contains the hashed token, the * expiration time and additional mandatory attributes that will be verified * during login. * * @param user * @param sc The current simple credentials. * @return A new {@code TokenInfo} or {@code null} if the token could not * be created. */ public TokenInfo createToken(User user, SimpleCredentials sc) throws RepositoryException { TokenInfo tokenInfo = null; if (sc != null && user != null && user.getID().equalsIgnoreCase(sc.getUserID())) { String[] attrNames = sc.getAttributeNames(); Map<String, String> attributes = new HashMap<String, String>(attrNames.length); for (String attrName : sc.getAttributeNames()) { attributes.put(attrName, sc.getAttribute(attrName).toString()); } tokenInfo = createToken(user, attributes); if (tokenInfo != null) { // also set the new token to the simple credentials. sc.setAttribute(TOKEN_ATTRIBUTE, tokenInfo.getToken()); } } return tokenInfo; }
/** * Create a separate token node underneath a dedicated token store within * the user home node. That token node contains the hashed token, the * expiration time and additional mandatory attributes that will be verified * during login. * * @param user * @param sc The current simple credentials. * @return A new {@code TokenInfo} or {@code null} if the token could not * be created. */ public TokenInfo createToken(User user, SimpleCredentials sc) throws RepositoryException { TokenInfo tokenInfo = null; if (sc != null && user != null && user.getID().equalsIgnoreCase(sc.getUserID())) { String[] attrNames = sc.getAttributeNames(); Map<String, String> attributes = new HashMap<String, String>(attrNames.length); for (String attrName : sc.getAttributeNames()) { attributes.put(attrName, sc.getAttribute(attrName).toString()); } tokenInfo = createToken(user, attributes); if (tokenInfo != null) { // also set the new token to the simple credentials. sc.setAttribute(TOKEN_ATTRIBUTE, tokenInfo.getToken()); } } return tokenInfo; }
for (String name : sc.getAttributeNames()) { if (!TOKEN_ATTRIBUTE.equals(name)) { String value = sc.getAttribute(name).toString();
for (String name : sc.getAttributeNames()) { if (!TOKEN_ATTRIBUTE.equals(name)) { String value = sc.getAttribute(name).toString();
String[] attributeNames = simple.getAttributeNames(); if (attributeNames != null && attributeNames.length != 0) { sessionAttributes = new HashMap<String, Object>(); for (String attributeName : simple.getAttributeNames()) { Object attributeValue = simple.getAttribute(attributeName); sessionAttributes.put(attributeName, attributeValue);
String[] attributeNames = simple.getAttributeNames(); if (attributeNames != null && attributeNames.length != 0) { sessionAttributes = new HashMap<String, Object>(); for (String attributeName : simple.getAttributeNames()) { Object attributeValue = simple.getAttribute(attributeName); sessionAttributes.put(attributeName, attributeValue);
if (credentials instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials) credentials; for (String name : sc.getAttributeNames()) { if (!TokenBasedAuthentication.isMandatoryAttribute(name)) { session.setAttribute(name, sc.getAttribute(name));
if (credentials instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials) credentials; for (String name : sc.getAttributeNames()) { if (!TokenBasedAuthentication.isMandatoryAttribute(name)) { session.setAttribute(name, sc.getAttribute(name));