hammant 02/01/14 17:15:24 Modified: altrmi/src/java/org/apache/commons/altrmi/client AltrmiInterfaceLookup.java altrmi/src/java/org/apache/commons/altrmi/client/impl AbstractAltrmiFactory.java altrmi/src/java/org/apache/commons/altrmi/common AltrmiReply.java AltrmiRequest.java altrmi/src/java/org/apache/commons/altrmi/server AltrmiAuthenticator.java altrmi/src/java/org/apache/commons/altrmi/server/impl AbstractServer.java DefaultAuthenticator.java Added: altrmi/src/java/org/apache/commons/altrmi/common KeyAuthentication.java OpenConnectionReply.java OpenConnectionRequest.java Log: more work on authentication Revision Changes Path 1.5 +10 -1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/AltrmiInterfaceLookup.java Index: AltrmiInterfaceLookup.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/AltrmiInterfaceLookup.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AltrmiInterfaceLookup.java 14 Jan 2002 23:03:30 -0000 1.4 +++ AltrmiInterfaceLookup.java 15 Jan 2002 01:15:23 -0000 1.5 @@ -20,7 +20,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ public interface AltrmiInterfaceLookup { @@ -51,4 +51,13 @@ */ Object lookup(String publishedServiceName, AltrmiAuthentication altrmiAuthentication) throws AltrmiConnectionException; + + /** + * Method getTextToSignForAuthentication + * + * + * @return + * + */ + String getTextToSignForAuthentication(); } 1.5 +27 -1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/AbstractAltrmiFactory.java Index: AbstractAltrmiFactory.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/AbstractAltrmiFactory.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractAltrmiFactory.java 14 Jan 2002 23:03:30 -0000 1.4 +++ AbstractAltrmiFactory.java 15 Jan 2002 01:15:24 -0000 1.5 @@ -13,6 +13,11 @@ import org.apache.commons.altrmi.client.AltrmiFactory; import org.apache.commons.altrmi.client.AltrmiHostContext; import org.apache.commons.altrmi.common.AltrmiConnectionException; +import org.apache.commons.altrmi.common.AltrmiReply; +import org.apache.commons.altrmi.common.LookupRequest; +import org.apache.commons.altrmi.common.OpenConnectionRequest; +import org.apache.commons.altrmi.common.AltrmiInvocationException; +import org.apache.commons.altrmi.common.OpenConnectionReply; import java.util.HashMap; @@ -22,7 +27,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ public abstract class AbstractAltrmiFactory implements AltrmiFactory { @@ -30,6 +35,7 @@ protected final HashMap mObjRefs = new HashMap(); protected final HashMap mRefObjs = new HashMap(); private final boolean mBeanOnly; + private String mTextToSign; /** * Constructor AbstractAltrmiFactory @@ -67,6 +73,16 @@ if (mHostContext == null) { mHostContext = hostContext; } + + AltrmiReply ar = mHostContext.getInvocationHandler().handleInvocation(new OpenConnectionRequest()); + if (ar instanceof OpenConnectionReply) { + mTextToSign = ((OpenConnectionReply) ar).getTextToSign(); + } else { + //TODO + } + + + } /** @@ -145,4 +161,14 @@ return lookup(publishedServiceName, null); } + /** + * Method getTextToSignForAuthentication + * + * + * @return + * + */ + public String getTextToSignForAuthentication() { + return mTextToSign; + } } 1.2 +2 -1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiReply.java Index: AltrmiReply.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiReply.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AltrmiReply.java 9 Jan 2002 19:25:54 -0000 1.1 +++ AltrmiReply.java 15 Jan 2002 01:15:24 -0000 1.2 @@ -17,7 +17,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public abstract class AltrmiReply implements Serializable { @@ -28,6 +28,7 @@ public static final int EXCEPTIONREPLY = 3; public static final int LOOKUPREPLY = 4; public static final int METHODFACADEREPLY = 5; + public static final int OPENCONNECTIONREPLY = 6; // 'bad' replies after 100 1.2 +2 -1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiRequest.java Index: AltrmiRequest.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiRequest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AltrmiRequest.java 9 Jan 2002 19:25:54 -0000 1.1 +++ AltrmiRequest.java 15 Jan 2002 01:15:24 -0000 1.2 @@ -17,7 +17,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public abstract class AltrmiRequest implements Serializable { @@ -25,6 +25,7 @@ public static final int METHODREQUEST = 302; public static final int METHODFACADEREQUEST = 303; public static final int LOOKUPREQUEST = 304; + public static final int OPENCONNECTIONREQUEST = 305; /** * Constructor AltrmiRequest 1.1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/KeyAuthentication.java Index: KeyAuthentication.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.commons.altrmi.common; /** * Class KeyAuthentication * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> * @version $Revision: 1.1 $ */ public final class KeyAuthentication extends AltrmiAuthentication { private final String mPublicKey; private final String mSignedText; /** * Constructor KeyAuthentication * * * @param publicKey * @param signedText * */ public KeyAuthentication(String publicKey, String signedText) { mPublicKey = publicKey; mSignedText = signedText; } /** * Method getPublicKey * * * @return * */ public String getPublicKey() { return mPublicKey; } /** * Method getSignedText * * * @return * */ public String getSignedText() { return mSignedText; } } 1.1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/OpenConnectionReply.java Index: OpenConnectionReply.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.commons.altrmi.common; /** * Class OpenConnectionReply * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> * @version $Revision: 1.1 $ */ public final class OpenConnectionReply extends AltrmiReply { private final String mTextToSign; /** * Constructor OpenConnectionReply * * * @param stringToSign * */ public OpenConnectionReply(String textToSign) { mTextToSign = textToSign; } /** * Method getReplyCode. This is quicker than instanceof for type checking. * * * @return * */ public int getReplyCode() { return OPENCONNECTIONREPLY; } /** * Method getTextToSign * * * @return * */ public String getTextToSign() { return mTextToSign; } } 1.1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/OpenConnectionRequest.java Index: OpenConnectionRequest.java =================================================================== /* * Copyright (C) The Apache Software Foundation. All rights reserved. * * This software is published under the terms of the Apache Software License * version 1.1, a copy of which has been included with this distribution in * the LICENSE.txt file. */ package org.apache.commons.altrmi.common; /** * Class OpenConnectionRequest * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> * @version $Revision: 1.1 $ */ public final class OpenConnectionRequest extends AltrmiRequest { /** * Method getRequestCode. This is quicker than instanceof for type checking. * * * @return * */ public int getRequestCode() { return OPENCONNECTIONREQUEST; } } 1.2 +34 -1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiAuthenticator.java Index: AltrmiAuthenticator.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiAuthenticator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- AltrmiAuthenticator.java 14 Jan 2002 23:03:30 -0000 1.1 +++ AltrmiAuthenticator.java 15 Jan 2002 01:15:24 -0000 1.2 @@ -1,3 +1,4 @@ + /* * Copyright (C) The Apache Software Foundation. All rights reserved. * @@ -7,10 +8,42 @@ */ package org.apache.commons.altrmi.server; + + import org.apache.commons.altrmi.common.AltrmiAuthentication; import org.apache.commons.altrmi.common.AltrmiAuthenticationException; + +/** + * Interface AltrmiAuthenticator + * + * + * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> + * @version * $Revision: 1.2 $ + */ public interface AltrmiAuthenticator { - Long checkAuthority(AltrmiAuthentication auth, String publishedService) throws AltrmiAuthenticationException; + /** + * Method checkAuthority + * + * + * @param auth + * @param publishedService + * + * @return + * + * @throws AltrmiAuthenticationException + * + */ + Long checkAuthority(AltrmiAuthentication auth, String publishedService) + throws AltrmiAuthenticationException; + + /** + * Method getTextToSign + * + * + * @return + * + */ + String getTextToSign(); } 1.5 +4 -1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java Index: AbstractServer.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/AbstractServer.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- AbstractServer.java 14 Jan 2002 23:03:30 -0000 1.4 +++ AbstractServer.java 15 Jan 2002 01:15:24 -0000 1.5 @@ -32,6 +32,7 @@ import org.apache.commons.altrmi.common.MethodReply; import org.apache.commons.altrmi.common.AltrmiAuthenticationException; import org.apache.commons.altrmi.common.AltrmiInvocationException; +import org.apache.commons.altrmi.common.OpenConnectionReply; import org.apache.commons.altrmi.server.AltrmiClassRetrievalException; import org.apache.commons.altrmi.server.ClassRetriever; import org.apache.commons.altrmi.server.AltrmiServerInvocationHandler; @@ -51,7 +52,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ public abstract class AbstractServer extends AbstractMethodHandler implements AltrmiServer { @@ -336,6 +337,8 @@ return new RequestFailedReply(e.getMessage()); } + } else if (request.getRequestCode() == AltrmiRequest.OPENCONNECTIONREQUEST) { + return new OpenConnectionReply(mAltrmiAuthenticator.getTextToSign()); } else { return new RequestFailedReply("Unknown request :" + request.getClass().getName()); } 1.2 +12 -1 jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultAuthenticator.java Index: DefaultAuthenticator.java =================================================================== RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultAuthenticator.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- DefaultAuthenticator.java 14 Jan 2002 23:03:30 -0000 1.1 +++ DefaultAuthenticator.java 15 Jan 2002 01:15:24 -0000 1.2 @@ -20,7 +20,7 @@ * * * @author Paul Hammant <a href="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</a> - * @version $Revision: 1.1 $ + * @version $Revision: 1.2 $ */ public class DefaultAuthenticator implements AltrmiAuthenticator { @@ -44,5 +44,16 @@ // approve everything and set session identifier. return new Long (( SESSION++ * (2^31) ) + Math.round(Math.random())); + } + + /** + * Method getTextToSign + * + * + * @return + * + */ + public String getTextToSign() { + return "random" + Math.random() + "-" + Math.random() + "-" + Math.random() + "!"; } }
-- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>