commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hamm...@apache.org
Subject cvs commit: jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl DefaultAuthenticator.java AbstractServer.java DefaultInvocationHandler.java
Date Mon, 14 Jan 2002 23:03:31 GMT
hammant     02/01/14 15:03:31

  Modified:    altrmi/src/java/org/apache/commons/altrmi/client
                        AltrmiInterfaceLookup.java
               altrmi/src/java/org/apache/commons/altrmi/client/impl
                        AbstractAltrmiFactory.java BaseServedObject.java
                        ClientClassAltrmiFactory.java
                        ServerClassAltrmiFactory.java
               altrmi/src/java/org/apache/commons/altrmi/common
                        FacadeRefHolder.java LookupReply.java
                        LookupRequest.java MethodFacadeReply.java
                        MethodFacadeRequest.java MethodRequest.java
               altrmi/src/java/org/apache/commons/altrmi/server
                        AltrmiServer.java
                        AltrmiServerInvocationHandler.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl
                        AbstractServer.java DefaultInvocationHandler.java
  Added:       altrmi/src/java/org/apache/commons/altrmi/common
                        AltrmiAuthentication.java
                        AltrmiAuthenticationException.java
                        UserPasswordAuthentication.java
               altrmi/src/java/org/apache/commons/altrmi/server
                        AltrmiAuthenticator.java
               altrmi/src/java/org/apache/commons/altrmi/server/impl
                        DefaultAuthenticator.java
  Log:
  start of authentication and session handling
  
  Revision  Changes    Path
  1.4       +16 -2     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AltrmiInterfaceLookup.java	14 Jan 2002 12:11:07 -0000	1.3
  +++ AltrmiInterfaceLookup.java	14 Jan 2002 23:03:30 -0000	1.4
  @@ -12,6 +12,7 @@
   
   import org.apache.commons.altrmi.client.impl.ClientClassAltrmiFactory;
   import org.apache.commons.altrmi.common.AltrmiConnectionException;
  +import org.apache.commons.altrmi.common.AltrmiAuthentication;
   
   
   /**
  @@ -19,7 +20,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public interface AltrmiInterfaceLookup {
   
  @@ -36,5 +37,18 @@
        */
       Object lookup(String publishedServiceName) throws AltrmiConnectionException;
   
  -
  +    /**
  +     * Method lookup
  +     *
  +     *
  +     * @param publishedServiceName
  +     * @param altrmiAuthentication
  +     *
  +     * @return
  +     *
  +     * @throws AltrmiConnectionException
  +     *
  +     */
  +    Object lookup(String publishedServiceName, AltrmiAuthentication altrmiAuthentication)
  +        throws AltrmiConnectionException;
   }
  
  
  
  1.4       +23 -5     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractAltrmiFactory.java	14 Jan 2002 12:11:07 -0000	1.3
  +++ AbstractAltrmiFactory.java	14 Jan 2002 23:03:30 -0000	1.4
  @@ -22,7 +22,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public abstract class AbstractAltrmiFactory implements AltrmiFactory {
   
  @@ -97,7 +97,7 @@
        *
        *
        */
  -    public final void registerReferenceObject(Object obj, String referenceID) {
  +    public final void registerReferenceObject(Object obj, Long referenceID) {
           mObjRefs.put(obj, referenceID);
           mRefObjs.put(referenceID, obj);
       }
  @@ -111,8 +111,8 @@
        * @return
        *
        */
  -    public final String getReferenceID(Object obj) {
  -        return (String) mObjRefs.get(obj);
  +    public final Long getReferenceID(Object obj) {
  +        return (Long) mObjRefs.get(obj);
       }
   
       /**
  @@ -124,7 +124,25 @@
        * @return
        *
        */
  -    public final Object getImplObj(String referenceID) {
  +    public final Object getImplObj(Long referenceID) {
           return mRefObjs.get(referenceID);
       }
  +
  +
  +    /**
  +     * Method lookup
  +     *
  +     *
  +     * @param publishedServiceName
  +     *
  +     * @return
  +     *
  +     * @throws AltrmiConnectionException
  +     *
  +     */
  +    public final Object lookup(String publishedServiceName)
  +            throws AltrmiConnectionException {
  +        return lookup(publishedServiceName, null);
  +    }
  +
   }
  
  
  
  1.5       +12 -9     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/BaseServedObject.java
  
  Index: BaseServedObject.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/BaseServedObject.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BaseServedObject.java	14 Jan 2002 12:11:07 -0000	1.4
  +++ BaseServedObject.java	14 Jan 2002 23:03:30 -0000	1.5
  @@ -27,7 +27,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.4 $
  + * @version $Revision: 1.5 $
    */
   public final class BaseServedObject {
   
  @@ -35,7 +35,8 @@
       private final AltrmiInvocationHandler mInvocationHandler;
       private final String mPublishedServiceName;
       private final String mObjectName;
  -    private final String mReferenceID;
  +    private final Long mReferenceID;
  +    private final Long mSession;
   
       /**
        * Constructor BaseServedObject
  @@ -51,13 +52,15 @@
        */
       public BaseServedObject(AbstractAltrmiFactory altrmiFactory,
                               AltrmiInvocationHandler invocationHandler,
  -                            String pubishedServiceName, String objectName, String referenceID)
{
  +                            String pubishedServiceName, String objectName,
  +                            Long referenceID, Long session) {
   
           mAltrmiFactory = altrmiFactory;
           mInvocationHandler = invocationHandler;
           mPublishedServiceName = pubishedServiceName;
           mObjectName = objectName;
           mReferenceID = referenceID;
  +        mSession = session;
       }
   
       /**
  @@ -89,18 +92,18 @@
   
           MethodFacadeRequest request = new MethodFacadeRequest(mPublishedServiceName, mObjectName,
                                                                 methodSignature, args,
  -                                                              mReferenceID, objectName);
  +                                                              mReferenceID, objectName,
mSession);
           AltrmiReply reply = mInvocationHandler.handleInvocation(request);
   
           if (reply.getReplyCode() == AltrmiReply.METHODFACADEREPLY) {
               MethodFacadeReply mfr = (MethodFacadeReply) reply;
  -            String ref = mfr.getReferenceID();
  +            Long ref = mfr.getReferenceID();
               Object implBean = mAltrmiFactory.getImplObj(ref);
   
               if (implBean == null) {
                   BaseServedObject bo2 = new BaseServedObject(mAltrmiFactory, mInvocationHandler,
                                                               mPublishedServiceName, objectName,
  -                                                            ref);
  +                                                            ref, mSession);
                   Object retFacade = mAltrmiFactory.getInstance(mPublishedServiceName, objectName,
                                                                 bo2, mAltrmiFactory.isBeanOnly());
   
  @@ -136,7 +139,7 @@
               throws Throwable {
   
           MethodRequest request = new MethodRequest(mPublishedServiceName, mObjectName,
  -                                                  methodSignature, args, mReferenceID);
  +                                                  methodSignature, args, mReferenceID,
mSession);
           AltrmiReply reply = mInvocationHandler.handleInvocation(request);
   
           if (reply.getReplyCode() == AltrmiReply.METHODREPLY) {
  @@ -166,7 +169,7 @@
       public void altrmiProcessVoidRequest(String methodSignature, Object[] args) throws
Throwable {
   
           MethodRequest request = new MethodRequest(mPublishedServiceName, mObjectName,
  -                                                  methodSignature, args, mReferenceID);
  +                                                  methodSignature, args, mReferenceID,
mSession);
           //debug(args);
           AltrmiReply reply = mInvocationHandler.handleInvocation(request);
   
  @@ -196,7 +199,7 @@
        */
       public FacadeRefHolder makeFacadeRefHolder(Object obj, String objectName) {
   
  -        String refID = mAltrmiFactory.getReferenceID(obj);
  +        Long refID = mAltrmiFactory.getReferenceID(obj);
   
           return new FacadeRefHolder(refID, objectName);
       }
  
  
  
  1.4       +10 -5     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientClassAltrmiFactory.java
  
  Index: ClientClassAltrmiFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ClientClassAltrmiFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClientClassAltrmiFactory.java	14 Jan 2002 12:11:07 -0000	1.3
  +++ ClientClassAltrmiFactory.java	14 Jan 2002 23:03:30 -0000	1.4
  @@ -17,6 +17,8 @@
   import org.apache.commons.altrmi.common.LookupRequest;
   import org.apache.commons.altrmi.common.AltrmiReply;
   import org.apache.commons.altrmi.common.NotPublishedReply;
  +import org.apache.commons.altrmi.common.AltrmiAuthentication;
  +import org.apache.commons.altrmi.common.ExceptionReply;
   
   import java.lang.reflect.Constructor;
   import java.lang.reflect.InvocationTargetException;
  @@ -27,7 +29,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class ClientClassAltrmiFactory extends AbstractAltrmiFactory {
   
  @@ -47,24 +49,27 @@
        *
        *
        * @param publishedServiceName
  -     * @param beanOnly
  +     * @param altrmiAuthentication
        *
        * @return
        *
        * @throws AltrmiConnectionException
        *
        */
  -    public Object lookup(String publishedServiceName)
  +    public Object lookup(String publishedServiceName, AltrmiAuthentication altrmiAuthentication)
               throws AltrmiConnectionException {
   
           AltrmiReply ar =
               mHostContext.getInvocationHandler()
  -                .handleInvocation(new LookupRequest(publishedServiceName));
  +                .handleInvocation(new LookupRequest(publishedServiceName, altrmiAuthentication));
   
           if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
               if (ar instanceof NotPublishedReply) {
                   throw new AltrmiConnectionException("Service " + publishedServiceName
                                                       + " not published");
  +            } else if (ar instanceof ExceptionReply) {
  +                ExceptionReply er = (ExceptionReply) ar;
  +                throw (AltrmiConnectionException) er.getReplyException();
               } else {
                   throw new AltrmiConnectionException("Problem doing lookup on service");
               }
  @@ -74,7 +79,7 @@
           BaseServedObject baseObj = new BaseServedObject(this,
                                                           mHostContext.getInvocationHandler(),
                                                           publishedServiceName, "Main",
  -                                                        lr.getReferenceID());
  +                                                        lr.getReferenceID(), lr.getSession());
           Object retVal = getInstance(publishedServiceName, "Main", baseObj, isBeanOnly());
   
           baseObj.registerImplObject(retVal);
  
  
  
  1.4       +10 -4     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ServerClassAltrmiFactory.java
  
  Index: ServerClassAltrmiFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/client/impl/ServerClassAltrmiFactory.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ServerClassAltrmiFactory.java	14 Jan 2002 12:11:07 -0000	1.3
  +++ ServerClassAltrmiFactory.java	14 Jan 2002 23:03:30 -0000	1.4
  @@ -21,6 +21,8 @@
   import org.apache.commons.altrmi.common.AltrmiReply;
   import org.apache.commons.altrmi.common.NotPublishedReply;
   import org.apache.commons.altrmi.common.RequestFailedReply;
  +import org.apache.commons.altrmi.common.AltrmiAuthentication;
  +import org.apache.commons.altrmi.common.ExceptionReply;
   
   import java.util.HashMap;
   
  @@ -33,7 +35,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public class ServerClassAltrmiFactory extends AbstractAltrmiFactory {
   
  @@ -56,23 +58,27 @@
        *
        *
        * @param publishedServiceName
  +     * @param altrmiAuthentication
        *
        * @return
        *
        * @throws AltrmiConnectionException
        *
        */
  -    public Object lookup(String publishedServiceName)
  +    public Object lookup(String publishedServiceName, AltrmiAuthentication altrmiAuthentication)
               throws AltrmiConnectionException {
   
           AltrmiReply ar =
               mHostContext.getInvocationHandler()
  -                .handleInvocation(new LookupRequest(publishedServiceName));
  +                .handleInvocation(new LookupRequest(publishedServiceName, altrmiAuthentication));
   
           if (ar.getReplyCode() >= AltrmiReply.PROBLEMREPLY) {
               if (ar instanceof NotPublishedReply) {
                   throw new AltrmiConnectionException("Service " + publishedServiceName
                                                       + " not published");
  +            } else if (ar instanceof ExceptionReply) {
  +                ExceptionReply er = (ExceptionReply) ar;
  +                throw (AltrmiConnectionException) er.getReplyException();
               } else {
                   throw new AltrmiConnectionException("Problem doing lookup on service");
               }
  @@ -82,7 +88,7 @@
           BaseServedObject baseObj = new BaseServedObject(this,
                                                           mHostContext.getInvocationHandler(),
                                                           publishedServiceName, "Main",
  -                                                        lr.getReferenceID());
  +                                                        lr.getReferenceID(), lr.getSession());
           Object retVal = getInstance(publishedServiceName, "Main", baseObj, isBeanOnly());
   
           baseObj.registerImplObject(retVal);
  
  
  
  1.2       +3 -3      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/FacadeRefHolder.java
  
  Index: FacadeRefHolder.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/FacadeRefHolder.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FacadeRefHolder.java	9 Jan 2002 19:25:54 -0000	1.1
  +++ FacadeRefHolder.java	14 Jan 2002 23:03:30 -0000	1.2
  @@ -15,11 +15,11 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class FacadeRefHolder implements Serializable {
   
  -    private String mReferenceID;
  +    private Long mReferenceID;
       private String mObjectName;
   
   
  @@ -31,7 +31,7 @@
        * @param objectName
        *
        */
  -    public FacadeRefHolder(String referenceID, String objectName) {
  +    public FacadeRefHolder(Long referenceID, String objectName) {
           mReferenceID = referenceID;
           mObjectName = objectName;
       }
  @@ -41,7 +41,7 @@
        *
        *
        */
  -    public String getReferenceID() {
  +    public Long getReferenceID() {
           return mReferenceID;
       }
   
  
  
  
  1.2       +19 -6     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/LookupReply.java
  
  Index: LookupReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/LookupReply.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LookupReply.java	9 Jan 2002 19:25:54 -0000	1.1
  +++ LookupReply.java	14 Jan 2002 23:03:30 -0000	1.2
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -14,24 +15,26 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class LookupReply extends AltrmiReply {
   
  -    private final String mReferenceID;
  +    private final Long mReferenceID;
  +    private final Long mSession;
   
       /**
        * Constructor LookupReply
        *
        *
        * @param referenceID
  +     * @param session
        *
        */
  -    public LookupReply(String referenceID) {
  -        this.mReferenceID = referenceID;
  +    public LookupReply(Long referenceID, Long session) {
  +        mReferenceID = referenceID;
  +        mSession = session;
       }
   
  -
       /**
        * Method getReferenceID.
        *
  @@ -39,7 +42,7 @@
        * @return
        *
        */
  -    public String getReferenceID() {
  +    public Long getReferenceID() {
           return mReferenceID;
       }
   
  @@ -54,4 +57,14 @@
           return LOOKUPREPLY;
       }
   
  +    /**
  +     * Method getSession
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public Long getSession() {
  +        return mSession;
  +    }
   }
  
  
  
  1.2       +16 -2     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/LookupRequest.java
  
  Index: LookupRequest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/LookupRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LookupRequest.java	9 Jan 2002 19:25:54 -0000	1.1
  +++ LookupRequest.java	14 Jan 2002 23:03:30 -0000	1.2
  @@ -14,10 +14,12 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class LookupRequest extends PublishedNameRequest {
   
  +    private final AltrmiAuthentication mAltrmiAuthentication;
  +
       /**
        * Constructor LookupRequest
        *
  @@ -25,8 +27,9 @@
        * @param publishedServiceName
        *
        */
  -    public LookupRequest(String publishedServiceName) {
  +    public LookupRequest(String publishedServiceName, AltrmiAuthentication altrmiAuthentication)
{
           super(publishedServiceName, "Main");
  +        mAltrmiAuthentication = altrmiAuthentication;
       }
   
       /**
  @@ -38,5 +41,16 @@
        */
       public int getRequestCode() {
           return LOOKUPREQUEST;
  +    }
  +
  +    /**
  +     * Method getAltrmiAuthentication.
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public AltrmiAuthentication getAltrmiAuthentication() {
  +        return mAltrmiAuthentication;
       }
   }
  
  
  
  1.2       +4 -4      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/MethodFacadeReply.java
  
  Index: MethodFacadeReply.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/MethodFacadeReply.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MethodFacadeReply.java	9 Jan 2002 19:25:54 -0000	1.1
  +++ MethodFacadeReply.java	14 Jan 2002 23:03:30 -0000	1.2
  @@ -14,11 +14,11 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class MethodFacadeReply extends AltrmiReply {
   
  -    private final String mReferenceID;
  +    private final Long mReferenceID;
   
       /**
        * Constructor MethodFacadeReply
  @@ -27,7 +27,7 @@
        * @param referenceID
        *
        */
  -    public MethodFacadeReply(String referenceID) {
  +    public MethodFacadeReply(Long referenceID) {
           this.mReferenceID = referenceID;
       }
   
  @@ -38,7 +38,7 @@
        * @return
        *
        */
  -    public String getReferenceID() {
  +    public Long getReferenceID() {
           return mReferenceID;
       }
   
  
  
  
  1.2       +3 -3      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/MethodFacadeRequest.java
  
  Index: MethodFacadeRequest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/MethodFacadeRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MethodFacadeRequest.java	9 Jan 2002 19:25:54 -0000	1.1
  +++ MethodFacadeRequest.java	14 Jan 2002 23:03:30 -0000	1.2
  @@ -14,7 +14,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public final class MethodFacadeRequest extends MethodRequest {
   
  @@ -32,8 +32,8 @@
        * @param returnClassNameEncoded
        *
        */
  -    public MethodFacadeRequest(String publishedServiceName, String objectName, String methodSignature,
Object[] args, String referenceID, String returnClassNameEncoded) {
  -        super(publishedServiceName, objectName, methodSignature, args, referenceID);
  +    public MethodFacadeRequest(String publishedServiceName, String objectName, String methodSignature,
Object[] args, Long referenceID, String returnClassNameEncoded, Long session) {
  +        super(publishedServiceName, objectName, methodSignature, args, referenceID, session);
           mReturnClassNameEncoded = returnClassNameEncoded;
       }
   
  
  
  
  1.2       +23 -6     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/MethodRequest.java
  
  Index: MethodRequest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/MethodRequest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MethodRequest.java	9 Jan 2002 19:25:54 -0000	1.1
  +++ MethodRequest.java	14 Jan 2002 23:03:30 -0000	1.2
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -14,13 +15,14 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class MethodRequest extends PublishedNameRequest {
   
       private final String mMethodSignature;
       private final Object[] mArgs;
  -    private final String mRferenceID;
  +    private final Long mReferenceID;
  +    private final Long mSession;
   
       /**
        * Constructor MethodRequest
  @@ -31,13 +33,18 @@
        * @param methodSignature
        * @param args
        * @param referenceID
  +     * @param session
        *
        */
  -    public MethodRequest(String publishedServiceName, String objectName, String methodSignature,
Object[] args, String referenceID) {
  +    public MethodRequest(String publishedServiceName, String objectName, String methodSignature,
  +                         Object[] args, Long referenceID, Long session) {
  +
           super(publishedServiceName, objectName);
  +
           mMethodSignature = methodSignature;
           mArgs = args;
  -        mRferenceID = referenceID;
  +        mReferenceID = referenceID;
  +        mSession = session;
       }
   
       /**
  @@ -69,8 +76,8 @@
        * @return
        *
        */
  -    public String getReferenceID() {
  -        return mRferenceID;
  +    public Long getReferenceID() {
  +        return mReferenceID;
       }
   
       /**
  @@ -84,4 +91,14 @@
           return METHODREQUEST;
       }
   
  +    /**
  +     * Method getSession
  +     *
  +     *
  +     * @return
  +     *
  +     */
  +    public Long getSession() {
  +        return mSession;
  +    }
   }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiAuthentication.java
  
  Index: AltrmiAuthentication.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;
  
  import java.io.Serializable;
  
  public abstract class AltrmiAuthentication implements Serializable {
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/AltrmiAuthenticationException.java
  
  Index: AltrmiAuthenticationException.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;
  
  public class AltrmiAuthenticationException extends AltrmiConnectionException {
  
      public AltrmiAuthenticationException(String msg) {
          super(msg);
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/common/UserPasswordAuthentication.java
  
  Index: UserPasswordAuthentication.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 UserPasswordAuthentication
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public final class UserPasswordAuthentication extends AltrmiAuthentication {
  
      private final String mUserID;
      private final String mPassword;
  
      /**
       * Constructor UserPasswordAuthentication
       *
       *
       * @param userID
       * @param password
       *
       */
      public UserPasswordAuthentication(String userID, String password) {
          mUserID = userID;
          mPassword = password;
      }
  
      /**
       * Method getUserID
       *
       *
       * @return
       *
       */
      public String getUserID() {
          return mUserID;
      }
  
      /**
       * Method getPassword
       *
       *
       * @return
       *
       */
      public String getPassword() {
          return mPassword;
      }
  }
  
  
  
  1.2       +12 -7     jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiServer.java
  
  Index: AltrmiServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiServer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AltrmiServer.java	9 Jan 2002 19:25:55 -0000	1.1
  +++ AltrmiServer.java	14 Jan 2002 23:03:30 -0000	1.2
  @@ -1,3 +1,4 @@
  +
   /*
    * Copyright (C) The Apache Software Foundation. All rights reserved.
    *
  @@ -18,7 +19,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version * $Revision: 1.1 $
  + * @version * $Revision: 1.2 $
    */
   public interface AltrmiServer extends AltrmiPublisher {
   
  @@ -28,12 +29,20 @@
        *
        * @param classRetriever
        *
  -     * @return
        *
        */
       void setClassRetriever(ClassRetriever classRetriever);
   
       /**
  +     * Method setAuthenticator
  +     *
  +     *
  +     * @param altrmiAuthenticator
  +     *
  +     */
  +    void setAuthenticator(AltrmiAuthenticator altrmiAuthenticator);
  +
  +    /**
        * Method processRequest
        *
        *
  @@ -60,15 +69,11 @@
        * Method start
        *
        */
  -    void start() throws AltrmiServerException ;
  +    void start() throws AltrmiServerException;
   
       /**
        * Method stop
        *
        */
       void stop();
  -
  -
  -
  -
   }
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiServerInvocationHandler.java
  
  Index: AltrmiServerInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiServerInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AltrmiServerInvocationHandler.java	9 Jan 2002 19:25:55 -0000	1.1
  +++ AltrmiServerInvocationHandler.java	14 Jan 2002 23:03:30 -0000	1.2
  @@ -14,7 +14,7 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public interface AltrmiServerInvocationHandler extends AltrmiInvocationHandler {
   
  @@ -26,7 +26,7 @@
        * @param beanImpl
        *
        */
  -   void addImplementationBean(String referenceID, Object beanImpl);
  +   void addImplementationBean(Long referenceID, Object beanImpl);
   
       /**
        * Method replaceImplementationBean
  @@ -45,7 +45,7 @@
        * @param implBean
        *
        */
  -   String getOrMakeReferenceIDForBean(Object implBean);
  +   Long getOrMakeReferenceIDForBean(Object implBean);
   
   
   }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/AltrmiAuthenticator.java
  
  Index: AltrmiAuthenticator.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.server;
  
  import org.apache.commons.altrmi.common.AltrmiAuthentication;
  import org.apache.commons.altrmi.common.AltrmiAuthenticationException;
  
  public interface AltrmiAuthenticator {
  
      Long checkAuthority(AltrmiAuthentication auth, String publishedService) throws AltrmiAuthenticationException;
  }
  
  
  
  1.4       +53 -7     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AbstractServer.java	14 Jan 2002 16:36:07 -0000	1.3
  +++ AbstractServer.java	14 Jan 2002 23:03:30 -0000	1.4
  @@ -30,9 +30,12 @@
   import org.apache.commons.altrmi.common.MethodFacadeRequest;
   import org.apache.commons.altrmi.common.MethodFacadeReply;
   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.server.AltrmiClassRetrievalException;
   import org.apache.commons.altrmi.server.ClassRetriever;
   import org.apache.commons.altrmi.server.AltrmiServerInvocationHandler;
  +import org.apache.commons.altrmi.server.AltrmiAuthenticator;
   import org.apache.commons.altrmi.server.impl.classretrievers.BaseMobileClassRetriever;
   import org.apache.commons.altrmi.server.impl.classretrievers.NoClassRetriever;
   
  @@ -48,14 +51,17 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.3 $
  + * @version $Revision: 1.4 $
    */
   public abstract class AbstractServer extends AbstractMethodHandler implements AltrmiServer
{
   
       private HashMap mPublishedObjects = new HashMap();
  +    private Vector mSessions = new Vector();
  +    private Long mLastSession = new Long(0);
       private boolean mSuspend = false;
       private Vector mConnections = new Vector();
       private ClassRetriever mClassRetriever = new NoClassRetriever();
  +    private AltrmiAuthenticator mAltrmiAuthenticator = new DefaultAuthenticator();
   
       protected static final int SHUTTINGDOWN = 11;
       protected static final int STARTED = 22;
  @@ -146,7 +152,7 @@
   
           HashMap mainMethodMap = new HashMap();
           AltrmiServerInvocationHandler mainAsih = new DefaultInvocationHandler(this, asName
+ "_Main", mainMethodMap);
  -        mainAsih.addImplementationBean("<MAIN>", impl);
  +        mainAsih.addImplementationBean(new Long(0), impl);
   
   
           for (int x = 0; x < classesOrInterfacesToExpose.length; x++) {
  @@ -237,10 +243,21 @@
        * @return
        *
        */
  -    public void setClassRetriever(ClassRetriever classRetriever) {
  +    public final void setClassRetriever(ClassRetriever classRetriever) {
           mClassRetriever = classRetriever;
       }
   
  +    /**
  +     * Method setAuthenticator
  +     *
  +     *
  +     * @param altrmiAuthenticator
  +     *
  +     *
  +     */
  +    public final void setAuthenticator(AltrmiAuthenticator altrmiAuthenticator) {
  +        mAltrmiAuthenticator = altrmiAuthenticator;
  +    }
   
       /**
        * Method processRequest
  @@ -273,6 +290,9 @@
                   System.out.flush();
                   return new NotPublishedReply();
               }
  +            if (!sessionExists(mr.getSession())) {
  +                return new ExceptionReply(new AltrmiInvocationException("TODO - you dirty
rat/hacker"));
  +            }
   
               AltrmiServerInvocationHandler asih = (AltrmiServerInvocationHandler) mPublishedObjects.get(publishedThing);
               AltrmiReply ar = asih.handleInvocation(mr);
  @@ -288,13 +308,25 @@
               if (asih2 == null) {
                   return new NotPublishedReply();
               }
  -            String newRef = asih2.getOrMakeReferenceIDForBean(beanImpl);
  -            String newRef2 = asih2.getOrMakeReferenceIDForBean(beanImpl);
  +            if (!sessionExists(mr.getSession())) {
  +                return new ExceptionReply(new AltrmiInvocationException("TODO - you dirty
rat/hacker"));
  +            }
  +
  +            //TODO a decent ref number for main?
  +            Long newRef = asih2.getOrMakeReferenceIDForBean(beanImpl);
  +            //long newRef2 = asih2.getOrMakeReferenceIDForBean(beanImpl);
               return new MethodFacadeReply(newRef);
           } else if (request.getRequestCode() == AltrmiRequest.LOOKUPREQUEST) {
               LookupRequest lr = (LookupRequest) request;
  -            //TODO
  -            return new LookupReply("<MAIN>");
  +            Long session;
  +            try {
  +                session = mAltrmiAuthenticator.checkAuthority(lr.getAltrmiAuthentication(),
lr.getPublishedServiceName());
  +                mSessions.add(session);
  +            } catch (AltrmiAuthenticationException aae) {
  +                return new ExceptionReply(aae);
  +            }
  +            //TODO a decent ref number for main?
  +            return new LookupReply(new Long(0), session);
           } else if (request.getRequestCode() == AltrmiRequest.CLASSREQUEST) {
               try {
                   ClassRequest cr = (ClassRequest) request;
  @@ -308,6 +340,20 @@
               return new RequestFailedReply("Unknown request :" + request.getClass().getName());
           }
       }
  +
  +    private boolean sessionExists(Long session) {
  +        if (mLastSession.equals(session)) {
  +            // buffer last session for performance.
  +            return true;
  +        } else {
  +            if (mSessions.contains(session)) {
  +                mLastSession = session;
  +                return true;
  +            }
  +        }
  +        return false;
  +    }
  +
   
       /**
        * Method suspend
  
  
  
  1.2       +7 -7      jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultInvocationHandler.java
  
  Index: DefaultInvocationHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultInvocationHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- DefaultInvocationHandler.java	9 Jan 2002 19:25:55 -0000	1.1
  +++ DefaultInvocationHandler.java	14 Jan 2002 23:03:30 -0000	1.2
  @@ -35,14 +35,14 @@
    *
    *
    * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
  - * @version $Revision: 1.1 $
  + * @version $Revision: 1.2 $
    */
   public class DefaultInvocationHandler implements AltrmiServerInvocationHandler {
   
       private HashMap mRefBeans = new HashMap();
       private HashMap mBeanRefs = new HashMap();
       private HashMap mMethodMap;
  -    private long mNextReference = 1;
  +    private int mNextReference = 1;
       private AbstractServer mAbstractServer;
       private String mPublishedThing;
   
  @@ -73,7 +73,7 @@
        * @param beanImpl
        *
        */
  -    public void addImplementationBean(String referenceID, Object beanImpl) {
  +    public void addImplementationBean(Long referenceID, Object beanImpl) {
           mRefBeans.put(referenceID, beanImpl);
           mBeanRefs.put(beanImpl, referenceID);
       }
  @@ -89,7 +89,7 @@
       public void replaceImplementationBean(Object implBean, Object withImplBean) {
           Collection coll = mRefBeans.keySet();
           for (Iterator iterator = coll.iterator(); iterator.hasNext();) {
  -            String ref = (String) iterator.next();
  +            Long ref = (Long) iterator.next();
               if (mRefBeans.get(ref).equals(implBean)) {
                   mRefBeans.put(ref, withImplBean);
                   mBeanRefs.remove(implBean);
  @@ -105,10 +105,10 @@
        * @param implBean
        *
        */
  -    public String getOrMakeReferenceIDForBean(Object implBean) {
  -        String ref = (String) mBeanRefs.get(implBean);
  +    public Long getOrMakeReferenceIDForBean(Object implBean) {
  +        Long ref = (Long) mBeanRefs.get(implBean);
           if (ref == null) {
  -            ref = (mNextReference++ + "_" + Math.random()).intern(); // guarantees no spoofing.
  +            ref = new Long( (mNextReference++ * (2^31) ) + Math.round(Math.random())  );
               mBeanRefs.put(implBean, ref);
               mRefBeans.put(ref,implBean);
           }
  
  
  
  1.1                  jakarta-commons-sandbox/altrmi/src/java/org/apache/commons/altrmi/server/impl/DefaultAuthenticator.java
  
  Index: DefaultAuthenticator.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.server.impl;
  
  
  
  import org.apache.commons.altrmi.server.AltrmiAuthenticator;
  import org.apache.commons.altrmi.common.AltrmiAuthentication;
  import org.apache.commons.altrmi.common.AltrmiAuthenticationException;
  
  
  /**
   * Class DefaultAuthenticator
   *
   *
   * @author Paul Hammant <a href="mailto:Paul_Hammant@yahoo.com">Paul_Hammant@yahoo.com</a>
   * @version $Revision: 1.1 $
   */
  public class DefaultAuthenticator implements AltrmiAuthenticator {
  
      private static int SESSION = 0;
  
      /**
       * Method checkAuthority
       *
       *
       * @param auth
       * @param publishedService
       *
       * @return
       *
       * @throws AltrmiAuthenticationException
       *
       */
      public Long checkAuthority(AltrmiAuthentication auth, String publishedService)
              throws AltrmiAuthenticationException {
  
          // approve everything and set session identifier.
  
          return new Long (( SESSION++ * (2^31) ) + Math.round(Math.random()));
      }
  }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message