Package org.restlet.data

Examples of org.restlet.data.ChallengeRequest


     * @param header
     *            The HTTP header value to parse.
     * @return The parsed challenge request.
     */
    public static ChallengeRequest parseAuthenticateHeader(String header) {
        ChallengeRequest result = null;

        if (header != null) {
            final int space = header.indexOf(' ');

            if (space != -1) {
                final String scheme = header.substring(0, space);
                result = new ChallengeRequest(new ChallengeScheme("HTTP_"
                        + scheme, scheme), null);

                // Parse the parameters to extract the realm
                final String rest = header.substring(space + 1);
                parseParameters(rest, result.getParameters());
                result.setRealm(result.getParameters().getFirstValue("realm"));
            } else {
                final String scheme = header.substring(0);
                result = new ChallengeRequest(new ChallengeScheme("HTTP_"
                        + scheme, scheme), null);
            }
        }

        // Give a chance to the authentication helper to do further parsing
        final AuthenticationHelper helper = Engine.getInstance().findHelper(
                result.getScheme(), true, false);

        if (helper != null) {
            helper.parseRequest(result, header);
        } else {
            Context.getCurrentLogger().warning(
                    "Challenge scheme " + result.getScheme()
                            + " not supported by the Restlet engine.");
        }

        return result;
    }
View Full Code Here

TOP

Related Classes of org.restlet.data.ChallengeRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.