org.brickred.socialauth.Profile Java Examples

The following examples show how to use org.brickred.socialauth.Profile. 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: FacebookImpl.java    From socialauth with MIT License 6 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Retrieving Access Token in verify response function");
	if (requestParams.get("error_reason") != null
			&& "user_denied".equals(requestParams.get("error_reason"))) {
		throw new UserDeniedPermissionException();
	}
	accessGrant = authenticationStrategy.verifyResponse(requestParams);

	if (accessGrant != null) {
		LOG.debug("Obtaining user profile");
		return authFacebookLogin();
	} else {
		throw new SocialAuthException("Access token not found");
	}
}
 
Example #2
Source File: GooglePlusImpl.java    From socialauth with MIT License 6 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Retrieving Access Token in verify response function");
	if (requestParams.get("error_reason") != null
			&& "user_denied".equals(requestParams.get("error_reason"))) {
		throw new UserDeniedPermissionException();
	}
	accessGrant = authenticationStrategy.verifyResponse(requestParams,
			MethodType.POST.toString());

	if (accessGrant != null) {
		LOG.debug("Obtaining user profile");
		return getProfile();
	} else {
		throw new SocialAuthException("Access token not found");
	}
}
 
Example #3
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 #4
Source File: GenericOAuth2Provider.java    From socialauth with MIT License 6 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Retrieving Access Token in verify response function");
	if (requestParams.get("error_reason") != null
			&& "user_denied".equals(requestParams.get("error_reason"))) {
		throw new UserDeniedPermissionException();
	}
	accessGrant = authenticationStrategy.verifyResponse(requestParams);

	if (accessGrant != null) {
		LOG.debug("Access grant available");
		return null;
	} else {
		throw new SocialAuthException("Access token not found");
	}
}
 
Example #5
Source File: NimbleImpl.java    From socialauth with MIT License 6 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Retrieving Access Token in verify response function");
	if (requestParams.get("error") != null
			&& "access_denied".equals(requestParams.get("error"))) {
		throw new UserDeniedPermissionException();
	}
	accessGrant = authenticationStrategy.verifyResponse(requestParams,
			MethodType.POST.toString());

	if (accessGrant != null) {
		LOG.debug("Obtaining user profile");
		return null;
	} else {
		throw new SocialAuthException("Access token not found");
	}
}
 
Example #6
Source File: RunkeeperImpl.java    From socialauth with MIT License 6 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Retrieving Access Token in verify response function");
	if (requestParams.get("error") != null
			&& "access_denied".equals(requestParams.get("error"))) {
		throw new UserDeniedPermissionException();
	}
	accessGrant = authenticationStrategy.verifyResponse(requestParams,
			MethodType.POST.toString());

	if (accessGrant != null) {
		LOG.debug("Obtaining user profile");
		return getProfile();
	} else {
		throw new SocialAuthException("Access token not found");
	}
}
 
Example #7
Source File: GoogleImpl.java    From socialauth with MIT License 6 votes vote down vote up
/**
 * Retrieves the user profile.
 * 
 * @return Profile object containing the profile information.
 */
@Override
public Profile getUserProfile() {
	if (userProfile == null && accessToken != null) {
		Map<String, String> map = new HashMap<String, String>();
		for (Map.Entry<String, Object> entry : accessToken.getAttributes()
				.entrySet()) {
			String key = entry.getKey();
			String value = entry.getValue().toString();
			map.put(key, value);
		}
		if (!map.isEmpty()) {
			getProfile(map);
		}
	}
	return userProfile;
}
 
Example #8
Source File: InstagramImpl.java    From socialauth with MIT License 6 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Verifying the authentication response from provider");
	if (requestParams.get("error") != null
			&& "access_denied".equals(requestParams.get("error"))) {
		throw new UserDeniedPermissionException();
	}

	accessGrant = authenticationStrategy.verifyResponse(requestParams,
			MethodType.POST.toString());
	if (accessGrant != null) {
		LOG.debug("Obtaining user profile");
		getUserProfile();
		return this.userProfile;
	} else {
		throw new SocialAuthException("Access token not found");
	}
}
 
Example #9
Source File: SalesForceImpl.java    From socialauth with MIT License 6 votes vote down vote up
/**
 * @param requestParams
 * @return
 * @throws Exception
 */
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Retrieving Access Token in verify response function");
	if (requestParams.get("error") != null
			&& "access_denied".equals(requestParams.get("error"))) {
		throw new UserDeniedPermissionException();
	}
	accessGrant = authenticationStrategy.verifyResponse(requestParams,
			MethodType.POST.toString());

	if (accessGrant != null) {
		LOG.debug("Obtaining user profile");
		return getProfile();
	} else {
		throw new SocialAuthException("Access token not found");
	}

}
 
