Author: edeoliveira
Date: Sun Mar 29 10:46:40 2009
New Revision: 759663
URL: http://svn.apache.org/viewvc?rev=759663&view=rev
Log:
Added some javadoc
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java
mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyAuthException.java
mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyLogicHandler.java
mina/trunk/core/src/main/java/org/apache/mina/proxy/filter/ProxyFilter.java
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/ProxyRequest.java
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/proxy/AbstractProxyLogicHandler.java
Sun Mar 29 10:46:40 2009
@@ -69,14 +69,14 @@
/**
* Creates a new {...@link AbstractProxyLogicHandler}.
*
- * @param proxyIoSession {...@link ProxyIoSession} in use.
+ * @param proxyIoSession {...@link ProxyIoSession} in use.
*/
public AbstractProxyLogicHandler(ProxyIoSession proxyIoSession) {
this.proxyIoSession = proxyIoSession;
}
/**
- * Returns the proxyFilter {...@link ProxyFilter}.
+ * Returns the proxy filter {...@link ProxyFilter}.
*/
protected ProxyFilter getProxyFilter() {
return proxyIoSession.getProxyFilter();
@@ -96,15 +96,11 @@
return proxyIoSession;
}
- public void setProxySession(ProxyIoSession proxyIoSession) {
- this.proxyIoSession = proxyIoSession;
- }
-
/**
- * Write data to the proxy server.
+ * Writes data to the proxy server.
*
- * @param nextFilter Downstream filter to receive data.
- * @param data Data buffer to be written.
+ * @param nextFilter the next filter
+ * @param data Data buffer to be written.
*/
protected WriteFuture writeData(final NextFilter nextFilter,
final IoBuffer data) throws UnsupportedEncodingException {
@@ -131,7 +127,7 @@
}
/**
- * Signals that the shake has finished.
+ * Signals that the handshake has finished.
*/
protected final void setHandshakeComplete() {
synchronized (this) {
@@ -203,6 +199,11 @@
getSession().close(true);
}
+ /**
+ * Close the session.
+ *
+ * @param message
+ */
protected void closeSession(final String message) {
closeSession(message, null);
}
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyAuthException.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyAuthException.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyAuthException.java
(original)
+++ mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyAuthException.java
Sun Mar 29 10:46:40 2009
@@ -32,10 +32,16 @@
public class ProxyAuthException extends SaslException {
private static final long serialVersionUID = -6511596809517532988L;
+ /**
+ * {...@inheritdoc}
+ */
public ProxyAuthException(String message) {
super(message);
}
+ /**
+ * {...@inheritdoc}
+ */
public ProxyAuthException(String message, Throwable ex) {
super(message, ex);
}
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyLogicHandler.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyLogicHandler.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyLogicHandler.java
(original)
+++ mina/trunk/core/src/main/java/org/apache/mina/proxy/ProxyLogicHandler.java
Sun Mar 29 10:46:40 2009
@@ -33,31 +33,45 @@
*/
public interface ProxyLogicHandler {
/**
- * Returns <code>true</code> if handshaking is complete and
- * data can be sent through the proxy.
+ * Tests if handshake process is complete.
+ *
+ * @return <code>true</code> if handshaking is complete and
+ * data can be sent through the proxy, false otherwise.
*/
public abstract boolean isHandshakeComplete();
/**
* Handle incoming data during the handshake process. Should consume only
the
* handshake data from the buffer, leaving any extra data in place.
+ *
+ * @param nextFilter the next filter in the filter chain
+ * @param buf the buffer holding the received data
+ * @throws ProxyAuthException if authentication fails
*/
public abstract void messageReceived(NextFilter nextFilter, IoBuffer buf)
throws ProxyAuthException;
/**
* Called at each step of the handshake procedure.
+ *
+ * @param nextFilter the next filter in filter chain
+ * @throws ProxyAuthException if authentication fails
*/
public abstract void doHandshake(NextFilter nextFilter)
throws ProxyAuthException;
/**
* Returns the {...@link ProxyIoSession}.
+ *
+ * @return the proxy session object
*/
public abstract ProxyIoSession getProxyIoSession();
/**
* Enqueue a message to be written once handshaking is complete.
+ *
+ * @param nextFilter the next filter in filter chain
+ * @param writeRequest the data to be written
*/
public abstract void enqueueWriteRequest(final NextFilter nextFilter,
final WriteRequest writeRequest);
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/filter/ProxyFilter.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/filter/ProxyFilter.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
--- mina/trunk/core/src/main/java/org/apache/mina/proxy/filter/ProxyFilter.java
(original)
+++ mina/trunk/core/src/main/java/org/apache/mina/proxy/filter/ProxyFilter.java
Sun Mar 29 10:46:40 2009
@@ -43,7 +43,8 @@
import org.slf4j.LoggerFactory;
/**
- * ProxyFilter.java - Proxy {...@link IoFilter}. Automatically inserted into
the {...@link IoFilter} chain by {...@link ProxyConnector}.
+ * ProxyFilter.java - Proxy {...@link IoFilter}.
+ * Automatically inserted into the {...@link IoFilter} chain by {...@link
ProxyConnector}.
* Sends the initial handshake message to the proxy and handles any response
* to the handshake. Once the handshake has completed and the proxied
connection has been
* established this filter becomes transparent to data flowing through the
connection.
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/ProxyRequest.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/ProxyRequest.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/ProxyRequest.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/ProxyRequest.java
Sun Mar 29 10:46:40 2009
@@ -22,7 +22,7 @@
import java.net.InetSocketAddress;
/**
- * ProxyRequest.java - Wrapper class for proxy requests.
+ * ProxyRequest.java - Abstract wrapper class for proxy requests.
*
* @author The Apache MINA Project ([email protected])
* @version $Rev$, $Date$
@@ -30,26 +30,33 @@
*/
public abstract class ProxyRequest {
+ /**
+ * The address of the request endpoint.
+ */
private InetSocketAddress endpointAddress = null;
+ /**
+ * Implicit constructor.
+ */
public ProxyRequest() {
}
+ /**
+ * Basic constructor of a {...@link ProxyRequest} that only sets the
+ * address of the request endpoint.
+ *
+ * @param endpointAddress the address of the request endpoint.
+ */
public ProxyRequest(final InetSocketAddress endpointAddress) {
this.endpointAddress = endpointAddress;
}
/**
- * The request endpoint.
+ * Returns the address of the request endpoint.
+ *
+ * @return the address of the request endpoint
*/
public InetSocketAddress getEndpointAddress() {
return endpointAddress;
}
-
- /**
- * Sets the request endpoint.
- */
- public void setEndpointAddress(InetSocketAddress endpointAddress) {
- this.endpointAddress = endpointAddress;
- }
}
\ No newline at end of file
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/AbstractAuthLogicHandler.java
Sun Mar 29 10:46:40 2009
@@ -27,7 +27,8 @@
import org.slf4j.LoggerFactory;
/**
- * AbstractAuthLogicHandler.java - Abstract class that handles an
authentication mechanism logic.
+ * AbstractAuthLogicHandler.java - Abstract class that handles an
authentication
+ * mechanism logic.
*
* @author The Apache MINA Project ([email protected])
* @version $Rev$, $Date$
@@ -38,7 +39,7 @@
.getLogger(AbstractAuthLogicHandler.class);
/**
- * The request the proxy has to handle.
+ * The request to be handled by the proxy.
*/
protected ProxyRequest request;
@@ -48,10 +49,16 @@
protected ProxyIoSession proxyIoSession;
/**
- * The current step in the handshake.
+ * The current handshake step.
*/
protected int step = 0;
+ /**
+ * Instantiates a handler for the given proxy session.
+ *
+ * @param proxyIoSession the proxy session object
+ * @throws ProxyAuthException
+ */
protected AbstractAuthLogicHandler(final ProxyIoSession proxyIoSession)
throws ProxyAuthException {
this.proxyIoSession = proxyIoSession;
@@ -59,7 +66,10 @@
}
/**
- * Called on each step of the handshaking process.
+ * Method called at each step of the handshaking process.
+ *
+ * @param nextFilter the next filter
+ * @throws ProxyAuthException
*/
public abstract void doHandshake(final NextFilter nextFilter)
throws ProxyAuthException;
@@ -67,11 +77,19 @@
/**
* Handles a HTTP response from the proxy server.
*
- * @param response The response.
+ * @param response The HTTP response.
+ * @throws ProxyAuthException
*/
public abstract void handleResponse(final HttpProxyResponse response)
throws ProxyAuthException;
+ /**
+ * Sends an HTTP request.
+ *
+ * @param nextFilter the next filter
+ * @param request the request to write
+ * @throws ProxyAuthException
+ */
protected void writeRequest(final NextFilter nextFilter,
final HttpProxyRequest request) throws ProxyAuthException {
logger.debug(" sending HTTP request");
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/HttpAuthenticationMethods.java
Sun Mar 29 10:46:40 2009
@@ -43,32 +43,39 @@
this.id = id;
}
- public int getId() {
- return id;
- }
+ /**
+ * Returns the authentication mechanism id.
+ * @return the id
+ */
+ public int getId() {
+ return id;
+ }
- /**
- * Creates an {...@link AbstractAuthLogicHandler} to handle this
authentication mechanism.
+ /**
+ * Creates an {...@link AbstractAuthLogicHandler} to handle the
authentication mechanism.
+ *
+ * @param proxyIoSession the proxy session object
+ * @return a new logic handler
*/
public AbstractAuthLogicHandler getNewHandler(ProxyIoSession
proxyIoSession)
throws ProxyAuthException {
switch (this) {
- case BASIC:
- return new HttpBasicAuthLogicHandler(proxyIoSession);
-
- case DIGEST:
- HttpDigestAuthLogicHandler authHandler = new
HttpDigestAuthLogicHandler(
- proxyIoSession);
- return authHandler;
-
- case NTLM:
- return new HttpNTLMAuthLogicHandler(proxyIoSession);
-
- case NO_AUTH:
- return new HttpNoAuthLogicHandler(proxyIoSession);
-
- default:
- return null;
+ case BASIC:
+ return new HttpBasicAuthLogicHandler(proxyIoSession);
+
+ case DIGEST:
+ HttpDigestAuthLogicHandler authHandler = new
HttpDigestAuthLogicHandler(
+ proxyIoSession);
+ return authHandler;
+
+ case NTLM:
+ return new HttpNTLMAuthLogicHandler(proxyIoSession);
+
+ case NO_AUTH:
+ return new HttpNoAuthLogicHandler(proxyIoSession);
+
+ default:
+ return null;
}
}
}
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpBasicAuthLogicHandler.java
Sun Mar 29 10:46:40 2009
@@ -46,6 +46,9 @@
private final static Logger logger = LoggerFactory
.getLogger(HttpBasicAuthLogicHandler.class);
+ /**
+ * {...@inheritdoc}
+ */
public HttpBasicAuthLogicHandler(final ProxyIoSession proxyIoSession)
throws ProxyAuthException {
super(proxyIoSession);
@@ -60,6 +63,9 @@
req.checkRequiredProperty(HttpProxyConstants.PWD_PROPERTY);
}
+ /**
+ * {...@inheritdoc}
+ */
@Override
public void doHandshake(final NextFilter nextFilter)
throws ProxyAuthException {
@@ -93,7 +99,11 @@
}
/**
- * Computes authorization header value.
+ * Computes the authorization header value.
+ *
+ * @param username the user name
+ * @param password the user password
+ * @return the authorization header value as a string
*/
public static String createAuthorization(final String username,
final String password) {
@@ -101,6 +111,9 @@
.getBytes()));
}
+ /**
+ * {...@inheritdoc}
+ */
@Override
public void handleResponse(final HttpProxyResponse response)
throws ProxyAuthException {
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/basic/HttpNoAuthLogicHandler.java
Sun Mar 29 10:46:40 2009
@@ -39,11 +39,17 @@
private final static Logger logger = LoggerFactory
.getLogger(HttpNoAuthLogicHandler.class);
+ /**
+ * {...@inheritdoc}
+ */
public HttpNoAuthLogicHandler(final ProxyIoSession proxyIoSession)
throws ProxyAuthException {
super(proxyIoSession);
}
+ /**
+ * {...@inheritdoc}
+ */
@Override
public void doHandshake(final NextFilter nextFilter)
throws ProxyAuthException {
@@ -54,6 +60,9 @@
step++;
}
+ /**
+ * {...@inheritdoc}
+ */
@Override
public void handleResponse(final HttpProxyResponse response)
throws ProxyAuthException {
Modified:
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java
URL:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java?rev=759663&r1=759662&r2=759663&view=diff
==============================================================================
---
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java
(original)
+++
mina/trunk/core/src/main/java/org/apache/mina/proxy/handlers/http/ntlm/HttpNTLMAuthLogicHandler.java
Sun Mar 29 10:46:40 2009
@@ -53,6 +53,9 @@
*/
private byte[] challengePacket = null;
+ /**
+ * {...@inheritdoc}
+ */
public HttpNTLMAuthLogicHandler(final ProxyIoSession proxyIoSession)
throws ProxyAuthException {
super(proxyIoSession);
@@ -69,6 +72,9 @@
req.checkRequiredProperty(HttpProxyConstants.WORKSTATION_PROPERTY);
}
+ /**
+ * {...@inheritdoc}
+ */
@Override
public void doHandshake(NextFilter nextFilter) throws ProxyAuthException {
logger.debug(" doHandshake()");
@@ -150,6 +156,9 @@
return null;
}
+ /**
+ * {...@inheritdoc}
+ */
@Override
public void handleResponse(final HttpProxyResponse response)
throws ProxyAuthException {
@@ -158,7 +167,8 @@
step = 1;
if (challengeResponse == null || challengeResponse.length() < 5) {
- // Nothing to handle at this step. Just need to send a reply
type 1 message in doHandshake().
+ // Nothing to handle at this step.
+ // Just need to send a reply type 1 message in doHandshake().
return;
}
@@ -166,7 +176,7 @@
}
if (step == 1) {
- // Header should be like this
+ // Header should look like :
// Proxy-Authenticate: NTLM still_some_more_stuff
String challengeResponse = getNTLMHeader(response);