@Test public void testSimpleCredentialsWithAttribute() throws Exception { ContentSession cs = null; try { SimpleCredentials sc = new SimpleCredentials("test", new char[0]); sc.setAttribute(".token", ""); cs = login(sc); fail("Unsupported credentials login should fail"); } catch (LoginException e) { } finally { if (cs != null) { cs.close(); } } }
@Override public boolean login() throws LoginException { tokenProvider = getTokenProvider(); if (tokenProvider == null) { return false; } Credentials credentials = getCredentials(); if (credentials instanceof TokenCredentials) { TokenCredentials tc = (TokenCredentials) credentials; TokenAuthentication authentication = new TokenAuthentication(tokenProvider); if (authentication.authenticate(tc)) { tokenCredentials = tc; tokenInfo = authentication.getTokenInfo(); principal = authentication.getUserPrincipal(); log.debug("Login: adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, tokenInfo.getUserId()); return true; } } return false; }
TokenLoginModule extends AbstractLoginModule { @Override public boolean login() throws LoginException { tokenProvider = getTokenProvider(); if (tokenProvider == null) { return false; } Credentials credentials = getCredentials(); if (credentials instanceof TokenCredentials) { TokenCredentials tc = (TokenCredentials) credentials; TokenAuthentication authentication = new TokenAuthentication(tokenProvider); if (authentication.authenticate(tc)) { tokenCredentials = tc; tokenInfo = authentication.getTokenInfo(); principal = authentication.getUserPrincipal(); log.debug("Login: adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, tokenInfo.getUserId()); return true; } } return false; } }
TokenLoginModule extends AbstractLoginModule { @Override public boolean login() throws LoginException { tokenProvider = getTokenProvider(); if (tokenProvider == null) { return false; } Credentials credentials = getCredentials(); if (credentials instanceof TokenCredentials) { TokenCredentials tc = (TokenCredentials) credentials; TokenAuthentication authentication = new TokenAuthentication(tokenProvider); if (authentication.authenticate(tc)) { tokenCredentials = tc; tokenInfo = authentication.getTokenInfo(); principal = authentication.getUserPrincipal(); log.debug("Login: adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, tokenInfo.getUserId()); return true; } } return false; }  }
TokenLoginModule extends AbstractLoginModule { @Override public boolean login() throws LoginException { tokenProvider = getTokenProvider(); if (tokenProvider == null) { return false; } Credentials credentials = getCredentials(); if (credentials instanceof TokenCredentials) { TokenCredentials tc = (TokenCredentials) credentials; TokenAuthentication authentication = new TokenAuthentication(tokenProvider); if (authentication.authenticate(tc)) { tokenCredentials = tc; tokenInfo = authentication.getTokenInfo(); principal = authentication.getUserPrincipal(); log.debug("Login: adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, tokenInfo.getUserId()); return true; } } return false; }  @Override boolean login(); @Override boolean commit(); @Override boolean logout(); }
TokenLoginModule extends AbstractLoginModule { @Override public boolean login() throws LoginException { tokenProvider = getTokenProvider(); if (tokenProvider == null) { return false; } Credentials credentials = getCredentials(); if (credentials instanceof TokenCredentials) { TokenCredentials tc = (TokenCredentials) credentials; TokenAuthentication authentication = new TokenAuthentication(tokenProvider); if (authentication.authenticate(tc)) { tokenCredentials = tc; tokenInfo = authentication.getTokenInfo(); principal = authentication.getUserPrincipal(); log.debug("Login: adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, tokenInfo.getUserId()); return true; } } return false; }  @Override boolean login(); @Override boolean commit(); @Override boolean logout();  }