geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol GSSAPIClientProtocol.java GSSAPIServerProtocol.java
Date Sat, 24 Apr 2004 23:17:07 GMT
adc         2004/04/24 16:17:07

  Modified:    modules/network/src/java/org/apache/geronimo/network/protocol
                        GSSAPIClientProtocol.java GSSAPIServerProtocol.java
  Log:
  Removed reliance on startup dependency.
  
  Revision  Changes    Path
  1.4       +15 -1     incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/GSSAPIClientProtocol.java
  
  Index: GSSAPIClientProtocol.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/GSSAPIClientProtocol.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GSSAPIClientProtocol.java	17 Mar 2004 03:11:59 -0000	1.3
  +++ GSSAPIClientProtocol.java	24 Apr 2004 23:17:07 -0000	1.4
  @@ -32,6 +32,8 @@
   
   import org.apache.geronimo.system.ThreadPool;
   
  +import EDU.oswego.cs.dl.util.concurrent.Latch;
  +
   
   /**
    * @version $Revision$ $Date$
  @@ -46,6 +48,8 @@
       private boolean mutualAuth;
       private boolean confidential;
       private boolean integrity;
  +    Latch startupLatch = new Latch();
  +
   
       public ThreadPool getThreadPool() {
           return threadPool;
  @@ -160,6 +164,10 @@
                       if (context.getMutualAuthState()) log.trace("MUTUAL AUTHENTICATION
IN PLACE");
                       if (context.getConfState()) log.trace("CONFIDENTIALITY IN PLACE");
                       if (context.getIntegState()) log.trace("INTEGRITY IN PLACE");
  +                    
  +                    log.trace("RELEASING " + startupLatch);
  +                    startupLatch.release();
  +                    log.trace("RELEASED " + startupLatch);
                   }
               } else {
                   ByteBuffer buffer = packet.getBuffer();
  @@ -178,6 +186,10 @@
           try {
               log.trace("sendDown");
   
  +            log.trace("AQUIRING " + startupLatch);
  +            if (!startupLatch.attempt(1000 * 1000)) throw new ProtocolException("Send timeout");
  +            log.trace("AQUIRED " + startupLatch);
  +
               int size = 0;
               for (Iterator iter = packet.getBuffers().iterator(); iter.hasNext();) {
                   size += ((ByteBuffer) iter.next()).remaining();
  @@ -193,6 +205,8 @@
               reply.setBuffers(Collections.singletonList(ByteBuffer.allocate(token.length).put(token).flip()));
               getDownProtocol().sendDown(reply);
           } catch (GSSException e) {
  +            throw new ProtocolException(e);
  +        } catch (InterruptedException e) {
               throw new ProtocolException(e);
           }
       }
  
  
  
  1.4       +26 -13    incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/GSSAPIServerProtocol.java
  
  Index: GSSAPIServerProtocol.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/network/src/java/org/apache/geronimo/network/protocol/GSSAPIServerProtocol.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- GSSAPIServerProtocol.java	17 Mar 2004 03:11:59 -0000	1.3
  +++ GSSAPIServerProtocol.java	24 Apr 2004 23:17:07 -0000	1.4
  @@ -19,21 +19,21 @@
   
   import javax.security.auth.Subject;
   import javax.security.auth.kerberos.KerberosPrincipal;
  -
   import java.nio.ByteBuffer;
   import java.util.ArrayList;
   import java.util.Collection;
   import java.util.Collections;
   import java.util.Iterator;
   
  +import EDU.oswego.cs.dl.util.concurrent.Latch;
   import com.sun.security.jgss.GSSUtil;
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
   import org.ietf.jgss.GSSContext;
   import org.ietf.jgss.GSSCredential;
   import org.ietf.jgss.GSSException;
   import org.ietf.jgss.GSSManager;
   import org.ietf.jgss.MessageProp;
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   
   import org.apache.geronimo.network.protocol.control.BootstrapCook;
   import org.apache.geronimo.network.protocol.control.ControlContext;
  @@ -57,6 +57,7 @@
       private boolean integrity;
       private GSSContext context;
       private Subject clientSubject;
  +    Latch startupLatch;
   
       public ThreadPool getThreadPool() {
           return threadPool;
  @@ -98,19 +99,24 @@
           this.integrity = integrity;
       }
   
  -    public void setup() throws ProtocolException {
  -        log.trace("Starting");
  +    public Protocol cloneProtocol() throws CloneNotSupportedException {
  +        GSSAPIServerProtocol result = (GSSAPIServerProtocol) super.clone();
  +
  +        result.startupLatch = new Latch();
           try {
               GSSManager manager = GSSManager.getInstance();
  -            context = manager.createContext((GSSCredential) null);
  -            context.requestMutualAuth(mutualAuth);
  -            context.requestConf(confidential);
  -            context.requestInteg(integrity);
  -            context.requestCredDeleg(true);
  +            result.context = manager.createContext((GSSCredential) null);
  +            result.context.requestMutualAuth(mutualAuth);
  +            result.context.requestConf(confidential);
  +            result.context.requestInteg(integrity);
  +            result.context.requestCredDeleg(true);
           } catch (GSSException e) {
  -            e.printStackTrace();
  -            throw new ProtocolException(e);
  +            throw new CloneNotSupportedException(e.toString());
           }
  +        return result;
  +    }
  +    public void setup() throws ProtocolException {
  +        log.trace("Starting");
       }
   
       public void drain() throws ProtocolException {
  @@ -146,6 +152,7 @@
                           KerberosPrincipal principal = new KerberosPrincipal(context.getSrcName().toString());
                           clientSubject.getPrincipals().add(principal);
                       }
  +                    startupLatch.release();
                   }
               } else {
                   ByteBuffer buffer = packet.getBuffer();
  @@ -167,6 +174,10 @@
           try {
               log.trace("sendDown");
   
  +            log.trace("AQUIRING " + startupLatch);
  +            if (!startupLatch.attempt(1000 * 1000)) throw new ProtocolException("Send timeout");
  +            log.trace("AQUIRED " + startupLatch);
  +
               int size = 0;
               for (Iterator iter = packet.getBuffers().iterator(); iter.hasNext();) {
                   size += ((ByteBuffer) iter.next()).remaining();
  @@ -182,6 +193,8 @@
               reply.setBuffers(Collections.singletonList(ByteBuffer.allocate(token.length).put(token).flip()));
               getDownProtocol().sendDown(reply);
           } catch (GSSException e) {
  +            throw new ProtocolException(e);
  +        } catch (InterruptedException e) {
               throw new ProtocolException(e);
           }
       }
  
  
  

Mime
View raw message