return new UserAuthentication(getAuthMethod(), user);
if (user!=null) return new UserAuthentication(getAuthMethod(),user);
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(String, Object, ServletRequest) */ @Override public Authentication login(String username, Object password, ServletRequest request) { if (username == null) return null; UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
if (user != null) return new UserAuthentication(getAuthMethod(), user);
if (user!=null) return new UserAuthentication(getAuthMethod(),user);
return new UserAuthentication(getAuthMethod(),user);
@Test public class UserAuthenticationTest { // Given UserAuthentication userAuthentication = new UserAuthentication(); AuthenticationWebService mockedAuthenticationWebService = mock(AuthenticationWebService.class) String username = "aUsername" , password = "aPassword"; when(mockedAuthenticationWebService.authenticate(username, password).thenReturn(true); // but you could return false here too if your test needed it userAuthentication.set(mockedAuthenticationWebService); // When boolean yourStubbedReturnValue = userAuthentication.authenticate(username, password); //Then verify(mockedAuthenticationWebService).authenticateUser(username, password); assertThat(yourStubbedReturnValue, is(true)); }
httpSession.setAttribute(UserIdentityHolder.ATTRIBUTE, new UserIdentityHolder(identity)); return new UserAuthentication(getAuthMethod(), identity); return new UserAuthentication(getAuthMethod(), identity);
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(java.lang.String, java.lang.String) */ public Authentication login(String username, Object password, ServletRequest request) { UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(java.lang.String, java.lang.String) */ public Authentication login(String username, Object password, ServletRequest request) { UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(java.lang.String, java.lang.String) */ @Override public Authentication login(String username, Object password, ServletRequest request) { UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(java.lang.String, java.lang.String) */ public Authentication login(String username, Object password, ServletRequest request) { UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(java.lang.String, java.lang.String) */ public Authentication login(String username, Object password, ServletRequest request) { UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(String, Object, ServletRequest) */ @Override public Authentication login(String username, Object password, ServletRequest request) { if (username == null) return null; UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(java.lang.String, java.lang.String) */ @Override public Authentication login(String username, Object password, ServletRequest request) { UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(String, Object, ServletRequest) */ @Override public Authentication login(String username, Object password, ServletRequest request) { if (username == null) return null; UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
/** * @see org.eclipse.jetty.server.Authentication.Deferred#login(String, Object, ServletRequest) */ @Override public Authentication login(String username, Object password, ServletRequest request) { if (username == null) return null; UserIdentity identity = _authenticator.login(username, password, request); if (identity != null) { IdentityService identity_service = _authenticator.getLoginService().getIdentityService(); UserAuthentication authentication = new UserAuthentication("API",identity); if (identity_service != null) _previousAssociation=identity_service.associate(identity); return authentication; } return null; }
return new UserAuthentication(getAuthMethod(),user);
return new UserAuthentication(getAuthMethod(),user);
/** * Certain aspects of the container, such as logging, need the authentication information to behave properly. * This method updates the request with the necessary objects to recognize the authenticated user. */ private void setJettyAuthentication(Subject subject) { // In unit test environments there may not be a current connection. If any nulls are encountered // then, by definition, there is no container to update. HttpConnection connection = HttpConnection.getCurrentConnection(); if (connection == null) { return; } Request jettyRequest = connection.getHttpChannel().getRequest(); if (jettyRequest == null) { return; } // This cast down is safe; subject is always created with this type of principal PrincipalWithRoles principal = (PrincipalWithRoles) subject.getPrincipal(); UserIdentity identity = principal.toUserIdentity(); jettyRequest.setAuthentication(new UserAuthentication(SecurityContext.BASIC_AUTH, identity)); } }