You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by ch...@apache.org on 2005/02/20 02:40:29 UTC
svn commit: r154466 -
geronimo/trunk/modules/security/src/java/org/apache/geronimo/security/network/protocol/SubjectCarryingChannel.java
Author: chirino
Date: Sat Feb 19 17:40:28 2005
New Revision: 154466
URL: http://svn.apache.org/viewcvs?view=rev&rev=154466
Log:
Implemented the filter method so that if the packet gets sliced or duplicated, the resulting
packet wiill still carry the Subject context.
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?view=diff&r1=154465&r2=154466
==============================================================================
--- 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 Sat Feb 19 17:40:28 2005
@@ -92,6 +92,29 @@
super.write(createPassthroughPacket(packet));
}
+ public class SubjectPacketFilter extends FilterPacket {
+
+ SubjectPacketFilter(Packet packet) {
+ super(packet);
+ }
+
+ public Object narrow(Class target) {
+ if( target == SubjectContext.class ) {
+ return new SubjectContext() {
+ public Subject getSubject() {
+ return remoteSubject;
+ }
+ };
+ }
+ return super.narrow(target);
+ }
+
+ public Packet filter(Packet packet) {
+ return new SubjectPacketFilter(packet);
+ }
+
+ }
+
public void onPacket(Packet packet) {
// Don't take anything to the packet stream if subject reading is not enabled.
@@ -102,29 +125,15 @@
try {
switch( packet.read() ) {
- case CLEAR_SUBJECT:
- localSubject = null;
+ case CLEAR_SUBJECT:
+ localSubject = null;
return;
- case SET_SUBJECT:
- SubjectId subjectId = extractSubjectId(packet);
- localSubject = ContextManager.getRegisteredSubject(subjectId);
+ case SET_SUBJECT:
+ SubjectId subjectId = extractSubjectId(packet);
+ localSubject = ContextManager.getRegisteredSubject(subjectId);
return;
- case PASSTHROUGH:
- super.onPacket(new FilterPacket(packet){
- public Object narrow(Class target) {
- if( target == SubjectContext.class ) {
- return new SubjectContext() {
- public Subject getSubject() {
- return remoteSubject;
- }
- };
- }
- return super.narrow(target);
- }
- public Packet filter(Packet packet) {
- return packet;
- }
- });
+ case PASSTHROUGH:
+ super.onPacket( new SubjectPacketFilter(packet) );
}
} catch (IOException e) {
super.onPacketError(e);
@@ -139,7 +148,7 @@
DataInputStream is = new DataInputStream(new PacketInputStream(packet));
Long id = new Long(is.readLong());
byte hash[]= new byte[ is.readInt() ];
- return new SubjectId(id, hash);
+ return new SubjectId(id, hash);
}
private Packet createClearSubjectPackt() {