当前位置: 首页>>代码示例>>Java>>正文


Java OAuth2Parameters.setRedirectUri方法代码示例

本文整理汇总了Java中org.springframework.social.oauth2.OAuth2Parameters.setRedirectUri方法的典型用法代码示例。如果您正苦于以下问题:Java OAuth2Parameters.setRedirectUri方法的具体用法?Java OAuth2Parameters.setRedirectUri怎么用?Java OAuth2Parameters.setRedirectUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.social.oauth2.OAuth2Parameters的用法示例。


在下文中一共展示了OAuth2Parameters.setRedirectUri方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepare

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
@Override
public CredentialFlowState prepare(final String connectorId, final URI baseUrl, final URI returnUrl) {
    final OAuth2CredentialFlowState.Builder flowState = new OAuth2CredentialFlowState.Builder().returnUrl(returnUrl)
        .providerId(id);

    final OAuth2Parameters parameters = new OAuth2Parameters();

    final String callbackUrl = callbackUrlFor(baseUrl, EMPTY);
    parameters.setRedirectUri(callbackUrl);

    final String scope = connectionFactory.getScope();
    parameters.setScope(scope);

    final String stateKey = connectionFactory.generateState();
    flowState.key(stateKey);
    parameters.add("state", stateKey);

    final OAuth2Operations oauthOperations = connectionFactory.getOAuthOperations();

    final String redirectUrl = oauthOperations.buildAuthorizeUrl(parameters);
    flowState.redirectUrl(redirectUrl);

    flowState.connectorId(connectorId);

    return flowState.build();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:27,代码来源:OAuth2CredentialProvider.java

示例2: prepare

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
@Override
public CredentialFlowState prepare(final URI baseUrl, final URI returnUrl) {
    final OAuth2CredentialFlowState.Builder flowState = new OAuth2CredentialFlowState.Builder().returnUrl(returnUrl)
        .providerId(id);

    final OAuth2Parameters parameters = new OAuth2Parameters();

    final String callbackUrl = callbackUrlFor(baseUrl, EMPTY);
    parameters.setRedirectUri(callbackUrl);

    final String scope = connectionFactory.getScope();
    parameters.setScope(scope);

    final String stateKey = connectionFactory.generateState();
    flowState.key(stateKey);
    parameters.add("state", stateKey);

    final OAuth2Operations oauthOperations = connectionFactory.getOAuthOperations();

    final String redirectUrl = oauthOperations.buildAuthorizeUrl(parameters);
    flowState.redirectUrl(redirectUrl);

    return flowState.build();
}
 
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:25,代码来源:OAuth2CredentialProvider.java

示例3: getAuthorisationUrls

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
@Override
public AuthUrlPair getAuthorisationUrls(Channel channel, String callbackUrl)
{
    ParameterCheck.mandatory("channel", channel);
    if (!ID.equals(channel.getChannelType().getId()))
    {
        throw new IllegalArgumentException("Invalid channel type: " + channel.getChannelType().getId());
    }

    NodeRef channelRef = channel.getNodeRef();
    StringBuilder authStateBuilder = new StringBuilder(channelRef.getStoreRef().getProtocol()).append('.').append(
            channelRef.getStoreRef().getIdentifier()).append('.').append(channelRef.getId());
    OAuth2Operations oauthOperations = publishingHelper.getConnectionFactory().getOAuthOperations();
    OAuth2Parameters params = new OAuth2Parameters();
    params.setRedirectUri(redirectUri);
    params.setScope("publish_stream,offline_access,user_photos,user_videos");
    params.setState(authStateBuilder.toString());
    String authRequestUrl = oauthOperations.buildAuthorizeUrl(GrantType.IMPLICIT_GRANT, params);
    return new AuthUrlPair(authRequestUrl, redirectUri);
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:21,代码来源:FacebookChannelType.java

示例4: getOAuth2Parameters

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
private OAuth2Parameters getOAuth2Parameters(NativeWebRequest request, String defaultScope,
    MultiValueMap<String, String> additionalParameters) {
    OAuth2Parameters parameters = new OAuth2Parameters(additionalParameters);
    parameters.putAll(getRequestParameters(request, "scope"));
    parameters.setRedirectUri(callbackUrl(request));
    String scope = request.getParameter("scope");
    if (scope != null) {
        parameters.setScope(scope);
    } else if (defaultScope != null) {
        parameters.setScope(defaultScope);
    }
    return parameters;
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:14,代码来源:ConnectSupport.java

示例5: getAuthenticationURL

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
/**
 * API for getting the Authentication URL for Alfresco CMIS Server using Oauth.
 * 
 * @param clientKey {@link String}
 * @param secretKey {@link String}
 * @param redirectURL {@link String}
 * @return authenticationURL.
 */
public String getAuthenticationURL(String clientKey, String secretKey, String redirectURL) {
	LOGGER.info("Inside get Authentication URL method");
	AlfrescoConnectionFactory connectionFactory = new AlfrescoConnectionFactory(clientKey, secretKey);

	OAuth2Parameters parameters = new OAuth2Parameters();
	parameters.setRedirectUri(redirectURL);
	parameters.setScope(Alfresco.DEFAULT_SCOPE);
	
	return connectionFactory.getOAuthOperations().buildAuthenticateUrl(GrantType.AUTHORIZATION_CODE, parameters);
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:19,代码来源:AlfrescoCMISOAuth.java

示例6: init

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
@PostConstruct
public void init() {
    authUrl = (useSsl ? baseUrlSecure : baseUrl) + "/googleplus/authenticate";
    oAuthParams = new OAuth2Parameters();
    oAuthParams.setRedirectUri(authUrl);
    oAuthParams.setScope("https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.moments.write");
}
 
开发者ID:Glamdring,项目名称:welshare,代码行数:8,代码来源:GooglePlusController.java

示例7: main

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
public static void main(String[] args) {
        String secret = "<secret>";
        String id = "<id>";
        OAuth2Parameters oAuthParams = new OAuth2Parameters();
        oAuthParams.setRedirectUri("<https-url>/googleplus/authenticate");
        oAuthParams.setScope("https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.moments.write");
        oAuthParams.put("access_type", Lists.newArrayList("offline"));

        GooglePlusFactory factory = new GooglePlusFactory(id, secret);

        // Uncomment parts of the code below to simulate the whole flow
        // 1. Get the redirect url
        // 2. Open the url in the browser, authenticate, and copy the authorization code from the reidrected url
        // 3. Paste the code and exchange it for tokens.
        // 4. Copy the tokens and use it for getApi(..)

//        String url = factory.getOAuthOperations().buildAuthenticateUrl(oAuthParams);
//        System.out.println(url);

//        AccessGrant grant = factory.getOAuthOperations().exchangeForAccess("<code>", oAuthParams.getRedirectUri(), null);
//        System.out.println(grant.getAccessToken());
//        System.out.println(grant.getRefreshToken());

//        Plus plus = factory.getApi("<token>");
//        Person person = plus.getPeopleOperations().get("me");
//        System.out.println(person.getName().getFamilyName());
    }
 
开发者ID:Glamdring,项目名称:google-plus-java-api,代码行数:28,代码来源:ManualTest.java

示例8: getTokenMap

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
/**
 * API for getting the token map generated after successful authentication on the Alfresco CMIS Server.
 * 
 * @param clientKey {@link String}
 * @param secretKey {@link String}
 * @param redirectURL {@link String}
 * @return tokenMap
 * @throws DCMAApplicationException if any error or exception occurs.
 */
public Map<String, String> getTokenMap(String clientKey, String secretKey, String redirectURL) throws DCMAApplicationException {
	LOGGER.info("Inside get token map method");
	Map<String, String> map = new HashMap<String, String>();

	String host = ICommonConstants.EMPTY_STRING;
	String portString = ICommonConstants.EMPTY_STRING;
	String callbackPath = ICommonConstants.EMPTY_STRING;

	String[] splittedRedirectURL = redirectURL.split(ICommonConstants.FORWARD_SLASH + ICommonConstants.FORWARD_SLASH);
	if (splittedRedirectURL.length > 1) {
		String string = redirectURL.split(ICommonConstants.FORWARD_SLASH + ICommonConstants.FORWARD_SLASH)[1];
		String[] splittedString = string.split(ICommonConstants.COLON);
		if (splittedString.length > 1) {
			host = splittedString[0];
			String restURL = splittedString[1];
			String[] splittedRestURL = restURL.split(ICommonConstants.FORWARD_SLASH);
			if (splittedRestURL.length > 1) {
				portString = splittedRestURL[0];
				callbackPath = splittedRestURL[1];
			}
		}
	}

	LOGGER.info("Host address:" + host);
	LOGGER.info("Port address:" + portString);
	LOGGER.info("CallbackPath:" + callbackPath);

	if (host == null || host.isEmpty() || portString == null || portString.isEmpty() || callbackPath == null
			|| callbackPath.isEmpty()) {
		throw new DCMAApplicationException("Invalid redirect URL provided for processing.");
	}

	int port = 8080;
	try {
		port = Integer.valueOf(portString);
	} catch (NumberFormatException numberFormatException) {
		LOGGER.error("Invalid port specified in the redirect URL.");
		throw new DCMAApplicationException("Invalid port specified in redirect URL.");
	}

	VerificationCodeReceiver receiver = new LocalServerReceiver(host, port, callbackPath);
	try {
		receiver.getRedirectUri();
		AlfrescoConnectionFactory connectionFactory = new AlfrescoConnectionFactory(clientKey, secretKey);

		String code = receiver.waitForCode();
		
		OAuth2Parameters parameters = new OAuth2Parameters();
		parameters.setRedirectUri(redirectURL);
		parameters.setScope(Alfresco.DEFAULT_SCOPE);

		AccessGrant accessGrant = connectionFactory.getOAuthOperations().exchangeForAccess(code, redirectURL, parameters);
		map.put(CMISProperties.CMIS_REFRESH_TOKEN.getPropertyKey(), accessGrant.getRefreshToken());
	} catch (Exception exception) {
		LOGGER.error("Error occur while starting up the jetty server.");
		throw new DCMAApplicationException("Error occur while setting the jetty server", exception);
	} finally {
		try {
			receiver.stop();
		} catch (Exception e) {
			LOGGER.info("Error in stopping jetty server");
		}
	}
	return map;
}
 
开发者ID:kuzavas,项目名称:ephesoft,代码行数:75,代码来源:AlfrescoCMISOAuth.java

示例9: buildAuthenticateUrl

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
@Override
public String buildAuthenticateUrl(GrantType grantType, OAuth2Parameters parameters) {
	if (redirectUri != null) parameters.setRedirectUri(redirectUri);
	return super.buildAuthenticateUrl(grantType, parameters);
}
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:6,代码来源:YahooOAuth2Template.java

示例10: buildAuthorizeUrl

import org.springframework.social.oauth2.OAuth2Parameters; //导入方法依赖的package包/类
@Override
public String buildAuthorizeUrl(GrantType grantType, OAuth2Parameters parameters) {
	if (redirectUri != null) parameters.setRedirectUri(redirectUri);
	return super.buildAuthorizeUrl(grantType, parameters);
}
 
开发者ID:alex-bretet,项目名称:cloudstreetmarket.com,代码行数:6,代码来源:YahooOAuth2Template.java


注:本文中的org.springframework.social.oauth2.OAuth2Parameters.setRedirectUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。