samples/xml/openid/src/main/java/org/springframework/security/samples/openid/CustomUserDetailsService.java
public UserDetails loadUserDetails(OpenIDAuthenticationToken token) {
		String id = token.getIdentityUrl();

		CustomUserDetails user = registeredUsers.get(id);

		if (user != null) {
			return user;
		}

		String email = null;
		String firstName = null;
		String lastName = null;
		String fullName = null;

		List<OpenIDAttribute> attributes = token.getAttributes();

		for (OpenIDAttribute attribute : attributes) {
			if (attribute.getName().equals("email")) {
				email = attribute.getValues().get(0);
			}

			if (attribute.getName().equals("firstname")) {
				firstName = attribute.getValues().get(0);
			}

			if (attribute.getName().equals("lastname")) {
				lastName = attribute.getValues().get(0);
			}

			if (attribute.getName().equals("fullname")) {
				fullName = attribute.getValues().get(0);
			}
		}

		if (fullName == null) {
			StringBuilder fullNameBldr = new StringBuilder();

			if (firstName != null) {
				fullNameBldr.append(firstName);
			}

			if (lastName != null) {
				fullNameBldr.append(" ").append(lastName);
			}
			fullName = fullNameBldr.toString();
		}

		user = new CustomUserDetails(id, DEFAULT_AUTHORITIES);
		user.setEmail(email);
		user.setName(fullName);

		registeredUsers.put(id, user);

		user = new CustomUserDetails(id, DEFAULT_AUTHORITIES);
		user.setEmail(email);
		user.setName(fullName);
		user.setNewUser(true);

		return user;
	}
public UserDetails loadUserDetails(OpenIDAuthenticationToken token) {
		String id = token.getIdentityUrl();

		CustomUserDetails user = registeredUsers.get(id);

		if (user != null) {
			return user;
		}

		String email = null;
		String firstName = null;
		String lastName = null;
		String fullName = null;

		List<OpenIDAttribute> attributes = token.getAttributes();

		for (OpenIDAttribute attribute : attributes) {
			if (attribute.getName().equals("email")) {
				email = attribute.getValues().get(0);
			}

			if (attribute.getName().equals("firstname")) {
				firstName = attribute.getValues().get(0);
			}

			if (attribute.getName().equals("lastname")) {
				lastName = attribute.getValues().get(0);
			}

			if (attribute.getName().equals("fullname")) {
				fullName = attribute.getValues().get(0);
			}
		}

		if (fullName == null) {
			StringBuilder fullNameBldr = new StringBuilder();

			if (firstName != null) {
				fullNameBldr.append(firstName);
			}

			if (lastName != null) {
				fullNameBldr.append(" ").append(lastName);
			}
			fullName = fullNameBldr.toString();
		}

		user = new CustomUserDetails(id, DEFAULT_AUTHORITIES);
		user.setEmail(email);
		user.setName(fullName);

		registeredUsers.put(id, user);

		user = new CustomUserDetails(id, DEFAULT_AUTHORITIES);
		user.setEmail(email);
		user.setName(fullName);
		user.setNewUser(true);

		return user;
	}
public UserDetails loadUserDetails ( OpenIDAuthenticationToken token ) { String id = token . getIdentityUrl ( ) ; CustomUserDetails user = registeredUsers . get ( id ) ; if ( user != null ) { return user ; } String email = null ; String firstName = null ; String lastName = null ; String fullName = null ; List < OpenIDAttribute > attributes = token . getAttributes ( ) ; for ( OpenIDAttribute attribute : attributes ) { if ( attribute . getName ( ) . equals ( "email" ) ) { email = attribute . getValues ( ) . get ( 0 ) ; } if ( attribute . getName ( ) . equals ( "firstname" ) ) { firstName = attribute . getValues ( ) . get ( 0 ) ; } if ( attribute . getName ( ) . equals ( "lastname" ) ) { lastName = attribute . getValues ( ) . get ( 0 ) ; } if ( attribute . getName ( ) . equals ( "fullname" ) ) { fullName = attribute . getValues ( ) . get ( 0 ) ; } } if ( fullName == null ) { StringBuilder fullNameBldr = new StringBuilder ( ) ; if ( firstName != null ) { fullNameBldr . append ( firstName ) ; } if ( lastName != null ) { fullNameBldr . append ( " " ) . append ( lastName ) ; } fullName = fullNameBldr . toString ( ) ; } user = new CustomUserDetails ( id , DEFAULT_AUTHORITIES ) ; user . setEmail ( email ) ; user . setName ( fullName ) ; registeredUsers . put ( id , user ) ; user = new CustomUserDetails ( id , DEFAULT_AUTHORITIES ) ; user . setEmail ( email ) ; user . setName ( fullName ) ; user . setNewUser ( true ) ; return user ; }
Implementation of {@code AuthenticationUserDetailsService} which allows full access
to the submitted {@code Authentication} object. Used by the
OpenIDAuthenticationProvider.
Implementation of {