geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject svn commit: r505432 [7/11] - in /geronimo/server/trunk: applications/magicGball/magicGball-ear/src/main/plan/ configs/client-corba-yoko/src/plan/ configs/j2ee-corba-yoko/src/plan/ configs/openejb-corba-deployer/src/plan/ modules/ modules/geronimo-corba...
Date Fri, 09 Feb 2007 19:24:39 GMT
Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/config/tss/TSSX509AttributeCertChain.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/config/tss/TSSX509AttributeCertChain.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/config/tss/TSSX509AttributeCertChain.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/config/tss/TSSX509AttributeCertChain.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,29 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.config.tss;
+
+
+/**
+ * @version $Revision: 503274 $ $Date: 2007-02-03 10:19:18 -0800 (Sat, 03 Feb 2007) $
+ */
+public class TSSX509AttributeCertChain extends TSSSASMechConfig {
+    
+    protected String getName() {
+        return "TSSX509AttributeCertChain";
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPAnonServerName.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPAnonServerName.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPAnonServerName.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPAnonServerName.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.jgss;
+
+import java.security.Provider;
+
+import org.ietf.jgss.GSSName;
+import org.ietf.jgss.Oid;
+import sun.security.jgss.spi.GSSNameSpi;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public final class GSSUPAnonServerName implements GSSNameSpi {
+
+    public boolean isAnonymousName() {
+        return true;
+    }
+
+    public byte[] export() {
+        return "$ANONYMOUS@SERVER".getBytes();
+    }
+
+    public Provider getProvider() {
+        return GSSUPMechanismFactory.PROVIDER;
+    }
+
+    public Oid getMechanism() {
+        return GSSUPMechanismFactory.MECHANISM_OID;
+    }
+
+    public Oid getStringNameType() {
+        return GSSName.NT_HOSTBASED_SERVICE;
+    }
+
+    public boolean equals(GSSNameSpi obj) {
+        if (obj == null) return false;
+        if (!(obj instanceof GSSUPAnonServerName)) return false;
+
+        return true;
+    }
+
+    public String toString() {
+        return "$ANONYMOUS@SERVER";
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPAnonUserName.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPAnonUserName.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPAnonUserName.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPAnonUserName.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,61 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.jgss;
+
+import java.security.Provider;
+
+import org.ietf.jgss.GSSName;
+import org.ietf.jgss.Oid;
+import sun.security.jgss.spi.GSSNameSpi;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public final class GSSUPAnonUserName implements GSSNameSpi {
+
+    public boolean isAnonymousName() {
+        return true;
+    }
+
+    public byte[] export() {
+        return "$ANONYMOUS".getBytes();
+    }
+
+    public Provider getProvider() {
+        return GSSUPMechanismFactory.PROVIDER;
+    }
+
+    public Oid getMechanism() {
+        return GSSUPMechanismFactory.MECHANISM_OID;
+    }
+
+    public Oid getStringNameType() {
+        return GSSName.NT_USER_NAME;
+    }
+
+    public boolean equals(GSSNameSpi obj) {
+        if (obj == null) return false;
+        if (!(obj instanceof GSSUPAnonUserName)) return false;
+
+        return true;
+    }
+
+    public String toString() {
+        return "$ANONYMOUS";
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPContext.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPContext.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPContext.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPContext.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,407 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.jgss;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.security.Provider;
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.ietf.jgss.ChannelBinding;
+import org.ietf.jgss.GSSContext;
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.MessageProp;
+import org.ietf.jgss.Oid;
+import org.omg.GSSUP.InitialContextToken;
+import sun.security.jgss.spi.GSSContextSpi;
+import sun.security.jgss.spi.GSSCredentialSpi;
+import sun.security.jgss.spi.GSSNameSpi;
+
+import org.apache.geronimo.security.jaas.UsernamePasswordCallback;
+import org.apache.geronimo.security.jaas.UsernamePasswordCredential;
+
+import org.apache.geronimo.corba.util.Util;
+
+
+/**
+ * @version $Revision: 503493 $ $Date: 2007-02-04 13:47:55 -0800 (Sun, 04 Feb 2007) $
+ */
+public final class GSSUPContext implements GSSContextSpi {
+
+    private long end;
+    private int lifetime;
+    private UsernamePasswordCredential credential;
+    private GSSNameSpi there;
+    private GSSNameSpi here;
+    private boolean anonymity;
+    private boolean conf;
+    private boolean credDeleg;
+    private boolean integState;
+    private boolean mutualAuth;
+    private boolean replayDet;
+    private boolean sequenceDet;
+    private boolean protReady;
+
+    GSSUPContext() {
+    }
+
+    GSSUPContext(GSSNameSpi peer, GSSCredentialSpi initiatorCred, int lifetime) {
+        this.here = peer;
+
+        this.lifetime = (lifetime == GSSContext.DEFAULT_LIFETIME ? GSSContext.INDEFINITE_LIFETIME : lifetime);
+        this.end = System.currentTimeMillis() + ((long) this.lifetime * 1000L);
+        this.credential = (initiatorCred == null ? null : ((GSSUPCredential) initiatorCred).getCredential());
+    }
+
+    GSSUPContext(GSSCredentialSpi acceptorCred) throws GSSException {
+        this.here = acceptorCred.getName();
+
+        lifetime = (acceptorCred.getInitLifetime() == GSSContext.DEFAULT_LIFETIME ? GSSContext.INDEFINITE_LIFETIME : acceptorCred.getInitLifetime());
+        this.end = System.currentTimeMillis() + ((long) this.lifetime * 1000L);
+
+        checkLife();
+    }
+
+    public int getLifetime() {
+        return lifetime;
+    }
+
+    public void dispose() {
+    }
+
+    public boolean getAnonymityState() {
+        if (isProtReady()) return false;
+        return anonymity;
+    }
+
+    public boolean getConfState() {
+        if (isProtReady()) return false;
+        return conf;
+    }
+
+    public boolean getCredDelegState() {
+        if (isProtReady()) return false;
+        return credDeleg;
+    }
+
+    public boolean getIntegState() {
+        if (isProtReady()) return false;
+        return integState;
+    }
+
+    public boolean getMutualAuthState() {
+        if (isProtReady()) return false;
+        return mutualAuth;
+    }
+
+    public boolean getReplayDetState() {
+        if (isProtReady()) return false;
+        return replayDet;
+    }
+
+    public boolean getSequenceDetState() {
+        if (isProtReady()) return false;
+        return sequenceDet;
+    }
+
+    public boolean isEstablished() {
+        return isProtReady();
+    }
+
+    public boolean isProtReady() {
+        return protReady;
+    }
+
+    public boolean isTransferable() {
+        return true;
+    }
+
+    public byte[] export() throws GSSException {
+        checkLife();
+
+        try {
+            protReady = false;
+
+            ByteArrayOutputStream bout = new ByteArrayOutputStream();
+            DataOutputStream out = new DataOutputStream(bout);
+
+            out.writeLong(end);
+            out.writeInt(lifetime);
+            out.writeBoolean(anonymity);
+            out.writeBoolean(conf);
+            out.writeBoolean(credDeleg);
+            out.writeBoolean(integState);
+            out.writeBoolean(mutualAuth);
+            out.writeBoolean(replayDet);
+            out.writeBoolean(sequenceDet);
+
+            return bout.toByteArray();
+        } catch (IOException e) {
+            throw new GSSException(GSSException.FAILURE);
+        }
+    }
+
+    public void requestLifetime(int i) {
+        if (!isProtReady()) lifetime = i;
+    }
+
+    public int getWrapSizeLimit(int qop, boolean confReq, int maxTokenSize) {
+        return maxTokenSize;
+    }
+
+    public void requestAnonymity(boolean b) {
+        if (!isProtReady()) anonymity = b;
+    }
+
+    public void requestConf(boolean b) {
+        if (!isProtReady()) conf = b;
+    }
+
+    public void requestCredDeleg(boolean b) {
+        if (!isProtReady()) credDeleg = b;
+    }
+
+    public void requestInteg(boolean b) {
+        if (!isProtReady()) integState = b;
+    }
+
+    public void requestMutualAuth(boolean b) {
+        if (!isProtReady()) mutualAuth = b;
+    }
+
+    public void requestReplayDet(boolean b) {
+        if (!isProtReady()) replayDet = b;
+    }
+
+    public void requestSequenceDet(boolean b) {
+        if (!isProtReady()) sequenceDet = b;
+    }
+
+    public byte[] acceptSecContext(InputStream inputStream, int i) throws GSSException {
+        checkLife();
+        try {
+            if (inputStream.available() == 0) {
+                there = new GSSUPAnonUserName();
+                protReady = true;
+                return null;
+            }
+
+            InitialContextToken token = new InitialContextToken();
+            byte[] buf = new byte[2048];
+            inputStream.read(buf, 0, buf.length);
+
+            Util.decodeGSSUPToken(Util.getCodec(), buf, token);
+
+            LoginContext context = new LoginContext(Util.decodeGSSExportName(token.target_name),
+                                                    new UsernamePasswordCallback(new String(token.username, "UTF-8"),
+                                                                                 new String(token.password, "UTF-8").toCharArray()));
+            context.login();
+
+            there = new GSSUPUserName(token.username);
+
+            protReady = true;
+            return null;
+        } catch (IOException e) {
+            throw new GSSException(GSSException.DEFECTIVE_TOKEN);
+        } catch (LoginException e) {
+            throw new GSSException(GSSException.DEFECTIVE_CREDENTIAL);
+        }
+    }
+
+    public byte[] initSecContext(InputStream inputStream, int i) throws GSSException {
+        checkLife();
+
+        protReady = true;
+
+        if (credential == null) return new byte[0];
+        //TODO there isn't a domain apparently available in this class, so its' hard to see how to construct a full scoped username
+        String scopedUsername = Util.buildScopedUserName(credential.getUsername(), null);
+        return Util.encodeGSSUPToken(Util.getORB(), Util.getCodec(), scopedUsername, new String(credential.getPassword()), "GSSUP-REALM");
+    }
+
+    public Provider getProvider() {
+        return GSSUPMechanismFactory.PROVIDER;
+    }
+
+    public void setChannelBinding(ChannelBinding channelBinding) {
+    }
+
+    public byte[] getMIC(byte[] bytes, int offset, int len, MessageProp messageProp) throws GSSException {
+        checkLife();
+        return new byte[0];
+    }
+
+    public byte[] unwrap(byte[] bytes, int offset, int len, MessageProp messageProp) throws GSSException {
+        checkLife();
+        byte[] result = new byte[len];
+
+        System.arraycopy(bytes, offset, result, 0, len);
+
+        return result;
+    }
+
+    public byte[] wrap(byte[] bytes, int offset, int len, MessageProp messageProp) throws GSSException {
+        checkLife();
+        byte[] result = new byte[len];
+
+        System.arraycopy(bytes, offset, result, 0, len);
+
+        return result;
+    }
+
+    public void verifyMIC(byte[] inTok, int tokOffset, int tokLen, byte[] inNsg, int msgOffset, int msgLen, MessageProp messageProp) throws GSSException {
+        checkLife();
+    }
+
+    public int unwrap(byte inBuf[], int inOffset, int len, byte[] outBuf, int outOffset, MessageProp messageProp) throws GSSException {
+        checkLife();
+
+        System.arraycopy(inBuf, inOffset, outBuf, outOffset, len);
+
+        return len;
+    }
+
+    public int wrap(byte inBuf[], int inOffset, int len, byte[] outBuf, int outOffset, MessageProp messageProp) throws GSSException {
+        checkLife();
+
+        System.arraycopy(inBuf, inOffset, outBuf, outOffset, len);
+
+        return len;
+    }
+
+    public Oid getMech() {
+        return GSSUPMechanismFactory.MECHANISM_OID;
+    }
+
+    public GSSCredentialSpi getDelegCred() throws GSSException {
+        if (!this.isProtReady()) throw new GSSException(GSSException.NO_CONTEXT);
+        throw new GSSException(GSSException.NO_CRED);
+    }
+
+    public GSSNameSpi getSrcName() throws GSSException {
+        if (!this.isProtReady()) throw new GSSException(GSSException.NO_CONTEXT);
+        return there;
+    }
+
+    public GSSNameSpi getTargName() throws GSSException {
+        if (!this.isProtReady()) throw new GSSException(GSSException.NO_CONTEXT);
+        return here;
+    }
+
+    public int unwrap(InputStream inputStream, byte[] outBuf, int outOffset, MessageProp messageProp) throws GSSException {
+        checkLife();
+
+        int count = 0;
+        int offset = outOffset;
+        try {
+            byte[] buf = new byte[1024];
+            while (true) {
+                int read = inputStream.read(buf);
+                if (read == -1) return count;
+
+                System.arraycopy(buf, 0, outBuf, offset, read);
+                count += read;
+            }
+        } catch (IndexOutOfBoundsException e) {
+            throw new GSSException(GSSException.FAILURE);
+        } catch (IOException e) {
+            throw new GSSException(GSSException.FAILURE);
+        }
+    }
+
+    public void wrap(byte inBuf[], int offset, int len, OutputStream outputStream, MessageProp messageProp) throws GSSException {
+        checkLife();
+        try {
+            outputStream.write(inBuf, offset, len);
+        } catch (IOException e) {
+            throw new GSSException(GSSException.FAILURE);
+        }
+    }
+
+    public void verifyMIC(InputStream inputStream, InputStream inputStream1, MessageProp messageProp) throws GSSException {
+        checkLife();
+    }
+
+    public void getMIC(InputStream inputStream, OutputStream outputStream, MessageProp messageProp) throws GSSException {
+        checkLife();
+    }
+
+    public void unwrap(InputStream inputStream, OutputStream outputStream, MessageProp messageProp) throws GSSException {
+        checkLife();
+        try {
+            byte[] buf = new byte[1024];
+            while (true) {
+                int read = inputStream.read(buf);
+                if (read == -1) return;
+
+                outputStream.write(buf, 0, read);
+            }
+        } catch (IOException e) {
+            throw new GSSException(GSSException.FAILURE);
+        }
+    }
+
+    public void wrap(InputStream inputStream, OutputStream outputStream, MessageProp messageProp) throws GSSException {
+        checkLife();
+        try {
+            byte[] buf = new byte[1024];
+            while (true) {
+                int read = inputStream.read(buf);
+                if (read == -1) return;
+
+                outputStream.write(buf, 0, read);
+            }
+        } catch (IOException e) {
+            throw new GSSException(GSSException.FAILURE);
+        }
+    }
+
+    private void checkLife() throws GSSException {
+        if (end < System.currentTimeMillis()) throw new GSSException(GSSException.CONTEXT_EXPIRED);
+    }
+
+    static GSSUPContext importGSSUPContext(byte[] exportedContext) throws GSSException {
+        try {
+
+            ByteArrayInputStream bin = new ByteArrayInputStream(exportedContext);
+            DataInputStream in = new DataInputStream(bin);
+
+            GSSUPContext result = new GSSUPContext();
+
+            result.lifetime = in.readInt();
+            result.anonymity = in.readBoolean();
+            result.conf = in.readBoolean();
+            result.credDeleg = in.readBoolean();
+            result.integState = in.readBoolean();
+            result.mutualAuth = in.readBoolean();
+            result.replayDet = in.readBoolean();
+            result.sequenceDet = in.readBoolean();
+
+            result.protReady = true;
+
+            return result;
+        } catch (IOException e) {
+            throw new GSSException(GSSException.FAILURE);
+        }
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPCredential.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPCredential.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPCredential.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPCredential.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.jgss;
+
+import java.security.AccessControlContext;
+import java.security.AccessController;
+import java.security.Provider;
+
+import org.ietf.jgss.GSSCredential;
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.Oid;
+import sun.security.jgss.spi.GSSCredentialSpi;
+import sun.security.jgss.spi.GSSNameSpi;
+
+import org.apache.geronimo.security.jaas.UsernamePasswordCredential;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class GSSUPCredential implements GSSCredentialSpi {
+
+    private GSSNameSpi name;
+    private int initLifetime;
+    private int acceptLifetime;
+    private int usage;
+    private UsernamePasswordCredential credential;
+
+    GSSUPCredential(GSSNameSpi name, int initLifetime, int acceptLifetime, int usage) {
+        this.name = name;
+        this.initLifetime = initLifetime;
+        this.acceptLifetime = acceptLifetime;
+        this.usage = usage;
+
+        if (isInitiatorCredential()) {
+            AccessControlContext acc = AccessController.getContext();
+            credential = (UsernamePasswordCredential) AccessController.doPrivileged(new SubjectComber(acc, name.toString()));
+        }
+    }
+
+    public UsernamePasswordCredential getCredential() {
+        return credential;
+    }
+
+    public int getAcceptLifetime() throws GSSException {
+        return acceptLifetime;
+    }
+
+    public int getInitLifetime() throws GSSException {
+        return initLifetime;
+    }
+
+    public void dispose() throws GSSException {
+        credential = null;
+    }
+
+    public boolean isAcceptorCredential() {
+        return usage == GSSCredential.ACCEPT_ONLY || usage == GSSCredential.INITIATE_AND_ACCEPT;
+    }
+
+    public boolean isInitiatorCredential() {
+        return usage == GSSCredential.INITIATE_ONLY || usage == GSSCredential.INITIATE_AND_ACCEPT;
+    }
+
+    public Provider getProvider() {
+        return GSSUPMechanismFactory.PROVIDER;
+    }
+
+    public Oid getMechanism() {
+        return GSSUPMechanismFactory.MECHANISM_OID;
+    }
+
+    public GSSNameSpi getName() throws GSSException {
+        return name;
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPMechanismFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPMechanismFactory.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPMechanismFactory.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPMechanismFactory.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,104 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.jgss;
+
+import java.security.Provider;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.ietf.jgss.GSSCredential;
+import org.ietf.jgss.GSSException;
+import org.ietf.jgss.GSSName;
+import org.ietf.jgss.Oid;
+import sun.security.jgss.spi.GSSContextSpi;
+import sun.security.jgss.spi.GSSCredentialSpi;
+import sun.security.jgss.spi.GSSNameSpi;
+import sun.security.jgss.spi.MechanismFactory;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public final class GSSUPMechanismFactory implements MechanismFactory {
+
+    private final static Log log = LogFactory.getLog(GSSUPMechanismFactory.class);
+
+    final static Oid MECHANISM_OID;
+    private final static Oid[] NAME_TYPES = new Oid[]{GSSName.NT_HOSTBASED_SERVICE, GSSName.NT_USER_NAME};
+    final static Provider PROVIDER;
+
+    public Provider getProvider() {
+        return PROVIDER;
+    }
+
+    public Oid getMechanismOid() {
+        return MECHANISM_OID;
+    }
+
+    public Oid[] getNameTypes() {
+        return NAME_TYPES;
+    }
+
+    public GSSContextSpi getMechanismContext(byte[] exportedContext) throws GSSException {
+        return GSSUPContext.importGSSUPContext(exportedContext);
+    }
+
+    public GSSContextSpi getMechanismContext(GSSCredentialSpi myAcceptorCred) throws GSSException {
+        return new GSSUPContext(myAcceptorCred);
+    }
+
+    public GSSCredentialSpi getCredentialElement(GSSNameSpi name, int initLifetime, int acceptLifetime, int usage) {
+        if (name == null) {
+            if (usage == GSSCredential.INITIATE_ONLY || usage == GSSCredential.INITIATE_AND_ACCEPT) {
+                name = new GSSUPAnonUserName();
+            } else {
+                name = new GSSUPAnonServerName();
+            }
+        }
+        return new GSSUPCredential(name, initLifetime, acceptLifetime, usage);
+    }
+
+    public GSSNameSpi getNameElement(byte[] name, Oid nameType) throws GSSException {
+        if (nameType.equals(GSSName.NT_HOSTBASED_SERVICE)) {
+            return new GSSUPServerName(name);
+        } else if (nameType.equals(GSSName.NT_USER_NAME)) {
+            return new GSSUPUserName(name);
+        }
+        throw new GSSException(GSSException.BAD_NAMETYPE, -1, nameType.toString() + " is an unsupported nametype");
+    }
+
+    public GSSContextSpi getMechanismContext(GSSNameSpi peer, GSSCredentialSpi myInitiatorCred, int lifetime) {
+        return new GSSUPContext(peer, myInitiatorCred, lifetime);
+    }
+
+    public GSSNameSpi getNameElement(String nameStr, Oid nameType) throws GSSException {
+        return getNameElement(nameStr.getBytes(), nameType);
+    }
+
+    static {
+        Oid tempOID = null;
+        try {
+            tempOID = new Oid("2.23.130.1.1.1");
+        } catch (GSSException e) {
+            log.fatal("Unable to initialize mechanisms OID: " + e);
+        }
+        MECHANISM_OID = tempOID;
+
+        PROVIDER = new GSSUPProvider();
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPProvider.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPProvider.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPProvider.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPProvider.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.jgss;
+
+import java.security.Provider;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class GSSUPProvider extends Provider {
+
+    public GSSUPProvider() {
+        super("GSSUP", 1.0, "OpenEJB GSSUP provider v1.0");
+        put("GssApiMechanism.2.23.130.1.1.1", "org.apache.geronimo.corba.security.jgss.GSSUPMechanismFactory");
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPServerName.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPServerName.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPServerName.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPServerName.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.jgss;
+
+import java.security.Provider;
+
+import org.ietf.jgss.GSSName;
+import org.ietf.jgss.Oid;
+import sun.security.jgss.spi.GSSNameSpi;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public final class GSSUPServerName implements GSSNameSpi {
+    private final byte[] name;
+
+    GSSUPServerName(byte[] name) {
+        this.name = name;
+    }
+
+    public boolean isAnonymousName() {
+        return false;
+    }
+
+    public byte[] export() {
+        byte[] result = new byte[name.length];
+
+        System.arraycopy(name, 0, result, 0, name.length);
+
+        return result;
+    }
+
+    public Provider getProvider() {
+        return GSSUPMechanismFactory.PROVIDER;
+    }
+
+    public Oid getMechanism() {
+        return GSSUPMechanismFactory.MECHANISM_OID;
+    }
+
+    public Oid getStringNameType() {
+        return GSSName.NT_HOSTBASED_SERVICE;
+    }
+
+    public boolean equals(GSSNameSpi obj) {
+        if (obj == null) return false;
+        if (!(obj instanceof GSSUPServerName)) return false;
+
+        GSSUPServerName test = (GSSUPServerName) obj;
+        for (int i = 0; i < name.length; i++) {
+            if (name[i] != test.name[i]) return false;
+        }
+        return true;
+    }
+
+    public String toString() {
+        return new String(name);
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPUserName.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPUserName.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPUserName.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/GSSUPUserName.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,74 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.jgss;
+
+import java.security.Provider;
+
+import org.ietf.jgss.GSSName;
+import org.ietf.jgss.Oid;
+import sun.security.jgss.spi.GSSNameSpi;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public final class GSSUPUserName implements GSSNameSpi {
+    private final byte[] name;
+
+    GSSUPUserName(byte[] name) {
+        this.name = name;
+    }
+
+    public boolean isAnonymousName() {
+        return false;
+    }
+
+    public byte[] export() {
+        byte[] result = new byte[name.length];
+
+        System.arraycopy(name, 0, result, 0, name.length);
+
+        return result;
+    }
+
+    public Provider getProvider() {
+        return GSSUPMechanismFactory.PROVIDER;
+    }
+
+    public Oid getMechanism() {
+        return GSSUPMechanismFactory.MECHANISM_OID;
+    }
+
+    public Oid getStringNameType() {
+        return GSSName.NT_USER_NAME;
+    }
+
+    public boolean equals(GSSNameSpi obj) {
+        if (obj == null) return false;
+        if (!(obj instanceof GSSUPUserName)) return false;
+
+        GSSUPUserName test = (GSSUPUserName) obj;
+        for (int i = 0; i < name.length; i++) {
+            if (name[i] != test.name[i]) return false;
+        }
+        return true;
+    }
+
+    public String toString() {
+        return new String(name);
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/SubjectComber.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/SubjectComber.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/SubjectComber.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/jgss/SubjectComber.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.jgss;
+
+import java.security.AccessControlContext;
+import java.security.PrivilegedAction;
+import java.util.Iterator;
+import javax.security.auth.Subject;
+
+import org.apache.geronimo.security.jaas.UsernamePasswordCredential;
+
+
+/**
+ * A privileged action that hunts down username/password private credentials
+ * with a given username.
+ *
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+class SubjectComber implements PrivilegedAction {
+
+    private AccessControlContext acc;
+    private final String username;
+    private Subject subject;
+
+    public SubjectComber(AccessControlContext acc, String username) {
+        this.acc = acc;
+        this.username = username;
+    }
+
+    public SubjectComber(Subject subject, String username) {
+        this.subject = subject;
+        this.username = username;
+    }
+
+    public Object run() {
+        if (subject == null) subject = Subject.getSubject(acc);
+
+        if (subject != null) {
+            Iterator iterator = subject.getPrivateCredentials(UsernamePasswordCredential.class).iterator();
+            while (iterator.hasNext()) {
+                UsernamePasswordCredential key = (UsernamePasswordCredential) iterator.next();
+                if (username == null || username.equals(key.getUsername())) {
+                    return key;
+                }
+            }
+
+        }
+        return null;
+    }
+
+}
+
+

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/wrappers/EstablishContextWrapper.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/wrappers/EstablishContextWrapper.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/wrappers/EstablishContextWrapper.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/security/wrappers/EstablishContextWrapper.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.security.wrappers;
+
+import org.omg.CSI.EstablishContext;
+import org.omg.CSI.IdentityToken;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class EstablishContextWrapper {
+
+    private final EstablishContext establishMsg;
+    private final IdentityToken identity_token;
+
+    public EstablishContextWrapper(EstablishContext establishMsg) {
+        this.establishMsg = establishMsg;
+        this.identity_token = establishMsg.identity_token;
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/AbstractServerTransactionPolicyConfig.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/AbstractServerTransactionPolicyConfig.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/AbstractServerTransactionPolicyConfig.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/AbstractServerTransactionPolicyConfig.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,70 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.INTERNAL;
+import org.omg.CORBA.SystemException;
+import org.omg.CosTransactions.PropagationContext;
+import org.omg.CosTransactions.PropagationContextHelper;
+import org.omg.IOP.Codec;
+import org.omg.IOP.CodecPackage.FormatMismatch;
+import org.omg.IOP.CodecPackage.TypeMismatch;
+import org.omg.IOP.ServiceContext;
+import org.omg.IOP.TransactionService;
+import org.omg.PortableInterceptor.ServerRequestInfo;
+import org.apache.geronimo.corba.util.Util;
+
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public abstract class AbstractServerTransactionPolicyConfig implements ServerTransactionPolicyConfig {
+
+    public void importTransaction(ServerRequestInfo serverRequestInfo) throws SystemException {
+        ServiceContext serviceContext = null;
+        try {
+            serviceContext = serverRequestInfo.get_request_service_context(TransactionService.value);
+        } catch (BAD_PARAM e) {
+            // do nothing
+        }
+        PropagationContext propagationContext;
+        if (serviceContext == null) {
+            propagationContext = null;
+        } else {
+            byte[] encoded = serviceContext.context_data;
+            Codec codec = Util.getCodec();
+            Any any;
+            try {
+                any = codec.decode_value(encoded, PropagationContextHelper.type());
+            } catch (FormatMismatch formatMismatch) {
+                throw (INTERNAL) new INTERNAL("Could not decode encoded propagation context").initCause(formatMismatch);
+            } catch (TypeMismatch typeMismatch) {
+                throw (INTERNAL) new INTERNAL("Could not decode encoded propagation context").initCause(typeMismatch);
+            }
+            propagationContext = PropagationContextHelper.extract(any);
+        }
+        //figure out what method is being invoked
+        //operation name is unique... it contains the mangled operation name + arg types.
+        String operation = serverRequestInfo.operation();
+        importTransaction(operation, propagationContext);
+    }
+
+    protected abstract void importTransaction(String operation, PropagationContext propagationContext) throws SystemException;
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionInterceptor.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionInterceptor.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionInterceptor.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,119 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.BAD_PARAM;
+import org.omg.CORBA.INTERNAL;
+import org.omg.CORBA.LocalObject;
+import org.omg.IOP.CodecPackage.FormatMismatch;
+import org.omg.IOP.CodecPackage.TypeMismatch;
+import org.omg.IOP.TaggedComponent;
+import org.omg.PortableInterceptor.ClientRequestInfo;
+import org.omg.PortableInterceptor.ClientRequestInterceptor;
+import org.omg.PortableInterceptor.ForwardRequest;
+import org.omg.CosTSInteroperation.TAG_OTS_POLICY;
+import org.omg.CosTransactions.OTSPolicyValueHelper;
+import org.omg.CosTransactions.ADAPTS;
+
+import org.apache.geronimo.corba.util.Util;
+import org.apache.geronimo.corba.util.TypeCode;
+
+
+/**
+ * @version $Revision: 502396 $ $Date: 2007-02-01 15:06:06 -0800 (Thu, 01 Feb 2007) $
+ */
+class ClientTransactionInterceptor extends LocalObject implements ClientRequestInterceptor {
+
+    private final Log log = LogFactory.getLog(ClientTransactionInterceptor.class);
+
+    public ClientTransactionInterceptor() {
+        if (log.isDebugEnabled()) log.debug("Registered");
+    }
+
+    public void receive_exception(ClientRequestInfo ri) throws ForwardRequest {
+    }
+
+    public void receive_other(ClientRequestInfo ri) throws ForwardRequest {
+    }
+
+    public void receive_reply(ClientRequestInfo ri) {
+    }
+
+    public void send_poll(ClientRequestInfo ri) {
+    }
+
+    public void send_request(ClientRequestInfo ri) throws ForwardRequest {
+        TaggedComponent taggedComponent = null;
+        try {
+            if (log.isDebugEnabled()) log.debug("Checking if target " + ri.operation() + " has a transaction policy");
+
+            taggedComponent = ri.get_effective_component(TAG_OTS_POLICY.value);
+        } catch (BAD_PARAM e) {
+            return;
+        }
+
+        if (log.isDebugEnabled()) log.debug("Target has a transaction policy");
+
+        byte[] data = taggedComponent.component_data;
+        Any any = null;
+        try {
+            any = Util.getCodec().decode_value(data, TypeCode.SHORT);
+        } catch (FormatMismatch formatMismatch) {
+            log.error("Mismatched format", formatMismatch);
+            throw (INTERNAL) new INTERNAL("Mismatched format").initCause(formatMismatch);
+        } catch (TypeMismatch typeMismatch) {
+            log.error("Type mismatch", typeMismatch);
+            throw (INTERNAL) new INTERNAL("Type mismatch").initCause(typeMismatch);
+        }
+
+        short value = OTSPolicyValueHelper.extract(any);
+        if (value == ADAPTS.value) {
+            ClientTransactionPolicy clientTransactionPolicy = (ClientTransactionPolicy) ri.get_request_policy(ClientTransactionPolicyFactory.POLICY_TYPE);
+            if (clientTransactionPolicy == null) {
+                return; 
+            }
+            ClientTransactionPolicyConfig clientTransactionPolicyConfig = clientTransactionPolicy.getClientTransactionPolicyConfig();
+            if (clientTransactionPolicyConfig == null) return;
+
+            if (log.isDebugEnabled()) log.debug("Client has a transaction policy");
+
+            clientTransactionPolicyConfig.exportTransaction(ri);
+        }
+    }
+
+    public void destroy() {
+    }
+
+    /**
+     * Returns the name of the interceptor.
+     * <p/>
+     * Each Interceptor may have a name that may be used administratively
+     * to order the lists of Interceptors. Only one Interceptor of a given
+     * name can be registered with the ORB for each Interceptor type. An
+     * Interceptor may be anonymous, i.e., have an empty string as the name
+     * attribute. Any number of anonymous Interceptors may be registered with
+     * the ORB.
+     *
+     * @return the name of the interceptor.
+     */
+    public String name() {
+        return "org.apache.geronimo.corba.transaction.ClientTransactionInterceptor";
+    }
+}
\ No newline at end of file

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicy.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicy.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicy.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.Policy;
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class ClientTransactionPolicy extends LocalObject implements Policy {
+
+    private final ClientTransactionPolicyConfig clientTransactionPolicyConfig;
+
+    public ClientTransactionPolicy(ClientTransactionPolicyConfig clientTransactionPolicyConfig) {
+        this.clientTransactionPolicyConfig = clientTransactionPolicyConfig;
+    }
+
+
+    public int policy_type() {
+        return ClientTransactionPolicyFactory.POLICY_TYPE;
+    }
+
+    public Policy copy() {
+        return new ClientTransactionPolicy(clientTransactionPolicyConfig);
+    }
+
+    public void destroy() {
+
+    }
+
+    ClientTransactionPolicyConfig getClientTransactionPolicyConfig() {
+        return clientTransactionPolicyConfig;
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicyConfig.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicyConfig.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicyConfig.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicyConfig.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,28 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import java.io.Serializable;
+
+import org.omg.PortableInterceptor.ClientRequestInfo;
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public interface ClientTransactionPolicyConfig extends Serializable {
+    void exportTransaction(ClientRequestInfo ri);
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicyFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicyFactory.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicyFactory.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ClientTransactionPolicyFactory.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.PolicyError;
+import org.omg.PortableInterceptor.PolicyFactory;
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class ClientTransactionPolicyFactory extends LocalObject implements PolicyFactory {
+    public final static int POLICY_TYPE = 0x41534603;
+
+    public Policy create_policy(int type, Any value) throws PolicyError {
+        if (type != POLICY_TYPE){
+            throw new PolicyError();
+        }
+        return new ClientTransactionPolicy(((ClientTransactionPolicyConfig)value.extract_Value()));
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/IORTransactionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/IORTransactionInterceptor.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/IORTransactionInterceptor.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/IORTransactionInterceptor.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,71 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA.Any;
+import org.omg.CORBA.INV_POLICY;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.ORB;
+import org.omg.CosTSInteroperation.TAG_INV_POLICY;
+import org.omg.CosTransactions.ADAPTS;
+import org.omg.CosTransactions.SHARED;
+import org.omg.IOP.TAG_INTERNET_IOP;
+import org.omg.IOP.TAG_OTS_POLICY;
+import org.omg.IOP.TaggedComponent;
+import org.omg.PortableInterceptor.IORInfo;
+import org.omg.PortableInterceptor.IORInterceptor;
+import org.apache.geronimo.corba.util.Util;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+final class IORTransactionInterceptor extends LocalObject implements IORInterceptor {
+
+    private final Log log = LogFactory.getLog(IORTransactionInterceptor.class);
+
+    public void establish_components(IORInfo info) {
+
+        try {
+            Any invAny = ORB.init().create_any();
+            invAny.insert_short(SHARED.value);
+            byte[] invBytes = Util.getCodec().encode_value(invAny);
+            TaggedComponent invocationPolicyComponent = new TaggedComponent(TAG_INV_POLICY.value, invBytes);
+            info.add_ior_component_to_profile(invocationPolicyComponent, TAG_INTERNET_IOP.value);
+
+            Any otsAny = ORB.init().create_any();
+            otsAny.insert_short(ADAPTS.value);
+            byte[] otsBytes = Util.getCodec().encode_value(otsAny);
+            TaggedComponent otsPolicyComponent = new TaggedComponent(TAG_OTS_POLICY.value, otsBytes);
+            info.add_ior_component_to_profile(otsPolicyComponent, TAG_INTERNET_IOP.value);
+        } catch (INV_POLICY e) {
+            // do nothing
+        } catch (Exception e) {
+            log.error("Generating IOR", e);
+        }
+    }
+
+    public void destroy() {
+    }
+
+    public String name() {
+        return "org.apache.geronimo.corba.transaction.IORTransactionInterceptor";
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/MappedServerTransactionPolicyConfig.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/MappedServerTransactionPolicyConfig.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/MappedServerTransactionPolicyConfig.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/MappedServerTransactionPolicyConfig.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,47 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA.SystemException;
+import org.omg.CosTransactions.PropagationContext;
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class MappedServerTransactionPolicyConfig extends AbstractServerTransactionPolicyConfig {
+    private static Log log = LogFactory.getLog(MappedServerTransactionPolicyConfig.class);
+    private final Map operationToPolicyMap;
+    public MappedServerTransactionPolicyConfig(Map operationToPolicyMap) {
+        this.operationToPolicyMap = operationToPolicyMap;
+    }
+
+    protected void importTransaction(String operation, PropagationContext propagationContext) throws SystemException {
+        OperationTxPolicy operationTxPolicy = (OperationTxPolicy) operationToPolicyMap.get(operation);
+        if (operationTxPolicy == null) {
+            //TODO figure out if there is some way to detect if the method should be mapped or shouldn't
+            //e.g. _is_a shows up but should not be mapped.
+            log.info("No tx mapping for operation: " + operation);
+            return;
+        }
+        operationTxPolicy.importTransaction(propagationContext);
+     }
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/OperationTxPolicy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/OperationTxPolicy.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/OperationTxPolicy.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/OperationTxPolicy.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,27 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.omg.CosTransactions.PropagationContext;
+
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public interface OperationTxPolicy {
+    void importTransaction(PropagationContext propagationContext);
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionInterceptor.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionInterceptor.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionInterceptor.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionInterceptor.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,73 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.PortableInterceptor.ForwardRequest;
+import org.omg.PortableInterceptor.ServerRequestInfo;
+import org.omg.PortableInterceptor.ServerRequestInterceptor;
+
+/**
+ * @version $Revision: 476527 $ $Date: 2006-11-18 06:22:47 -0800 (Sat, 18 Nov 2006) $
+ */
+class ServerTransactionInterceptor extends LocalObject implements ServerRequestInterceptor {
+
+    public ServerTransactionInterceptor() {
+    }
+
+    public void receive_request(ServerRequestInfo serverRequestInfo) throws ForwardRequest {
+       ServerTransactionPolicy policy = (ServerTransactionPolicy) serverRequestInfo.get_server_policy(ServerTransactionPolicyFactory.POLICY_TYPE);
+       // it's possible for applications to obtain the orb instance using "java:comp/ORB" and then
+       // use the rootPOA to activate an object.  If that happens, then we're not going to see a
+       // transaction policy on the request.  Just ignore any request that doesn't have one.
+        if (policy != null) {
+            ServerTransactionPolicyConfig serverTransactionPolicyConfig = policy.getServerTransactionPolicyConfig();
+            serverTransactionPolicyConfig.importTransaction(serverRequestInfo);
+        }
+    }
+
+    public void receive_request_service_contexts(ServerRequestInfo ri) throws ForwardRequest {
+    }
+
+    public void send_exception(ServerRequestInfo ri) throws ForwardRequest {
+    }
+
+    public void send_other(ServerRequestInfo ri) throws ForwardRequest {
+    }
+
+    public void send_reply(ServerRequestInfo ri) {
+    }
+
+    public void destroy() {
+    }
+
+    /**
+     * Returns the name of the interceptor.
+     * <p/>
+     * Each Interceptor may have a name that may be used administratively
+     * to order the lists of Interceptors. Only one Interceptor of a given
+     * name can be registered with the ORB for each Interceptor type. An
+     * Interceptor may be anonymous, i.e., have an empty string as the name
+     * attribute. Any number of anonymous Interceptors may be registered with
+     * the ORB.
+     *
+     * @return the name of the interceptor.
+     */
+    public String name() {
+        return "org.apache.geronimo.corba.transaction.ServerTransactionInterceptor";
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicy.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicy.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicy.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicy.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.Policy;
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class ServerTransactionPolicy extends LocalObject implements Policy {
+
+    private final ServerTransactionPolicyConfig serverTransactionPolicyConfig;
+
+    public ServerTransactionPolicy(ServerTransactionPolicyConfig serverTransactionPolicyConfig) {
+        this.serverTransactionPolicyConfig = serverTransactionPolicyConfig;
+    }
+
+
+    public int policy_type() {
+        return ServerTransactionPolicyFactory.POLICY_TYPE;
+    }
+
+    public Policy copy() {
+        return new ServerTransactionPolicy(serverTransactionPolicyConfig);
+    }
+
+    public void destroy() {
+
+    }
+
+    ServerTransactionPolicyConfig getServerTransactionPolicyConfig() {
+        return serverTransactionPolicyConfig;
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicyConfig.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicyConfig.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicyConfig.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicyConfig.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import java.io.Serializable;
+
+import org.omg.CORBA.SystemException;
+import org.omg.PortableInterceptor.ServerRequestInfo;
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public interface ServerTransactionPolicyConfig extends Serializable {
+
+    void importTransaction(ServerRequestInfo serverRequestInfo) throws SystemException;
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicyFactory.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicyFactory.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicyFactory.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/ServerTransactionPolicyFactory.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,37 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.LocalObject;
+import org.omg.CORBA.Policy;
+import org.omg.CORBA.PolicyError;
+import org.omg.PortableInterceptor.PolicyFactory;
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class ServerTransactionPolicyFactory extends LocalObject implements PolicyFactory {
+    public final static int POLICY_TYPE = 0x41534602;
+
+    public Policy create_policy(int type, Any value) throws PolicyError {
+        if (type != POLICY_TYPE){
+            throw new PolicyError();
+        }
+        return new ServerTransactionPolicy((ServerTransactionPolicyConfig) value.extract_Value());
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/TransactionInitializer.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/TransactionInitializer.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/TransactionInitializer.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/TransactionInitializer.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.omg.CORBA.LocalObject;
+import org.omg.PortableInterceptor.ORBInitInfo;
+import org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName;
+import org.omg.PortableInterceptor.ORBInitializer;
+
+
+/**
+ * @version $Revision: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class TransactionInitializer extends LocalObject implements ORBInitializer {
+
+    private final Log log = LogFactory.getLog(TransactionInitializer.class);
+
+    public TransactionInitializer() {
+        if (log.isDebugEnabled()) log.debug("TransactionInitializer.<init>");
+    }
+
+    /**
+     * Called during ORB initialization.  If it is expected that initial
+     * services registered by an interceptor will be used by other
+     * interceptors, then those initial services shall be registered at
+     * this point via calls to
+     * <code>ORBInitInfo.register_initial_reference</code>.
+     *
+     * @param orbInitInfo provides initialization attributes and operations by
+     *                    which Interceptors can be registered.
+     */
+    public void pre_init(ORBInitInfo orbInitInfo) {
+
+    }
+
+    /**
+     * Called during ORB initialization. If a service must resolve initial
+     * references as part of its initialization, it can assume that all
+     * initial references will be available at this point.
+     * <p/>
+     * Calling the <code>post_init</code> operations is not the final
+     * task of ORB initialization. The final task, following the
+     * <code>post_init</code> calls, is attaching the lists of registered
+     * interceptors to the ORB. Therefore, the ORB does not contain the
+     * interceptors during calls to <code>post_init</code>. If an
+     * ORB-mediated call is made from within <code>post_init</code>, no
+     * request interceptors will be invoked on that call.
+     * Likewise, if an operation is performed which causes an IOR to be
+     * created, no IOR interceptors will be invoked.
+     *
+     * @param orbInitInfo provides initialization attributes and
+     *                    operations by which Interceptors can be registered.
+     */
+    public void post_init(ORBInitInfo orbInitInfo) {
+        try {
+            if (log.isDebugEnabled()) log.debug("Registering interceptors and policy factories");
+
+            try {
+                orbInitInfo.add_client_request_interceptor(new ClientTransactionInterceptor());
+                orbInitInfo.add_server_request_interceptor(new ServerTransactionInterceptor());
+                orbInitInfo.add_ior_interceptor(new IORTransactionInterceptor());
+            } catch (DuplicateName duplicateName) {
+                log.error("Duplicate name", duplicateName);
+            }
+
+            orbInitInfo.register_policy_factory(ClientTransactionPolicyFactory.POLICY_TYPE, new ClientTransactionPolicyFactory());
+            orbInitInfo.register_policy_factory(ServerTransactionPolicyFactory.POLICY_TYPE, new ServerTransactionPolicyFactory());
+        } catch (RuntimeException re) {
+            log.error("Error registering interceptor", re);
+            throw re;
+        }
+    }
+
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/Ignore.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/Ignore.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/Ignore.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/Ignore.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,38 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction.nodistributedtransactions;
+
+import java.io.Serializable;
+
+import org.apache.geronimo.corba.transaction.OperationTxPolicy;
+import org.omg.CosTransactions.PropagationContext;
+
+/**
+ * Use for:
+ * RequiresNew
+ * NotSupported
+ * Bean (? client should not send a PropagationContext)
+ *
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class Ignore implements OperationTxPolicy, Serializable {
+
+    public static final OperationTxPolicy INSTANCE = new Ignore();
+
+    public void importTransaction(PropagationContext propagationContext) {
+    }
+}

Added: geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NoDTxClientTransactionPolicyConfig.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NoDTxClientTransactionPolicyConfig.java?view=auto&rev=505432
==============================================================================
--- geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NoDTxClientTransactionPolicyConfig.java (added)
+++ geronimo/server/trunk/modules/geronimo-corba/src/main/java/org/apache/geronimo/corba/transaction/nodistributedtransactions/NoDTxClientTransactionPolicyConfig.java Fri Feb  9 11:24:30 2007
@@ -0,0 +1,75 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.geronimo.corba.transaction.nodistributedtransactions;
+
+import javax.transaction.TransactionManager;
+
+import org.omg.CORBA.Any;
+import org.omg.CORBA.INTERNAL;
+import org.omg.CosTransactions.PropagationContext;
+import org.omg.CosTransactions.PropagationContextHelper;
+import org.omg.CosTransactions.TransIdentity;
+import org.omg.CosTransactions.otid_t;
+import org.omg.IOP.Codec;
+import org.omg.IOP.CodecPackage.InvalidTypeForEncoding;
+import org.omg.IOP.ServiceContext;
+import org.omg.IOP.TransactionService;
+import org.omg.PortableInterceptor.ClientRequestInfo;
+import org.apache.geronimo.corba.transaction.ClientTransactionPolicyConfig;
+import org.apache.geronimo.corba.util.Util;
+import org.apache.openejb.util.TransactionUtils;
+
+/**
+ * @version $Rev: 451417 $ $Date: 2006-09-29 13:13:22 -0700 (Fri, 29 Sep 2006) $
+ */
+public class NoDTxClientTransactionPolicyConfig implements ClientTransactionPolicyConfig {
+
+    private static final TransIdentity[] NO_PARENTS = new TransIdentity[0];
+    private static final otid_t NULL_XID = new otid_t(0, 0, new byte[0]);
+
+    private final TransactionManager transactionManager;
+
+    public NoDTxClientTransactionPolicyConfig(TransactionManager transactionManager) {
+        if (transactionManager == null) {
+            throw new IllegalArgumentException("transactionManager must not be null");
+        }
+        this.transactionManager = transactionManager;
+    }
+
+    public void exportTransaction(ClientRequestInfo ri) {
+        if (TransactionUtils.isTransactionActive(transactionManager)) {
+            //19.6.2.1 (1) propagate an "empty" transaction context.
+            //but, it needs an xid!
+            TransIdentity transIdentity = new TransIdentity(null, null, NULL_XID);
+            int timeout = 0;
+            Any implementationSpecificData = Util.getORB().create_any();
+            PropagationContext propagationContext = new PropagationContext(timeout, transIdentity, NO_PARENTS, implementationSpecificData);
+            Codec codec = Util.getCodec();
+            Any any = Util.getORB().create_any();
+            PropagationContextHelper.insert(any, propagationContext);
+            byte[] encodedPropagationContext;
+            try {
+                encodedPropagationContext = codec.encode_value(any);
+            } catch (InvalidTypeForEncoding invalidTypeForEncoding) {
+                throw (INTERNAL)new INTERNAL("Could not encode propagationContext").initCause(invalidTypeForEncoding);
+            }
+            ServiceContext otsServiceContext = new ServiceContext(TransactionService.value, encodedPropagationContext);
+            ri.add_request_service_context(otsServiceContext, true);
+        }
+
+    }
+}



Mime
View raw message