Example #10
Source File: GitHubImpl.java    From socialauth with MIT License 6 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Retrieving Access Token in verify response function");
	if (requestParams.get("error_reason") != null
			&& "user_denied".equals(requestParams.get("error_reason"))) {
		throw new UserDeniedPermissionException();
	}
	accessGrant = authenticationStrategy.verifyResponse(requestParams,
			MethodType.POST.toString());

	if (accessGrant != null) {
		LOG.debug("Obtaining user profile");
		return getProfile();
	} else {
		throw new SocialAuthException("Access token not found");
	}
}
 
Example #11
Source File: FourSquareImpl.java    From socialauth with MIT License 6 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Verifying the authentication response from provider");
	if (requestParams.get("error") != null
			&& "access_denied".equals(requestParams.get("error"))) {
		throw new UserDeniedPermissionException();
	}

	accessGrant = authenticationStrategy.verifyResponse(requestParams);
	if (accessGrant != null) {
		accessToken = accessGrant.getKey();
		LOG.debug("Obtaining user profile");
		return getProfile();
	} else {
		throw new SocialAuthException("Access token not found");
	}
}
 
Example #12
Source File: FacebookImpl.java    From socialauth with MIT License 5 votes vote down vote up
/**
 * Retrieves the user profile.
 *
 * @return Profile object containing the profile information.
 */
@Override
public Profile getUserProfile() throws Exception {
	if (userProfile == null && accessGrant != null) {
		authFacebookLogin();
	}
	return userProfile;
}
 
Example #13
Source File: HotmailImpl.java    From socialauth with MIT License 5 votes vote down vote up
/**
 * Retrieves the user profile.
 * 
 * @return Profile object containing the profile information.
 */
@Override
public Profile getUserProfile() throws Exception {
	if (userProfile == null && accessGrant != null) {
		getProfile();
	}
	return userProfile;
}
 
Example #14
Source File: MendeleyImpl.java    From socialauth with MIT License 5 votes vote down vote up
/**
 * Retrieves the user profile.
 * 
 * @return Profile object containing the profile information.
 */
@Override
public Profile getUserProfile() throws Exception {
	if (userProfile == null && accessToken != null) {
		getProfile();
	}
	return userProfile;
}
 
Example #15
Source File: AmazonImpl.java    From socialauth with MIT License 5 votes vote down vote up
@Override
public Profile getUserProfile() throws Exception {
	if (userProfile == null && accessGrant != null) {
		getProfile();
	}
	return userProfile;
}
 
Example #16
Source File: AmazonImpl.java    From socialauth with MIT License 5 votes vote down vote up
private Profile getProfile() throws Exception {
	String presp;

	try {
		Response response = authenticationStrategy.executeFeed(PROFILE_URL);
		presp = response.getResponseBodyAsString(Constants.ENCODING);
	} catch (Exception e) {
		throw new SocialAuthException("Error while getting profile from "
				+ PROFILE_URL, e);
	}
	try {
		LOG.debug("User Profile : " + presp);
		JSONObject resp = new JSONObject(presp);
		Profile p = new Profile();
		p.setFullName(resp.optString("name", null));
		p.setEmail(resp.optString("email", null));
		p.setValidatedId(resp.optString("user_id", null));
		p.setLocation(resp.optString("postal_code", null));
		if (config.isSaveRawResponse()) {
			p.setRawResponse(presp);
		}
		p.setProviderId(getProviderId());
		if (config.isSaveRawResponse()) {
			p.setRawResponse(presp);
		}
		userProfile = p;
		return p;

	} catch (Exception ex) {
		throw new ServerDataException(
				"Failed to parse the user profile json : " + presp, ex);
	}
}
 
Example #17
Source File: AmazonImpl.java    From socialauth with MIT License 5 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Verifying the authentication response from provider");
	accessGrant = authenticationStrategy.verifyResponse(requestParams,
			MethodType.POST.toString());
	return getProfile();
}
 
Example #18
Source File: AmazonImpl.java    From socialauth with MIT License 5 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(Map<String, String> requestParams)
		throws Exception {
	if (requestParams.containsKey(Constants.STATE)) {
		String stateStr = requestParams.get(Constants.STATE);
		if (!state.equals(stateStr)) {
			throw new SocialAuthException(
					"State parameter value does not match with expected value");
		}
	}
	return doVerifyResponse(requestParams);
}
 
Example #19
Source File: GenericOAuth1Provider.java    From socialauth with MIT License 5 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Verifying the authentication response from provider");
	if (requestParams.get("denied") != null) {
		throw new UserDeniedPermissionException();
	}
	accessToken = authenticationStrategy.verifyResponse(requestParams);
	isVerify = true;
	return null;
}
 
