Java Code Examples for org.brickred.socialauth.Profile#getFullName()

The following examples show how to use org.brickred.socialauth.Profile#getFullName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuccessController.java    From socialauth with MIT License 6 votes vote down vote up
private ModelAndView registration(final AuthProvider provider)
		throws Exception {
	Profile profile = provider.getUserProfile();
	if (profile.getFullName() == null) {
		String name = null;
		if (profile.getFirstName() != null) {
			name = profile.getFirstName();
		}
		if (profile.getLastName() != null) {
			if (profile.getFirstName() != null) {
				name += " " + profile.getLastName();
			} else {
				name = profile.getLastName();
			}
		}
		if (name == null && profile.getDisplayName() != null) {
			name = profile.getDisplayName();
		}
		if (name != null) {
			profile.setFullName(name);
		}
	}
	ModelAndView view = new ModelAndView("registrationForm", "profile",
			profile);
	return view;
}
 
Example 2
Source File: GitHubProvider.java    From gocd-oauth-login with Apache License 2.0 5 votes vote down vote up
@Override
public User getUser(Profile profile) {
    String displayName = profile.getDisplayName();
    String fullName = profile.getFullName();
    String emailId = profile.getEmail();
    return new User(displayName, fullName, emailId);
}
 
Example 3
Source File: GitLabProvider.java    From gocd-oauth-login with Apache License 2.0 4 votes vote down vote up
@Override
public User getUser(Profile profile) {
    String fullName = profile.getFullName();
    String emailId = profile.getEmail();
    return new User(emailId, fullName, emailId);
}
 
Example 4
Source File: GoogleProvider.java    From gocd-oauth-login with Apache License 2.0 4 votes vote down vote up
@Override
public User getUser(Profile profile) {
    String emailId = profile.getEmail();
    String fullName = profile.getFullName();
    return new User(emailId, fullName, emailId);
}
 
Example 5
Source File: OpenIdImpl.java    From socialauth with MIT License 4 votes vote down vote up
/**
 * Verifies the user when the external provider redirects back to our
 * application.
 * 
 * 
 * @param requestParams
 *            request parameters, received from the provider
 * @return Profile object containing the profile information
 * @throws Exception
 */

@Override
public Profile verifyResponse(final Map<String, String> requestParams)
		throws Exception {
	if (!providerState) {
		throw new ProviderStateException();
	}
	try {
		// extract the parameters from the authentication response
		// (which comes in as a HTTP request from the OpenID provider)
		ParameterList response = new ParameterList(requestParams);

		// extract the receiving URL from the HTTP request
		StringBuffer receivingURL = new StringBuffer();
		receivingURL.append(successUrl);
		StringBuffer sb = new StringBuffer();
		for (Map.Entry<String, String> entry : requestParams.entrySet()) {
			String key = entry.getKey();
			String value = entry.getValue();
			if (sb.length() > 0) {
				sb.append("&");
			}
			sb.append(key).append("=").append(value);
		}
		receivingURL.append("?").append(sb.toString());

		// verify the response; ConsumerManager needs to be the same
		// (static) instance used to place the authentication request
		VerificationResult verification = manager.verify(
				receivingURL.toString(), response, discovered);

		// examine the verification result and extract the verified
		// identifier
		Identifier verified = verification.getVerifiedId();
		if (verified != null) {
			LOG.debug("Verified Id : " + verified.getIdentifier());
			Profile p = new Profile();
			p.setValidatedId(verified.getIdentifier());
			AuthSuccess authSuccess = (AuthSuccess) verification
					.getAuthResponse();

			if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
				FetchResponse fetchResp = (FetchResponse) authSuccess
						.getExtension(AxMessage.OPENID_NS_AX);

				p.setEmail(fetchResp.getAttributeValue("email"));
				p.setFirstName(fetchResp.getAttributeValue("firstname"));
				p.setLastName(fetchResp.getAttributeValue("lastname"));
				p.setFullName(fetchResp.getAttributeValue("fullname"));

				// also use the ax namespace for compatibility
				if (p.getEmail() == null) {
					p.setEmail(fetchResp.getAttributeValue("emailax"));
				}
				if (p.getFirstName() == null) {
					p.setFirstName(fetchResp
							.getAttributeValue("firstnameax"));
				}
				if (p.getLastName() == null) {
					p.setLastName(fetchResp.getAttributeValue("lastnameax"));
				}
				if (p.getFullName() == null) {
					p.setFullName(fetchResp.getAttributeValue("fullnameax"));
				}

			}
			userProfile = p;
			return p;
		}
	} catch (OpenIDException e) {
		throw e;
	}

	return null;
}