Package org.restlet.data

Examples of org.restlet.data.ChallengeResponse


        // login and password are filtered by header filter strategy
        String login = exchange.getIn().getHeader(RestletConstants.RESTLET_LOGIN, String.class);
        String password = exchange.getIn().getHeader(RestletConstants.RESTLET_PASSWORD, String.class);

        if (login != null && password != null) {
            ChallengeResponse authentication = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, login, password);
            request.setChallengeResponse(authentication);
            LOG.debug("Basic HTTP Authentication has been applied");
        }

        for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
View Full Code Here


        // login and password are filtered by header filter strategy
        String login = exchange.getIn().getHeader(RestletConstants.RESTLET_LOGIN, String.class);
        String password = exchange.getIn().getHeader(RestletConstants.RESTLET_PASSWORD, String.class);

        if (login != null && password != null) {
            ChallengeResponse authentication = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, login, password);
            request.setChallengeResponse(authentication);
            LOG.debug("Basic HTTP Authentication has been applied");
        }

        for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
View Full Code Here

     *            The header value to parse.
     * @return The parsed challenge response.
     */
    public static ChallengeResponse parseResponse(Request request,
            Logger logger, String header) {
        ChallengeResponse result = null;

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

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

                if (result.getScheme().equals(ChallengeScheme.HTTP_BASIC)) {
                    try {
                        credentials = new String(Base64.decode(result
                                .getCredentials()), "US-ASCII");
                        int separator = credentials.indexOf(':');

                        if (separator == -1) {
                            // Log the blocking
                            logger
                                    .warning("Invalid credentials given by client with IP: "
                                            + ((request != null) ? request
                                                    .getClientInfo()
                                                    .getAddress() : "?"));
                        } else {
                            result.setIdentifier(credentials.substring(0,
                                    separator));
                            result.setSecret(credentials
                                    .substring(separator + 1));

                            // Log the authentication result
                            if (logger != null) {
                                logger
                                        .info("Basic HTTP authentication succeeded: identifier="
                                                + result.getIdentifier() + ".");
                            }
                        }
                    } catch (UnsupportedEncodingException e) {
                        logger.log(Level.WARNING, "Unsupported encoding error",
                                e);
                    }
                } else {
                    // Authentication failed, scheme not supported
                    logger
                            .log(
                                    Level.WARNING,
                                    "Authentication failed: unsupported scheme used: "
                                            + result.getScheme().getName()
                                            + ". Please override the authenticate method.");
                }
            }
        }

View Full Code Here

        // login and password are filtered by header filter strategy
        String login = (String) exchange.getIn().getHeader(RestletConstants.LOGIN);
        String password = (String) exchange.getIn().getHeader(RestletConstants.PASSWORD);
         
        if (login != null && password != null) {
            ChallengeResponse authentication = new ChallengeResponse(
                    ChallengeScheme.HTTP_BASIC, login, password);
            request.setChallengeResponse(authentication);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Basic HTTP Authentication has been applied");
            }
View Full Code Here

        // login and password are filtered by header filter strategy
        String login = exchange.getIn().getHeader(RestletConstants.RESTLET_LOGIN, String.class);
        String password = exchange.getIn().getHeader(RestletConstants.RESTLET_PASSWORD, String.class);

        if (login != null && password != null) {
            ChallengeResponse authentication = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, login, password);
            request.setChallengeResponse(authentication);
            LOG.debug("Basic HTTP Authentication has been applied");
        }

        for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
View Full Code Here

        // login and password are filtered by header filter strategy
        String login = exchange.getIn().getHeader(RestletConstants.RESTLET_LOGIN, String.class);
        String password = exchange.getIn().getHeader(RestletConstants.RESTLET_PASSWORD, String.class);

        if (login != null && password != null) {
            ChallengeResponse authentication = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, login, password);
            request.setChallengeResponse(authentication);
            LOG.debug("Basic HTTP Authentication has been applied");
        }

        for (Map.Entry<String, Object> entry : exchange.getIn().getHeaders().entrySet()) {
View Full Code Here

        // login and password are filtered by header filter strategy
        String login = exchange.getIn().getHeader(RestletConstants.RESTLET_LOGIN, String.class);
        String password = exchange.getIn().getHeader(RestletConstants.RESTLET_PASSWORD, String.class);

        if (login != null && password != null) {
            ChallengeResponse authentication = new ChallengeResponse(ChallengeScheme.HTTP_BASIC, login, password);
            request.setChallengeResponse(authentication);
            if (LOG.isDebugEnabled()) {
                LOG.debug("Basic HTTP Authentication has been applied");
            }
        }
View Full Code Here

        final Method method = getTargetMethod(resolver);

        final Reference targetRef = getTargetRef(resolver);

        final Request request = new Request(method, targetRef);
        final ChallengeResponse challengeResponse = getTargetChallengeResponse(resolver);
        if (challengeResponse != null) {
            request.setChallengeResponse(challengeResponse);
        }

        if (isTargetEntityEnabled()) {
View Full Code Here

        }

        // B - Delete the mail
        final Request request = new Request(Method.DELETE, mailRef);
        if (getMailboxChallengeScheme() != null) {
            final ChallengeResponse challengeResponse = new ChallengeResponse(
                    getMailboxChallengeScheme(), getMailboxLogin(),
                    getMailboxPassword());
            request.setChallengeResponse(challengeResponse);
        }
        final Response response = getContext().getClientDispatcher().handle(
View Full Code Here

        final Reference mailRef = getMailRef(identifier);

        // B - Get the mail
        final Request request = new Request(Method.GET, mailRef);
        if (getMailboxChallengeScheme() != null) {
            final ChallengeResponse challengeResponse = new ChallengeResponse(
                    getMailboxChallengeScheme(), getMailboxLogin(),
                    getMailboxPassword());
            request.setChallengeResponse(challengeResponse);
        }
        final Response response = getContext().getClientDispatcher().handle(
View Full Code Here

TOP

Related Classes of org.restlet.data.ChallengeResponse

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.