Example #20
Source File: SocialAuthAdapter.java    From socialauth-android with MIT License 5 votes vote down vote up
@Override
protected Profile doInBackground(Void... params) {

	Profile profileList = null;
	try {
		profileList = getCurrentProvider().getUserProfile();
		Log.d("SocialAuthAdapter", "Received Profile Details");
		return profileList;

	} catch (Exception e) {
		e.printStackTrace();
		listener.onError(new SocialAuthError("Profile Details not Received", e));
		return null;
	}
}
 
Example #21
Source File: YahooImpl.java    From socialauth with MIT License 5 votes vote down vote up
/**
 * Retrieves the user profile.
 * 
 * @return Profile object containing the profile information.
 */
@Override
public Profile getUserProfile() throws Exception {
	if (userProfile == null && accessToken != null) {
		getProfile();
	}
	return userProfile;
}
 
Example #22
Source File: MendeleyImpl.java    From socialauth with MIT License 5 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Verifying the authentication response from provider");
	accessToken = authenticationStrategy.verifyResponse(requestParams,
			MethodType.POST.toString());
	isVerify = true;
	return getProfile();
}
 
Example #23
Source File: LinkedInImpl.java    From socialauth with MIT License 5 votes vote down vote up
/**
 * Retrieves the user profile.
 * 
 * @return Profile object containing the profile information.
 */
@Override
public Profile getUserProfile() throws Exception {
	if (userProfile == null && accessToken != null) {
		getProfile();
	}
	return userProfile;
}
 
Example #24
Source File: FourSquareImpl.java    From socialauth with MIT License 5 votes vote down vote up
/**
 * Retrieves the user profile.
 * 
 * @return Profile object containing the profile information.
 */
@Override
public Profile getUserProfile() throws Exception {
	if (userProfile == null && accessToken != null) {
		getProfile();
	}
	return userProfile;
}
 
Example #25
Source File: SocialAuthAdapter.java    From socialauth-android with MIT License 5 votes vote down vote up
/**
 * Synchronous Method to get Profile of User Use this method inside
 * AsyncTask else you will get NetworkOSThreadException
 */

public Profile getUserProfile() {
	Profile profileList = null;
	try {
		profileList = getCurrentProvider().getUserProfile();
		Log.d("SocialAuthAdapter", "Received Profile Details");
		return profileList;

	} catch (Exception e) {
		Log.d("SocialAuthAdapter", "Profile Details not Received");
		return null;
	}
}
 
Example #26
Source File: GoogleImpl.java    From socialauth with MIT License 5 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Verifying the authentication response from provider");
	LOG.debug("Verifying the authentication response from provider");
	if (requestParams.get("openid.mode") != null
			&& "cancel".equals(requestParams.get("openid.mode"))) {
		throw new UserDeniedPermissionException();
	}
	accessToken = authenticationStrategy.verifyResponse(requestParams);
	LOG.debug("Obtaining profile from OpenID response");
	return getProfile(requestParams);
}
 
Example #27
Source File: TwitterImpl.java    From socialauth with MIT License 5 votes vote down vote up
/**
 * Retrieves the user profile.
 * 
 * @return Profile object containing the profile information.
 */
@Override
public Profile getUserProfile() throws Exception {
	if (userProfile == null && accessToken != null) {
		getProfile();
	}
	return userProfile;
}
 
Example #28
Source File: TwitterImpl.java    From socialauth with MIT License 5 votes vote down vote up
private Profile doVerifyResponse(final Map<String, String> requestParams)
		throws Exception {
	LOG.info("Verifying the authentication response from provider");
	if (requestParams.get("denied") != null) {
		throw new UserDeniedPermissionException();
	}
	accessToken = authenticationStrategy.verifyResponse(requestParams);
	isVerify = true;
	return getProfile();
}
 
Example #29
Source File: OpenIdConsumer.java    From socialauth with MIT License 5 votes vote down vote up
/**
 * Parses the user info from request
 * 
 * @param requestParams
 *            request parameters map
 * @return User Profile
 */
public static Profile getUserInfo(final Map<String, String> requestParams) {
	Profile p = new Profile();
	p.setEmail(requestParams.get("openid.ext1.value.email"));
	p.setFirstName(requestParams.get("openid.ext1.value.firstname"));
	p.setLastName(requestParams.get("openid.ext1.value.lastname"));
	p.setCountry(requestParams.get("openid.ext1.value.country"));
	p.setLanguage(requestParams.get("openid.ext1.value.language"));
	p.setValidatedId(requestParams.get("openid.identity"));
	return p;
}
 
Example #30
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);
}