@@ -0,0 +1,2597 @@
+package org.pac4j.async.oauth.profile.url;%0A%0Aimport com.github.scribejava.core.model.OAuth2AccessToken;%0Aimport org.pac4j.async.oauth.config.FacebookConfiguration;%0Aimport org.pac4j.async.oauth.config.OAuth20Configuration;%0Aimport org.pac4j.async.oauth.facebook.FacebookConstants;%0Aimport org.pac4j.core.exception.TechnicalException;%0Aimport org.pac4j.core.util.CommonHelper;%0A%0Aimport javax.crypto.Mac;%0Aimport javax.crypto.spec.SecretKeySpec;%0A%0A/**%0A *%0A */%0Apublic class FacebookProfileUrlCalculator extends  OAuthProfileUrlCalculator%3COAuth2AccessToken, FacebookConfiguration%3E %7B%0A%0A    protected static final String BASE_URL = %22https://graph.facebook.com/v2.8/me%22;%0A%0A    protected static final String APPSECRET_PARAMETER = %22appsecret_proof%22;%0A%0A    @Override%0A    public String getProfileUrl(final OAuth2AccessToken accessToken, final FacebookConfiguration configuration) %7B%0A        String url = BASE_URL + %22?fields=%22 + configuration.getFields();%0A        if (configuration.getLimit() %3E FacebookConstants.DEFAULT_LIMIT) %7B%0A            url += %22&limit=%22 + configuration.getLimit();%0A        %7D%0A        // possibly include the appsecret_proof parameter%0A        if (configuration.isUseAppsecretProof()) %7B%0A            url = computeAppSecretProof(url, accessToken, configuration);%0A        %7D%0A        return url;%0A    %7D%0A%0A    /**%0A     * 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%0A     * and this answer: https://stackoverflow.com/questions/7124735/hmac-sha256-algorithm-for-signature-calculation%0A     *%0A     * @param url the URL to which we're adding the proof%0A     * @param token the application token we pass back and forth%0A     * @param configuration the current configuration%0A     * @return URL with the appsecret_proof parameter added%0A     */%0A    public String computeAppSecretProof(final String url, final OAuth2AccessToken token, final OAuth20Configuration configuration) %7B%0A        try %7B%0A            Mac sha256_HMAC = Mac.getInstance(%22HmacSHA256%22);%0A            SecretKeySpec secret_key = new SecretKeySpec(configuration.getSecret().getBytes(%22UTF-8%22), %22HmacSHA256%22);%0A            sha256_HMAC.init(secret_key);%0A            String proof = org.apache.commons.codec.binary.Hex.encodeHexString(sha256_HMAC.doFinal(token.getAccessToken().getBytes(%22UTF-8%22)));%0A            final String computedUrl = CommonHelper.addParameter(url, APPSECRET_PARAMETER, proof);%0A            return computedUrl;%0A        %7D catch (final Exception e) %7B%0A            throw new TechnicalException(%22Unable to compute appsecret_proof%22, e);%0A        %7D%0A    %7D%0A%0A%0A%7D%0A

pac4j-async-310 Implement FacebookProfileUrlCalculator