@Test(expected = LoginException.class) public void testImpersonationWithUnsupportedBaseCredentials() throws Exception { Credentials baseCredentials = mock(Credentials.class); ImpersonationCredentials ic = new ImpersonationCredentials(baseCredentials, new AuthInfoImpl(USER_ID, null, null)); try (ContentSession cs = login(ic)) { fail("Base credentials of ImpersonationCredentials can only be SimpleCredentials."); } }
@Override public boolean login() throws LoginException { credentials = getCredentials(); PreAuthenticatedLogin preAuthLogin = getSharedPreAuthLogin(); String loginName = getLoginId(preAuthLogin); Authentication authentication = getUserAuthentication(loginName); if (authentication != null) { if (preAuthLogin != null) { success = authentication.authenticate(PreAuthenticatedLogin.PRE_AUTHENTICATED); } else { success = authentication.authenticate(credentials); } if (success) { log.debug("Adding Credentials to shared state."); sharedState.put(SHARED_KEY_CREDENTIALS, credentials); log.debug("Adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, loginName); userId = authentication.getUserId(); if (userId == null) { userId = loginName; } principal = authentication.getUserPrincipal(); } } else { credentials = null; userId = null; } return success; }
LoginModuleImpl extends AbstractLoginModule { @Override public boolean login() throws LoginException { credentials = getCredentials(); PreAuthenticatedLogin preAuthLogin = getSharedPreAuthLogin(); String loginName = getLoginId(preAuthLogin); Authentication authentication = getUserAuthentication(loginName); if (authentication != null) { if (preAuthLogin != null) { success = authentication.authenticate(PreAuthenticatedLogin.PRE_AUTHENTICATED); } else { success = authentication.authenticate(credentials); } if (success) { log.debug("Adding Credentials to shared state."); sharedState.put(SHARED_KEY_CREDENTIALS, credentials); log.debug("Adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, loginName); userId = authentication.getUserId(); if (userId == null) { userId = loginName; } principal = authentication.getUserPrincipal(); } } else { credentials = null; userId = null; } return success; } }
LoginModuleImpl extends AbstractLoginModule { @Override public boolean login() throws LoginException { credentials = getCredentials(); PreAuthenticatedLogin preAuthLogin = getSharedPreAuthLogin(); String loginName = getLoginId(preAuthLogin); Authentication authentication = getUserAuthentication(loginName); if (authentication != null) { if (preAuthLogin != null) { success = authentication.authenticate(PreAuthenticatedLogin.PRE_AUTHENTICATED); } else { success = authentication.authenticate(credentials); } if (success) { log.debug("Adding Credentials to shared state."); sharedState.put(SHARED_KEY_CREDENTIALS, credentials); log.debug("Adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, loginName); userId = authentication.getUserId(); if (userId == null) { userId = loginName; } principal = authentication.getUserPrincipal(); } } else { credentials = null; userId = null; } return success; }  }
LoginModuleImpl extends AbstractLoginModule { @Override public boolean login() throws LoginException { credentials = getCredentials(); PreAuthenticatedLogin preAuthLogin = getSharedPreAuthLogin(); String loginName = getLoginId(preAuthLogin); Authentication authentication = getUserAuthentication(loginName); if (authentication != null) { if (preAuthLogin != null) { success = authentication.authenticate(PreAuthenticatedLogin.PRE_AUTHENTICATED); } else { success = authentication.authenticate(credentials); } if (success) { log.debug("Adding Credentials to shared state."); sharedState.put(SHARED_KEY_CREDENTIALS, credentials); log.debug("Adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, loginName); userId = authentication.getUserId(); if (userId == null) { userId = loginName; } principal = authentication.getUserPrincipal(); } } else { credentials = null; userId = null; } return success; }  @Override boolean login(); @Override boolean commit(); @Override boolean logout(); }
LoginModuleImpl extends AbstractLoginModule { @Override public boolean login() throws LoginException { credentials = getCredentials(); PreAuthenticatedLogin preAuthLogin = getSharedPreAuthLogin(); String loginName = getLoginId(preAuthLogin); Authentication authentication = getUserAuthentication(loginName); if (authentication != null) { if (preAuthLogin != null) { success = authentication.authenticate(PreAuthenticatedLogin.PRE_AUTHENTICATED); } else { success = authentication.authenticate(credentials); } if (success) { log.debug("Adding Credentials to shared state."); sharedState.put(SHARED_KEY_CREDENTIALS, credentials); log.debug("Adding login name to shared state."); sharedState.put(SHARED_KEY_LOGIN_NAME, loginName); userId = authentication.getUserId(); if (userId == null) { userId = loginName; } principal = authentication.getUserPrincipal(); } } else { credentials = null; userId = null; } return success; }  @Override boolean login(); @Override boolean commit(); @Override boolean logout();  }