String fullName = null; List<OpenIDAttribute> attributes = token.getAttributes();
/** * Handles the creation of the final <tt>Authentication</tt> object which will be * returned by the provider. * <p> * The default implementation just creates a new OpenIDAuthenticationToken from the * original, but with the UserDetails as the principal and including the authorities * loaded by the UserDetailsService. * * @param userDetails the loaded UserDetails object * @param auth the token passed to the authenticate method, containing * @return the token which will represent the authenticated user. */ protected Authentication createSuccessfulAuthentication(UserDetails userDetails, OpenIDAuthenticationToken auth) { return new OpenIDAuthenticationToken(userDetails, this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()), auth.getIdentityUrl(), auth.getAttributes()); }
public Builder withAuthenticationToken(OpenIDAuthenticationToken token) { this.username = token.getIdentityUrl(); for (OpenIDAttribute attribute : token.getAttributes()) { if (attribute.getName().equals("email")) { this.email = attribute.getValues().get(0); } if (attribute.getName().equals("firstname")) { this.firstname = attribute.getValues().get(0); } if (attribute.getName().equals("lastname")) { this.lastname = attribute.getValues().get(0); } if (attribute.getName().equals("fullname")) { this.fullname = attribute.getValues().get(0); } } return this; }
OpenIDAuthenticationToken newAuthentication = new OpenIDAuthenticationToken(userDetails, userDetails.getAuthorities(), openidAuthenticationToken.getIdentityUrl(), openidAuthenticationToken.getAttributes());
@Override public UserDetails loadUserDetails(OpenIDAuthenticationToken token) { MotechUser user = allMotechUsers.findUserByOpenId(token.getName()); if (user == null) { List<String> roles = new ArrayList<String>(); if (allMotechUsers.getOpenIdUsers().isEmpty()) { for (MotechRole role : allMotechRoles.getRoles()) { roles.add(role.getRoleName()); } } user = new MotechUser(getAttribute(token.getAttributes(), "Email"), "", getAttribute(token.getAttributes(), "Email"), "", roles, token.getName(), Locale.getDefault()); allMotechUsers.addOpenIdUser(user); } return new User(user.getUserName(), user.getPassword(), user.isActive(), true, true, true, authoritiesService.authoritiesFor(user)); }
/** * Handles the creation of the final <tt>Authentication</tt> object which will be * returned by the provider. * <p> * The default implementation just creates a new OpenIDAuthenticationToken from the * original, but with the UserDetails as the principal and including the authorities * loaded by the UserDetailsService. * * @param userDetails the loaded UserDetails object * @param auth the token passed to the authenticate method, containing * @return the token which will represent the authenticated user. */ protected Authentication createSuccessfulAuthentication(UserDetails userDetails, OpenIDAuthenticationToken auth) { return new OpenIDAuthenticationToken(userDetails, this.authoritiesMapper.mapAuthorities(userDetails.getAuthorities()), auth.getIdentityUrl(), auth.getAttributes()); }
private AbstractAuthenticationToken getToken(Authentication authentication, MotechUser user) { AbstractAuthenticationToken token = null; if (authentication instanceof UsernamePasswordAuthenticationToken) { UsernamePasswordAuthenticationToken oldToken = (UsernamePasswordAuthenticationToken) authentication; token = new UsernamePasswordAuthenticationToken(oldToken.getPrincipal(), oldToken.getCredentials(), authoritiesService.authoritiesFor(user)); } else if (authentication instanceof OpenIDAuthenticationToken) { OpenIDAuthenticationToken oldToken = (OpenIDAuthenticationToken) authentication; token = new OpenIDAuthenticationToken(oldToken.getPrincipal(), authoritiesService.authoritiesFor(user), user.getOpenId(), oldToken.getAttributes()); } return token; }
private User createTemporaryUser(OpenIDAuthenticationToken token, final String openId) { final List<OpenIDAttribute> attributes = token.getAttributes(); String email = null; String firstName = null;
List<OpenIDAttribute> attributes = token.getAttributes();
List<OpenIDAttribute> attributes = token.getAttributes();
List<OpenIDAttribute> attributes = token.getAttributes();