geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dblev...@apache.org
Subject svn commit: r279045 - /geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/network/protocol/SubjectCarryingChannel.java
Date Tue, 06 Sep 2005 17:52:27 GMT
Author: dblevins
Date: Tue Sep  6 10:52:24 2005
New Revision: 279045

URL: http://svn.apache.org/viewcvs?rev=279045&view=rev
Log:
Updated for activeio 2

Modified:
    geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/network/protocol/SubjectCarryingChannel.java

Modified: geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/network/protocol/SubjectCarryingChannel.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/network/protocol/SubjectCarryingChannel.java?rev=279045&r1=279044&r2=279045&view=diff
==============================================================================
--- geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/network/protocol/SubjectCarryingChannel.java
(original)
+++ geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/network/protocol/SubjectCarryingChannel.java
Tue Sep  6 10:52:24 2005
@@ -16,78 +16,77 @@
  */
 package org.apache.geronimo.security.network.protocol;
 
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.security.AccessController;
-import java.util.Collection;
-import javax.security.auth.Subject;
-
-import org.activeio.AsynchChannel;
-import org.activeio.FilterAsynchChannel;
+import org.activeio.AsyncChannel;
+import org.activeio.FilterAsyncChannel;
 import org.activeio.Packet;
-import org.activeio.adapter.PacketInputStream;
 import org.activeio.adapter.PacketOutputStream;
+import org.activeio.adapter.PacketToInputStream;
 import org.activeio.packet.AppendedPacket;
 import org.activeio.packet.ByteArrayPacket;
 import org.activeio.packet.FilterPacket;
-
 import org.apache.geronimo.security.ContextManager;
 import org.apache.geronimo.security.IdentificationPrincipal;
 import org.apache.geronimo.security.SubjectId;
 
+import javax.security.auth.Subject;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.security.AccessController;
+import java.util.Collection;
+
 /**
- * SubjectCarryingChannel is a FilterAsynchChannel that allows you to send 
+ * SubjectCarryingChannel is a FilterAsynchChannel that allows you to send
  * the subject associated with the current write operation down to the remote
  * end of the channel.
- * 
+ *
  * @version $Rev: 46019 $ $Date: 2004-09-14 02:56:06 -0700 (Tue, 14 Sep 2004) $
  */
-public class SubjectCarryingChannel extends FilterAsynchChannel {
+public class SubjectCarryingChannel extends FilterAsyncChannel {
 
-    static final byte PASSTHROUGH = (byte)0x00;
-    static final byte SET_SUBJECT = (byte)0x01;
-    static final byte CLEAR_SUBJECT = (byte)0x2;
+    static final byte PASSTHROUGH = (byte) 0x00;
+    static final byte SET_SUBJECT = (byte) 0x01;
+    static final byte CLEAR_SUBJECT = (byte) 0x2;
 
-    final private ByteArrayPacket header = new ByteArrayPacket(new byte[1+8+4]);
+    final private ByteArrayPacket header = new ByteArrayPacket(new byte[1 + 8 + 4]);
 
     private Subject remoteSubject;
     private Subject localSubject;
-    
+
     private final boolean enableLocalSubjectPublishing;
     private final boolean enableRemoteSubjectConsumption;
 
-    public SubjectCarryingChannel(AsynchChannel next) {
+    public SubjectCarryingChannel(AsyncChannel next) {
         this(next, true, true);
     }
-    
-    public SubjectCarryingChannel(AsynchChannel next, boolean enableLocalSubjectPublishing,
boolean enableRemoteSubjectConsumption) {
+
+    public SubjectCarryingChannel(AsyncChannel next, boolean enableLocalSubjectPublishing,
boolean enableRemoteSubjectConsumption) {
         super(next);
         this.enableLocalSubjectPublishing = enableLocalSubjectPublishing;
         this.enableRemoteSubjectConsumption = enableRemoteSubjectConsumption;
     }
-    
+
     public void write(Packet packet) throws IOException {
-        
+
         // Don't add anything to the packet stream if subject writing is not enabled.
-        if( !enableLocalSubjectPublishing ) {
+        if (!enableLocalSubjectPublishing) {
             super.write(packet);
             return;
         }
-        
+
         Subject subject = Subject.getSubject(AccessController.getContext());
         if (remoteSubject != subject) {
             remoteSubject = subject;
             Collection principals = remoteSubject.getPrincipals(IdentificationPrincipal.class);
-            
+
             if (principals.isEmpty()) {
                 super.write(createClearSubjectPackt());
-            } else {                
+            } else {
                 IdentificationPrincipal principal = (IdentificationPrincipal) principals.iterator().next();
-                SubjectId subjectId = principal.getId();                
+                SubjectId subjectId = principal.getId();
                 super.write(createSubjectPacket(subjectId.getSubjectId(), subjectId.getHash()));
             }
-            
+
         }
         super.write(createPassthroughPacket(packet));
     }
@@ -99,7 +98,7 @@
         }
 
         public Object narrow(Class target) {
-            if( target == SubjectContext.class ) {
+            if (target == SubjectContext.class) {
                 return new SubjectContext() {
                     public Subject getSubject() {
                         return remoteSubject;
@@ -116,24 +115,24 @@
     }
 
     public void onPacket(Packet packet) {
-        
+
         // Don't take anything to the packet stream if subject reading is not enabled.
-        if( !enableRemoteSubjectConsumption ) {
+        if (!enableRemoteSubjectConsumption) {
             super.onPacket(packet);
             return;
         }
-        
+
         try {
-            switch( packet.read() ) {
+            switch (packet.read()) {
                 case CLEAR_SUBJECT:
                     localSubject = null;
                     return;
-                case SET_SUBJECT:               
+                case SET_SUBJECT:
                     SubjectId subjectId = extractSubjectId(packet);
                     localSubject = ContextManager.getRegisteredSubject(subjectId);
                     return;
                 case PASSTHROUGH:
-                    super.onPacket( new SubjectPacketFilter(packet) );
+                    super.onPacket(new SubjectPacketFilter(packet));
             }
         } catch (IOException e) {
             super.onPacketError(e);
@@ -145,9 +144,9 @@
     /**
      */
     private SubjectId extractSubjectId(Packet packet) throws IOException {
-        DataInputStream is = new DataInputStream(new PacketInputStream(packet));
+        DataInputStream is = new DataInputStream(new PacketToInputStream(packet));
         Long id = new Long(is.readLong());
-        byte hash[]=  new byte[ is.readInt() ];
+        byte hash[] = new byte[is.readInt()];
         return new SubjectId(id, hash);
     }
 
@@ -173,7 +172,7 @@
         header.clear();
         header.write(PASSTHROUGH);
         header.flip();
-        return AppendedPacket.join(header,packet);
+        return AppendedPacket.join(header, packet);
     }
 
     public Subject getLocalSubject() {
@@ -183,5 +182,5 @@
     public Subject getRemoteSubject() {
         return remoteSubject;
     }
-    
+
 }



Mime
View raw message