@Override public String getUserIdentifier() { return getLogin(); }
@SuppressWarnings("RedundantThrows") protected boolean authenticateInLdap(LoginPasswordCredentials credentials) throws LoginException { String login = credentials.getLogin(); String password = credentials.getPassword(); return ldapTemplate.authenticate(LdapUtils.emptyLdapName(), buildPersonFilter(login), password); }
LoginPasswordCredentials loginPassword = (LoginPasswordCredentials) credentials; if (webAuthConfig.getStandardAuthenticationUsers().contains(loginPassword.getLogin())) { log.debug("User {} is not allowed to use external login"); return null; authProvider.authenticate(loginPassword.getLogin(), loginPassword.getPassword(), loginPassword.getLocale()); String systemLogin = convertLoginString(loginPassword.getLogin());
LoginPasswordCredentials loginPasswordCredentials = (LoginPasswordCredentials) credentials; if (webAuthConfig.getStandardAuthenticationUsers().contains(loginPasswordCredentials.getLogin())) { log.debug("User {} is not allowed to use external login"); return null; locale, loginPasswordCredentials.getLogin()) ); loginPasswordCredentials.getLogin(), webAuthConfig.getTrustedClientPassword(), loginPasswordCredentials.getLocale(),
protected TrustedClientCredentials createTrustedCredentials(LoginPasswordCredentials credentials) { TrustedClientCredentials tcCredentials = new TrustedClientCredentials( credentials.getLogin(), webAuthConfig.getTrustedClientPassword(), credentials.getLocale(), credentials.getParams() ); tcCredentials.setClientInfo(credentials.getClientInfo()); tcCredentials.setClientType(ClientType.WEB); tcCredentials.setIpAddress(credentials.getIpAddress()); tcCredentials.setOverrideLocale(credentials.isOverrideLocale()); tcCredentials.setSyncNewUserSessionReplication(credentials.isSyncNewUserSessionReplication()); tcCredentials.setSessionAttributes(credentials.getSessionAttributes()); return tcCredentials; }
protected AuthenticationDetails loginClient(LoginPasswordCredentials credentials) { String login = credentials.getLogin(); Locale credentialsLocale = credentials.getLocale() == null ? messages.getTools().getDefaultLocale() : credentials.getLocale(); if (Strings.isNullOrEmpty(login)) { // empty login is not valid throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } UserSession systemSession = trustedClientService.getSystemSession(portalConfig.getTrustedClientPassword()); User user = AppContext.withSecurityContext(new SecurityContext(systemSession), () -> usersRepository.findUserByLogin(login)); if (user == null) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } if (!passwordEncryption.checkPassword(user, credentials.getPassword())) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } return authenticationService.login(createTrustedCredentials(credentials)); }
protected AuthenticationDetails loginClient(LoginPasswordCredentials credentials) { String login = credentials.getLogin(); Locale credentialsLocale = credentials.getLocale() == null ? messages.getTools().getDefaultLocale() : credentials.getLocale(); if (Strings.isNullOrEmpty(login)) { // empty login is not valid throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } UserSession systemSession = trustedClientService.getSystemSession(restApiConfig.getTrustedClientPassword()); User user = AppContext.withSecurityContext(new SecurityContext(systemSession), () -> usersRepository.findUserByLogin(login)); if (user == null) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } if (!passwordEncryption.checkPassword(user, credentials.getPassword())) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } return authenticationService.login(createTrustedCredentials(credentials)); }
protected AuthenticationDetails loginClient(LoginPasswordCredentials credentials) { String login = credentials.getLogin(); Locale credentialsLocale = credentials.getLocale() == null ? messages.getTools().getDefaultLocale() : credentials.getLocale(); if (Strings.isNullOrEmpty(login)) { // empty login is not valid throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } UserSession systemSession = trustedClientService.getSystemSession(webAuthConfig.getTrustedClientPassword()); User user = AppContext.withSecurityContext(new SecurityContext(systemSession), () -> usersRepository.findUserByLogin(login)); if (user == null) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } if (!passwordEncryption.checkPassword(user, credentials.getPassword())) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } return authenticationService.login(createTrustedCredentials(credentials)); }
protected TrustedClientCredentials createTrustedCredentials(LoginPasswordCredentials credentials) { TrustedClientCredentials tcCredentials = new TrustedClientCredentials( credentials.getLogin(), portalConfig.getTrustedClientPassword(), credentials.getLocale(), credentials.getParams() ); tcCredentials.setClientInfo(credentials.getClientInfo()); tcCredentials.setClientType(ClientType.PORTAL); tcCredentials.setIpAddress(credentials.getIpAddress()); tcCredentials.setOverrideLocale(credentials.isOverrideLocale()); tcCredentials.setSyncNewUserSessionReplication(credentials.isSyncNewUserSessionReplication()); tcCredentials.setSessionAttributes(credentials.getSessionAttributes()); return tcCredentials; }
protected TrustedClientCredentials createTrustedCredentials(LoginPasswordCredentials credentials) { TrustedClientCredentials tcCredentials = new TrustedClientCredentials( credentials.getLogin(), restApiConfig.getTrustedClientPassword(), credentials.getLocale(), credentials.getParams() ); tcCredentials.setClientInfo(credentials.getClientInfo()); tcCredentials.setClientType(ClientType.REST_API); tcCredentials.setIpAddress(credentials.getIpAddress()); tcCredentials.setOverrideLocale(credentials.isOverrideLocale()); tcCredentials.setSyncNewUserSessionReplication(credentials.isSyncNewUserSessionReplication()); tcCredentials.setSessionAttributes(credentials.getSessionAttributes()); return tcCredentials; }
@Override public AuthenticationDetails authenticate(Credentials credentials) throws LoginException { LoginPasswordCredentials loginAndPassword = (LoginPasswordCredentials) credentials; String login = loginAndPassword.getLogin(); Locale credentialsLocale = loginAndPassword.getLocale() == null ? messages.getTools().getDefaultLocale() : loginAndPassword.getLocale(); if (Strings.isNullOrEmpty(login)) { // empty login is not valid throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } checkUserCredentials(credentials); User user = loadUser(login); if (user == null) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } if (!passwordEncryption.checkPassword(user, loginAndPassword.getPassword())) { throw new LoginException(getInvalidCredentialsMessage(login, credentialsLocale)); } Locale userLocale = getUserLocale(loginAndPassword, user); UserSession session = createSession(loginAndPassword, user, userLocale); setClientSessionParams(loginAndPassword, session); AuthenticationDetails authenticationDetails = new SimpleAuthenticationDetails(session); checkUserAccess(loginAndPassword, authenticationDetails); return authenticationDetails; }