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


Java CommonHelper.addParameter方法代码示例

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


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

示例1: buildCallbackUrlForAuthorizationCodeResponseType

import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
private String buildCallbackUrlForAuthorizationCodeResponseType(final Authentication authentication,
                                                                final Service service, final String redirectUri,
                                                                final TicketGrantingTicket ticketGrantingTicket) {

    final OAuthCode code = this.oAuthCodeFactory.create(service, authentication, ticketGrantingTicket);
    LOGGER.debug("Generated OAuth code: [{}]", code);
    this.ticketRegistry.addTicket(code);

    final String state = authentication.getAttributes().get(OAuth20Constants.STATE).toString();
    final String nonce = authentication.getAttributes().get(OAuth20Constants.NONCE).toString();

    String callbackUrl = redirectUri;
    callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.CODE, code.getId());
    if (StringUtils.isNotBlank(state)) {
        callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.STATE, state);
    }
    if (StringUtils.isNotBlank(nonce)) {
        callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.NONCE, nonce);
    }
    return callbackUrl;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:OAuth20AuthorizeEndpointController.java

示例2: buildCallbackUrlForAuthorizationCodeResponseType

import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
private String buildCallbackUrlForAuthorizationCodeResponseType(Authentication authentication, Service service, String redirectUri, TicketGrantingTicket ticketGrantingTicket) {
	OAuthCode code = this.oAuthCodeFactory.create(service, authentication, ticketGrantingTicket);
	LOGGER.debug("Generated OAuth code: [{}]", code);
	this.ticketRegistry.addTicket(code);
	String state = authentication.getAttributes().get("state").toString();
	String nonce = authentication.getAttributes().get("nonce").toString();
	String callbackUrl = CommonHelper.addParameter(redirectUri, "code", code.getId());
	if(StringUtils.isNotBlank(state)) {
		callbackUrl = CommonHelper.addParameter(callbackUrl, "state", state);
	}

	if(StringUtils.isNotBlank(nonce)) {
		callbackUrl = CommonHelper.addParameter(callbackUrl, "nonce", nonce);
	}

	return callbackUrl;
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:18,代码来源:OAuth20AuthorizeEndpointController.java

示例3: redirectToApproveView

import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
/**
 * Redirect to approve view model and view.
 *
 * @param ctx the ctx
 * @param svc the svc
 * @return the model and view
 */
protected ModelAndView redirectToApproveView(final J2EContext ctx, final OAuthRegisteredService svc) {
    String callbackUrl = ctx.getFullRequestURL();
    callbackUrl = CommonHelper.addParameter(callbackUrl, OAuth20Constants.BYPASS_APPROVAL_PROMPT, "true");
    LOGGER.debug("callbackUrl: [{}]", callbackUrl);

    final Map<String, Object> model = new HashMap<>();
    model.put("service", svc);
    model.put("callbackUrl", callbackUrl);
    model.put("serviceName", svc.getName());
    model.put("deniedApprovalUrl", svc.getAccessStrategy().getUnauthorizedRedirectUrl());

    prepareApprovalViewModel(model, ctx, svc);
    return getApprovalModelAndView(model);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:22,代码来源:OAuth20ConsentApprovalViewResolver.java

示例4: addExchangeToken

import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
/**
 * Adds the token to the URL in question. If we require appsecret_proof, then this method
 * will also add the appsecret_proof parameter to the URL, as Facebook expects.
 *
 * @param url the URL to modify
 * @param accessToken the token we're passing back and forth
 * @return url with additional parameter(s)
 */
protected String addExchangeToken(final String url, final OAuth2AccessToken accessToken) {
    final FacebookProfileDefinition profileDefinition = configuration.getProfileDefinition();
    String computedUrl = url;
    if (configuration.isUseAppsecretProof()) {
        computedUrl = oAuthProfileUrlCalculator.computeAppSecretProof(computedUrl, accessToken, configuration);
    }
    return CommonHelper.addParameter(computedUrl, EXCHANGE_TOKEN_PARAMETER, accessToken.getAccessToken());
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:17,代码来源:AsyncFacebookProfileCreator.java

示例5: computeAppSecretProof

import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
/**
 * The code in this method is based on this blog post: https://www.sammyk.me/the-single-most-important-way-to-make-your-facebook-app-more-secure
 * and this answer: https://stackoverflow.com/questions/7124735/hmac-sha256-algorithm-for-signature-calculation
 *
 * @param url the URL to which we're adding the proof
 * @param token the application token we pass back and forth
 * @param configuration the current configuration
 * @return URL with the appsecret_proof parameter added
 */
public String computeAppSecretProof(final String url, final OAuth2AccessToken token, final OAuth20Configuration configuration) {
    try {
        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
        SecretKeySpec secret_key = new SecretKeySpec(configuration.getSecret().getBytes("UTF-8"), "HmacSHA256");
        sha256_HMAC.init(secret_key);
        String proof = org.apache.commons.codec.binary.Hex.encodeHexString(sha256_HMAC.doFinal(token.getAccessToken().getBytes("UTF-8")));
        final String computedUrl = CommonHelper.addParameter(url, APPSECRET_PARAMETER, proof);
        return computedUrl;
    } catch (final Exception e) {
        throw new TechnicalException("Unable to compute appsecret_proof", e);
    }
}
 
开发者ID:millross,项目名称:pac4j-async,代码行数:22,代码来源:FacebookProfileUrlCalculator.java

示例6: handleInvalidCredentials

import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
private HttpAction handleInvalidCredentials(final WebContext context, final String username, String message, String errorMessage, int errorCode) throws HttpAction {
    // it's an AJAX request -> unauthorized (instead of a redirection)
    if (getAjaxRequestResolver().isAjax(context)) {
        logger.info("AJAX request detected -> returning " + errorCode);
        return HttpAction.status("AJAX request -> " + errorCode, errorCode, context);
    } else {
        String redirectionUrl = CommonHelper.addParameter(this.loginUrl, this.usernameParameter, username);
        redirectionUrl = CommonHelper.addParameter(redirectionUrl, ERROR_PARAMETER, errorMessage);
        logger.debug("redirectionUrl: {}", redirectionUrl);
        logger.debug(message);
        return HttpAction.redirect(message, context, redirectionUrl);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:14,代码来源:FormClient.java

示例7: retrieveUserProfileFromToken

import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
@Override
protected FacebookProfile retrieveUserProfileFromToken(final OAuth2AccessToken accessToken) throws HttpAction {
    String body = sendRequestForData(accessToken, getProfileUrl(accessToken));
    if (body == null) {
        throw new HttpCommunicationException("Not data found for accessToken: " + accessToken);
    }
    final FacebookProfile profile = extractUserProfile(body);
    addAccessTokenToProfile(profile, accessToken);
    if (profile != null && this.requiresExtendedToken) {
        String url = CommonHelper.addParameter(EXCHANGE_TOKEN_URL, OAuthConstants.CLIENT_ID, getKey());
        url = CommonHelper.addParameter(url, OAuthConstants.CLIENT_SECRET, getSecret());
        url = addExchangeToken(url, accessToken);
        final OAuthRequest request = createOAuthRequest(url);
        final long t0 = System.currentTimeMillis();
        final Response response = request.send();
        final int code = response.getCode();
        body = response.getBody();
        final long t1 = System.currentTimeMillis();
        logger.debug("Request took: " + (t1 - t0) + " ms for: " + url);
        logger.debug("response code: {} / response body: {}", code, body);
        if (code == 200) {
            logger.debug("Retrieve extended token from  {}", body);
            final OAuth2AccessToken extendedAccessToken = ((DefaultApi20) getApi()).getAccessTokenExtractor().extract(body);
            logger.debug("Extended token: {}", extendedAccessToken);
            addAccessTokenToProfile(profile, extendedAccessToken);
        } else {
            logger.error("Cannot get extended token: {} / {}", code, body);
        }
    }
    return profile;
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:32,代码来源:FacebookClient.java

示例8: computeAppSecretProof

import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
/**
 * The code in this method is based on this blog post: https://www.sammyk.me/the-single-most-important-way-to-make-your-facebook-app-more-secure
 * and this answer: https://stackoverflow.com/questions/7124735/hmac-sha256-algorithm-for-signature-calculation
 *
 * @param url the URL to which we're adding the proof
 * @param token the application token we pass back and forth
 * @return URL with the appsecret_proof parameter added
 */
protected String computeAppSecretProof(String url, OAuth2AccessToken token) {
    try {
        Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
        SecretKeySpec secret_key = new SecretKeySpec(getSecret().getBytes("UTF-8"), "HmacSHA256");
        sha256_HMAC.init(secret_key);
        String proof = org.apache.commons.codec.binary.Hex.encodeHexString(sha256_HMAC.doFinal(token.getAccessToken().getBytes("UTF-8")));
        url = CommonHelper.addParameter(url, APPSECRET_PARAMETER, proof);
        return url;
    } catch (final Exception e) {
        throw new TechnicalException("Unable to compute appsecret_proof", e);
    }
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:21,代码来源:FacebookClient.java

示例9: addExchangeToken

import org.pac4j.core.util.CommonHelper; //导入方法依赖的package包/类
/**
 * Adds the token to the URL in question. If we require appsecret_proof, then this method
 * will also add the appsecret_proof parameter to the URL, as Facebook expects.
 *
 * @param url the URL to modify
 * @param accessToken the token we're passing back and forth
 * @return url with additional parameter(s)
 */
protected String addExchangeToken(String url, OAuth2AccessToken accessToken) {
    if (this.useAppsecretProof) {
        url = computeAppSecretProof(url, accessToken);
    }
    return CommonHelper.addParameter(url, EXCHANGE_TOKEN_PARAMETER, accessToken.getAccessToken());
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:15,代码来源:FacebookClient.java


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