@@ -0,0 +1,2346 @@
+/*%0D%0A * Copyright (C) 2014 Authlete, Inc.%0D%0A *%0D%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0D%0A * you may not use this file except in compliance with the License.%0D%0A * You may obtain a copy of the License at%0D%0A *%0D%0A *     http://www.apache.org/licenses/LICENSE-2.0%0D%0A *%0D%0A * Unless required by applicable law or agreed to in writing, software%0D%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0D%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0D%0A * See the License for the specific language governing permissions and%0D%0A * limitations under the License.%0D%0A */%0D%0Apackage com.authlete.common.web;%0D%0A%0D%0A%0D%0Aimport java.util.regex.Matcher;%0D%0Aimport java.util.regex.Pattern;%0D%0A%0D%0A%0D%0A/**%0D%0A * Utility class for Bearer Token defined in%0D%0A * %3Ca href=%22http://tools.ietf.org/html/rfc6750%22%3ERFC 6750%3C/a%3E.%0D%0A *%0D%0A * @author Takahiko Kawasaki%0D%0A *%0D%0A * @see %3Ca href=%22http://tools.ietf.org/html/rfc6750%22%0D%0A *      %3ERFC 6750 (OAuth 2.0 Bearer Token Usage)%3C/a%3E%0D%0A */%0D%0Apublic class DpopToken%0D%0A%7B%0D%0A    /**%0D%0A     * Regular expression to parse %7B@code Authorization%7D header.%0D%0A     */%0D%0A    private static final Pattern CHALLENGE_PATTERN%0D%0A            = Pattern.compile(%22%5EDPoP *(%5B%5E %5D+) *$%22, Pattern.CASE_INSENSITIVE);%0D%0A%0D%0A%0D%0A    private DpopToken()%0D%0A    %7B%0D%0A    %7D%0D%0A%0D%0A%0D%0A    /**%0D%0A     * Extract the access token embedded in the input string.%0D%0A     *%0D%0A     * %3Cp%3E%0D%0A     * This method assumes that the input string comes from the%0D%0A     * Authorization Request Header Field.%0D%0A     * %0D%0A     * @param input%0D%0A     *            The input string to be parsed.%0D%0A     *%0D%0A     * @return%0D%0A     *         The extracted access token, or %3Ccode%3Enull%3C/code%3E if not found.%0D%0A     *%0D%0A     */%0D%0A    public static String parse(String input)%0D%0A    %7B%0D%0A        if (input == null)%0D%0A        %7B%0D%0A            return null;%0D%0A        %7D%0D%0A%0D%0A        // First, check whether the input matches the pattern%0D%0A        // %22Bearer %7Baccess-token%7D%22.%0D%0A        Matcher matcher = CHALLENGE_PATTERN.matcher(input);%0D%0A%0D%0A        // If the input matches the pattern.%0D%0A        if (matcher.matches())%0D%0A        %7B%0D%0A            // Return the value as is. Note that it is not Base64-encoded.%0D%0A            // See https://www.ietf.org/mail-archive/web/oauth/current/msg08489.html%0D%0A            return matcher.group(1);%0D%0A        %7D%0D%0A        else%0D%0A        %7B%0D%0A            return null;%0D%0A        %7D%0D%0A    %7D%0D%0A%7D%0D%0A

add dpop parser