List of usage examples for org.springframework.security.openid OpenIDAuthenticationToken getStatus
public OpenIDAuthenticationStatus getStatus()
From source file:net.firejack.platform.web.security.spring.openid.OpenIDAuthenticationManager.java
@Override protected Authentication doAuthentication(Authentication authentication) throws AuthenticationException { if (authentication instanceof OpenIDAuthenticationToken) { OpenIDAuthenticationToken token = (OpenIDAuthenticationToken) authentication; if (!OpenIDAuthenticationStatus.SUCCESS.equals(token.getStatus())) { String errorMessage = MessageResolver.messageFormatting("login.wrong.credentials", null); throw new BadCredentialsException(errorMessage); }// w w w .j av a 2 s. co m String email = findAttributeValueByName(SupportedOpenIDAttribute.EMAIL, token.getAttributes()); if (StringUtils.isBlank(email)) { String errorMessage = MessageResolver.messageFormatting("login.wrong.credentials", null); throw new BadCredentialsException(errorMessage); } HttpSession session = ((SessionContainerWebAuthenticationDetails) token.getDetails()).getSession(); if (authenticator != null) { AuthenticatorFactory authenticatorFactory = AuthenticatorFactory.getInstance(); Map<SupportedOpenIDAttribute, String> attributeValues = findAttributeValues(token.getAttributes()); OpenIDAuthenticationSource openIDAuthenticationSource = (OpenIDAuthenticationSource) authenticatorFactory .provideOpenIDAuthenticationSource(email, attributeValues); IAuthenticationDetails authenticationDetails = authenticator .authenticate(openIDAuthenticationSource); if (authenticationDetails != null) { return generateDefaultToken(authenticationDetails, session); } } } String errorMessage = MessageResolver.messageFormatting("login.authentication.failure", null); throw new BadCredentialsException(errorMessage); }