private String getCookieAuthData(final Credentials credentials) { if (credentials instanceof SimpleCredentials) { Object data = ((SimpleCredentials) credentials).getAttribute(attrCookieAuthData); if (data instanceof String) { return (String) data; } } // no SimpleCredentials or no valid attribute return null; }
/** * 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 LdapUser getLdapAuthData(final Credentials credentials) { if (credentials instanceof SimpleCredentials) { Object data = ((SimpleCredentials) credentials).getAttribute(attrLdapId); if (data instanceof LdapUser) { return (LdapUser) data; } } // no SimpleCredentials or no valid attribute return null; }
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; }
/** * @param name * @return */ public Object getAttribute(String name) { return simpleCredentials.getAttribute(name); }
/** * 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; }
public Object getAttribute(String name) { return registrySimpleCredentials.getAttribute(name); }
@Nullable @Override public Object apply(String input) { return sc.getAttribute(input); } });
@Nullable @Override public Object apply(String input) { return sc.getAttribute(input); } });
/** * Returns <code>true</code> if the specified <code>credentials</code> * should be used to create a new login token. * * @param credentials * @return <code>true</code> if upon successful authentication a new * login token should be created; <code>false</code> otherwise. */ public static boolean doCreateToken(Credentials credentials) { if (credentials instanceof SimpleCredentials) { Object attr = ((SimpleCredentials) credentials).getAttribute(TOKEN_ATTRIBUTE); return (attr != null && "".equals(attr.toString())); } return false; }
/** * Returns <code>true</code> if the specified <code>credentials</code> * should be used to create a new login token. * * @param credentials * @return <code>true</code> if upon successful authentication a new * login token should be created; <code>false</code> otherwise. */ public static boolean doCreateToken(Credentials credentials) { if (credentials instanceof SimpleCredentials) { Object attr = ((SimpleCredentials) credentials).getAttribute(TOKEN_ATTRIBUTE); return (attr != null && "".equals(attr.toString())); } return false; }
public boolean canHandle(Credentials credentials) { if(credentials != null && credentials instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials)credentials; OpenIdUser user = (OpenIdUser)sc.getAttribute(getClass().getName()); if(user != null) { return user.isAssociated(); } } return false; }
public Principal getPrincipal(Credentials credentials) { if(credentials != null && credentials instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials)credentials; OpenIdUser user = (OpenIdUser)sc.getAttribute(getClass().getName()); if(user != null) { return new OpenIDPrincipal(user); } } return null; }
@Override protected boolean isPreAuthenticated( final Credentials creds ) { if ( super.isPreAuthenticated( creds ) ) { SimpleCredentials simpleCreds = (SimpleCredentials) creds; String preAuth = (String) simpleCreds.getAttribute( getPreAuthAttributeName() ); boolean preAuthenticated = preAuthenticationTokens.contains( preAuth ); if ( preAuthenticated ) { if ( logger.isDebugEnabled() ) { logger.debug( simpleCreds.getUserID() + " is pre-authenticated" ); //$NON-NLS-1$ } } else { if ( logger.isDebugEnabled() ) { logger.debug( "pre-authentication token rejected" ); //$NON-NLS-1$ } } return preAuthenticated; } return false; }
public boolean authenticate(Credentials credentials) throws RepositoryException { if(credentials instanceof SimpleCredentials) { OpenIdUser user = (OpenIdUser)((SimpleCredentials)credentials) .getAttribute(OpenIDAuthenticationHandler.class.getName()); if(user != null) { return principal.getName().equals( OpenIDUserUtil.getPrincipalName( user.getIdentity())) && user.isAuthenticated(); } } throw new RepositoryException("Can't authenticate credentials of type: " + credentials.getClass()); }
private static Long getRefreshInterval(Credentials credentials) { if (credentials instanceof SimpleCredentials) { Object value = ((SimpleCredentials) credentials).getAttribute(REFRESH_INTERVAL); return toLong(value); } else if (credentials instanceof TokenCredentials) { String value = ((TokenCredentials) credentials).getAttribute(REFRESH_INTERVAL); if (value != null) { return toLong(value); } } return null; }
private static Long getRefreshInterval(Credentials credentials) { if (credentials instanceof SimpleCredentials) { Object value = ((SimpleCredentials) credentials).getAttribute(REFRESH_INTERVAL); return toLong(value); } else if (credentials instanceof TokenCredentials) { String value = ((TokenCredentials) credentials).getAttribute(REFRESH_INTERVAL); if (value != null) { return toLong(value); } } return null; }
private static Long getRefreshInterval(Credentials credentials) { if (credentials instanceof SimpleCredentials) { Object value = ((SimpleCredentials) credentials).getAttribute(REFRESH_INTERVAL); return toLong(value); } else if (credentials instanceof TokenCredentials) { String value = ((TokenCredentials) credentials).getAttribute(REFRESH_INTERVAL); if (value != null) { return toLong(value); } } return null; }
@Test public void testSetAttributes() { Map<String, ?> attributes = credentialsSupport.getAttributes(new TestCredentials()); assertNotNull(attributes); assertTrue(attributes.isEmpty()); SimpleCredentials sc = new SimpleCredentials("uid", new char[0]); Map<String, ?> expected = ImmutableMap.of("a", "a", "b", Boolean.TRUE, "c", new TestCredentials()); credentialsSupport.setAttributes(sc, expected); for (Map.Entry<String, ?> entry : expected.entrySet()) { assertEquals(entry.getValue(), sc.getAttribute(entry.getKey())); } attributes = credentialsSupport.getAttributes(sc); assertNotNull(attributes); assertEquals(3, attributes.size()); assertEquals(expected, attributes); }
@Test public void testSimpleCredentials() throws Exception { SimpleCredentials credentials = (SimpleCredentials) getAdminCredentials(); credentials.setAttribute(TokenConstants.TOKEN_ATTRIBUTE, ""); ContentSession cs = null; try { cs = login(credentials); assertEquals(credentials.getUserID(), cs.getAuthInfo().getUserID()); String token = credentials.getAttribute(TokenConstants.TOKEN_ATTRIBUTE).toString(); assertFalse(token.isEmpty()); cs.close(); } finally { if (cs != null) { cs.close(); } } } }