001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.mina.proxy.handlers.http.basic;
021
022import org.apache.mina.core.filterchain.IoFilter.NextFilter;
023import org.apache.mina.proxy.ProxyAuthException;
024import org.apache.mina.proxy.handlers.http.AbstractAuthLogicHandler;
025import org.apache.mina.proxy.handlers.http.HttpProxyRequest;
026import org.apache.mina.proxy.handlers.http.HttpProxyResponse;
027import org.apache.mina.proxy.session.ProxyIoSession;
028import org.slf4j.Logger;
029import org.slf4j.LoggerFactory;
030
031/**
032 * HttpNoAuthLogicHandler.java - HTTP 'no auth' mechanism logic handler.
033 * 
034 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
035 * @since MINA 2.0.0-M3
036 */
037public class HttpNoAuthLogicHandler extends AbstractAuthLogicHandler {
038    private final static Logger logger = LoggerFactory.getLogger(HttpNoAuthLogicHandler.class);
039
040    /**
041     * Build an HttpNoAuthLogicHandler
042     * 
043     * @param proxyIoSession The original session
044     * @throws ProxyAuthException If we get an error during the proxy authentication
045     */
046    public HttpNoAuthLogicHandler(final ProxyIoSession proxyIoSession) throws ProxyAuthException {
047        super(proxyIoSession);
048    }
049
050    /**
051     * {@inheritDoc}
052     */
053    @Override
054    public void doHandshake(final NextFilter nextFilter) throws ProxyAuthException {
055        logger.debug(" doHandshake()");
056
057        // Just send the request, no authentication needed
058        writeRequest(nextFilter, (HttpProxyRequest) request);
059        step++;
060    }
061
062    /**
063     * {@inheritDoc}
064     */
065    @Override
066    public void handleResponse(final HttpProxyResponse response) throws ProxyAuthException {
067        // Should never get here !
068        throw new ProxyAuthException("Received error response code (" + response.getStatusLine() + ").");
069    }
070}