You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by dj...@apache.org on 2004/01/11 09:28:15 UTC

cvs commit: incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/connectiontracking ConnectionTrackingCoordinatorTest.java

djencks     2004/01/11 00:28:15

  Modified:    modules/core/src/java/org/apache/geronimo/connector/outbound
                        ConnectionManagerDeployment.java
                        ConnectionTrackingInterceptor.java
                        SubjectInterceptor.java
               modules/core/src/java/org/apache/geronimo/deployment/model/geronimo/connector
                        GeronimoConnectionDefinition.java
               modules/core/src/java/org/apache/geronimo/xml/deployment
                        GeronimoConnectorLoader.java
               modules/core/src/test/org/apache/geronimo/connector/outbound
                        ConnectionManagerTest.java
                        ConnectionManagerTestUtils.java
               modules/core/src/test/org/apache/geronimo/connector/outbound/connectiontracking
                        ConnectionTrackingCoordinatorTest.java
  Added:       modules/core/src/java/org/apache/geronimo/connector/outbound/security
                        PasswordCredentialLoginModule.java
                        PasswordCredentialRealm.java ResourcePrincipal.java
  Removed:     modules/core/src/java/org/apache/geronimo/connector/outbound
                        SecurityDomain.java SecurityDomainImpl.java
  Log:
  Convert from non-implemented SecurityDomain concept to RealmBridge concept
  
  Revision  Changes    Path
  1.8       +18 -15    incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionManagerDeployment.java
  
  Index: ConnectionManagerDeployment.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionManagerDeployment.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ConnectionManagerDeployment.java	28 Dec 2003 19:31:16 -0000	1.7
  +++ ConnectionManagerDeployment.java	11 Jan 2004 08:28:15 -0000	1.8
  @@ -70,6 +70,7 @@
   import org.apache.geronimo.kernel.service.GeronimoMBeanTarget;
   import org.apache.geronimo.kernel.service.GeronimoOperationInfo;
   import org.apache.geronimo.kernel.service.GeronimoParameterInfo;
  +import org.apache.geronimo.security.bridge.RealmBridge;
   
   /**
    * ConnectionManagerDeployment is an mbean that sets up a ProxyConnectionManager
  @@ -104,7 +105,7 @@
        */
       private String jndiName;
       //dependencies
  -    private SecurityDomain securityDomain;
  +    private RealmBridge realmBridge;
       private ConnectionTracker connectionTracker;
   
       //GeronimoMBeanTarget support.
  @@ -122,7 +123,7 @@
        boolean useTransactions,
        int maxSize,
        int blockingTimeout,
  -     SecurityDomain securityDomain,
  +     RealmBridge realmBridge,
        String jndiName,
        ConnectionTracker connectionTracker) {
           this.useConnectionRequestInfo = useConnectionRequestInfo;
  @@ -132,7 +133,7 @@
           this.useTransactions = useTransactions;
           this.maxSize = maxSize;
           this.blockingTimeout = blockingTimeout;
  -        this.securityDomain = securityDomain;
  +        this.realmBridge = realmBridge;
           this.jndiName = jndiName;
           this.connectionTracker = connectionTracker;
           setUpConnectionManager(null, null);
  @@ -166,14 +167,14 @@
        * ConnectionHandleInterceptor
        * TransactionCachingInterceptor (useTransactions & useTransactionCaching)
        * TransactionEnlistingInterceptor (useTransactions)
  -     * SubjectInterceptor (securityDomain != null)
  +     * SubjectInterceptor (realmBridge != null)
        * SinglePoolConnectionInterceptor or MultiPoolConnectionInterceptor
        * LocalXAResourceInsertionInterceptor or XAResourceInsertionInterceptor (useTransactions (&localTransactions))
        * MCFConnectionInterceptor
        */
       private void setUpConnectionManager(String agentID, ObjectName connectionManagerName) {
           //check for consistency between attributes
  -        if (securityDomain == null) {
  +        if (realmBridge == null) {
               assert useSubject == false: "To use Subject in pooling, you need a SecurityDomain";
           }
   
  @@ -201,8 +202,8 @@
                       maxSize,
                       blockingTimeout);
           }
  -        if (securityDomain != null) {
  -            stack = new SubjectInterceptor(stack, securityDomain);
  +        if (realmBridge != null) {
  +            stack = new SubjectInterceptor(stack, realmBridge);
           }
           if (useTransactions) {
               stack = new TransactionEnlistingInterceptor(stack);
  @@ -216,7 +217,7 @@
                       stack,
                       jndiName,
                       connectionTracker,
  -                    securityDomain);
  +                    realmBridge);
           }
   
           cm = new ProxyConnectionManager(agentID, connectionManagerName, stack);
  @@ -231,7 +232,7 @@
            */
       public void doStop() {
           cm = null;
  -        securityDomain = null;
  +        realmBridge = null;
           connectionTracker = null;
   
       }
  @@ -280,12 +281,12 @@
           this.maxSize = maxSize;
       }
   
  -    public SecurityDomain getSecurityDomain() {
  -        return securityDomain;
  +    public RealmBridge getRealmBridge() {
  +        return realmBridge;
       }
   
  -    public void setSecurityDomain(SecurityDomain securityDomain) {
  -        this.securityDomain = securityDomain;
  +    public void setRealmBridge(RealmBridge realmBridge) {
  +        this.realmBridge = realmBridge;
       }
   
       public boolean isUseConnectionRequestInfo() {
  @@ -313,6 +314,8 @@
           this.useLocalTransactions = useLocalTransactions;
       }
   
  +    //Even if realmBridge is present, if reauthentication is supported, you might not want to use
  +    //the subject as pooling crieteria.
       public boolean isUseSubject() {
           return useSubject;
       }
  @@ -334,7 +337,7 @@
   
           mBeanInfo.setTargetClass(ConnectionManagerDeployment.class);
           mBeanInfo.addEndpoint(new GeronimoMBeanEndpoint("ConnectionTracker", ConnectionTracker.class, ObjectName.getInstance("geronimo.connector:role=ConnectionTrackingCoordinator"), true));
  -        mBeanInfo.addEndpoint(new GeronimoMBeanEndpoint("SecurityDomain", SecurityDomain.class, ObjectName.getInstance("geronimo.connector:role=SecurityDomain"), false));
  +        mBeanInfo.addEndpoint(new GeronimoMBeanEndpoint("RealmBridge", RealmBridge.class, ObjectName.getInstance("geronimo.connector:role=SecurityDomain"), false));
   
           mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("BlockingTimeout", true, true, "Milliseconds to wait for a connection to be returned"));
           mBeanInfo.addAttributeInfo(new GeronimoAttributeInfo("JndiName", true, true, "Name to use to identify this guy (needs refactoring of naming conventions)"));
  
  
  
  1.4       +13 -6     incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java
  
  Index: ConnectionTrackingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/ConnectionTrackingInterceptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ConnectionTrackingInterceptor.java	13 Dec 2003 23:33:53 -0000	1.3
  +++ ConnectionTrackingInterceptor.java	11 Jan 2004 08:28:15 -0000	1.4
  @@ -60,12 +60,15 @@
   import javax.resource.spi.ManagedConnection;
   import javax.resource.spi.DissociatableManagedConnection;
   import javax.security.auth.Subject;
  +import javax.security.auth.login.LoginException;
   
   import java.util.Collection;
   import java.util.Set;
   import java.util.Iterator;
   
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTracker;
  +import org.apache.geronimo.security.bridge.RealmBridge;
  +import org.apache.geronimo.security.util.ContextManager;
   
   /**
    * ConnectionTrackingInterceptor.java handles communication with the
  @@ -82,17 +85,17 @@
       private final ConnectionInterceptor next;
       private final String key;
       private final ConnectionTracker connectionTracker;
  -    private final SecurityDomain securityDomain;
  +    private final RealmBridge realmBridge;
   
       public ConnectionTrackingInterceptor(
               final ConnectionInterceptor next,
               final String key,
               final ConnectionTracker connectionTracker,
  -            final SecurityDomain securityDomain) {
  +            final RealmBridge realmBridge) {
           this.next = next;
           this.key = key;
           this.connectionTracker = connectionTracker;
  -        this.securityDomain = securityDomain;
  +        this.realmBridge = realmBridge;
       }
   
       /**
  @@ -134,16 +137,20 @@
               //the spec says anything about this.
               //this is wrong
           }
  -        if (securityDomain == null) {
  +        if (realmBridge == null) {
               return;    //this is wrong: need a "bouncing" subjectInterceptor
           }
   
           Subject currentSubject = null;
           try {
  -            currentSubject = securityDomain.getSubject();
  +            currentSubject = realmBridge.mapSubject(ContextManager.getCurrentCaller());
           } catch (SecurityException e) {
               throw new ResourceException("Can not obtain Subject for login", e);
  +        } catch (LoginException e) {
  +            throw new ResourceException("Can not obtain Subject for login", e);
           }
  +        //TODO figure out which is right here
  +        assert currentSubject != null;
           if (currentSubject == null) {
               //check to see if mci.getSubject() is null?
               return;
  
  
  
  1.5       +11 -5     incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/SubjectInterceptor.java
  
  Index: SubjectInterceptor.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/SubjectInterceptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SubjectInterceptor.java	10 Dec 2003 07:48:12 -0000	1.4
  +++ SubjectInterceptor.java	11 Jan 2004 08:28:15 -0000	1.5
  @@ -58,6 +58,10 @@
   
   import javax.resource.ResourceException;
   import javax.security.auth.Subject;
  +import javax.security.auth.login.LoginException;
  +
  +import org.apache.geronimo.security.bridge.RealmBridge;
  +import org.apache.geronimo.security.util.ContextManager;
   
   /**
    * SubjectInterceptor.java
  @@ -70,20 +74,22 @@
   public class SubjectInterceptor implements ConnectionInterceptor {
   
       private final ConnectionInterceptor next;
  -    private final SecurityDomain securityDomain;
  +    private final RealmBridge realmBridge;
   
       public SubjectInterceptor(
               final ConnectionInterceptor next,
  -            final SecurityDomain securityDomain) {
  +            final RealmBridge realmBridge) {
           this.next = next;
  -        this.securityDomain = securityDomain;
  +        this.realmBridge = realmBridge;
       }
   
       public void getConnection(ConnectionInfo connectionInfo) throws ResourceException {
           Subject currentSubject = null;
           try {
  -            currentSubject = securityDomain.getSubject();
  +            currentSubject = realmBridge.mapSubject(ContextManager.getCurrentCaller());
           } catch (SecurityException e) {
  +            throw new ResourceException("Can not obtain Subject for login", e);
  +        } catch (LoginException e) {
               throw new ResourceException("Can not obtain Subject for login", e);
           }
           assert currentSubject != null;
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/security/PasswordCredentialLoginModule.java
  
  Index: PasswordCredentialLoginModule.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.connector.outbound.security;
  
  import java.io.IOException;
  import java.util.Map;
  
  import javax.resource.spi.security.PasswordCredential;
  import javax.security.auth.Subject;
  import javax.security.auth.callback.Callback;
  import javax.security.auth.callback.CallbackHandler;
  import javax.security.auth.callback.NameCallback;
  import javax.security.auth.callback.PasswordCallback;
  import javax.security.auth.callback.UnsupportedCallbackException;
  import javax.security.auth.login.LoginException;
  import javax.security.auth.spi.LoginModule;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/11 08:28:15 $
   *
   * */
  public class PasswordCredentialLoginModule implements LoginModule {
  
      private Subject subject;
      private CallbackHandler callbackHandler;
  
      private PasswordCredentialRealm passwordCredentialRealm;
  
      private String resourcePrincipalName;
      private String userName;
      private char[] password;
  
      public void initialize(Subject subject, CallbackHandler callbackHandler,
                             Map sharedState, Map options) {
          this.subject = subject;
          this.callbackHandler = callbackHandler;
          passwordCredentialRealm = (PasswordCredentialRealm)options.get(PasswordCredentialRealm.REALM_INSTANCE);
          if (passwordCredentialRealm == null) {
              throw new IllegalArgumentException("No realm supplied in options");
          }
      }
  
      public boolean login() throws LoginException {
          if (passwordCredentialRealm == null || passwordCredentialRealm.managedConnectionFactory == null) {
              return false;
          }
          Callback[] callbacks = new Callback[3];
  
          callbacks[0] = new NameCallback("Resource Principal");
          callbacks[1] = new NameCallback("User name");
          callbacks[2] = new PasswordCallback("Password", false);
          try {
              callbackHandler.handle(callbacks);
          } catch (IOException ioe) {
              throw (LoginException) new LoginException().initCause(ioe);
          } catch (UnsupportedCallbackException uce) {
              throw (LoginException) new LoginException().initCause(uce);
          }
          resourcePrincipalName = ((NameCallback) callbacks[0]).getName();
          userName = ((NameCallback) callbacks[1]).getName();
          password = ((PasswordCallback) callbacks[2]).getPassword();
          return resourcePrincipalName != null && userName != null && password != null;
      }
  
      public boolean commit() throws LoginException {
          subject.getPrincipals().add(new ResourcePrincipal(resourcePrincipalName));
          PasswordCredential passwordCredential = new PasswordCredential(userName, password);
          passwordCredential.setManagedConnectionFactory(passwordCredentialRealm.getManagedConnectionFactory());
          subject.getPrivateCredentials().add(passwordCredential);
          return true;
      }
  
      public boolean abort() throws LoginException {
          subject = null;
          userName = null;
          password = null;
          return true;
      }
  
      public boolean logout() throws LoginException {
          subject = null;
          userName = null;
          password = null;
          return true;
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/security/PasswordCredentialRealm.java
  
  Index: PasswordCredentialRealm.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.connector.outbound.security;
  
  import java.util.HashMap;
  import java.util.Map;
  import java.util.Set;
  import java.security.Principal;
  
  import javax.resource.spi.ManagedConnectionFactory;
  import javax.resource.spi.security.PasswordCredential;
  import javax.security.auth.login.AppConfigurationEntry;
  
  import org.apache.geronimo.kernel.service.GeronimoAttributeInfo;
  import org.apache.geronimo.kernel.service.GeronimoMBeanInfo;
  import org.apache.geronimo.security.GeronimoSecurityException;
  import org.apache.geronimo.security.SecurityRealm;
  import org.apache.regexp.RE;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/11 08:28:15 $
   *
   * */
  public class PasswordCredentialRealm implements SecurityRealm {
  
      private String realmName;
  
      ManagedConnectionFactory managedConnectionFactory;
  
      static final String REALM_INSTANCE = "org.apache.connector.outbound.security.PasswordCredentialRealm";
  
      public static GeronimoMBeanInfo getGeronimoMBeanInfo() {
          GeronimoMBeanInfo mbeanInfo = new GeronimoMBeanInfo();
          mbeanInfo.setTargetClass(PasswordCredentialRealm.class);
          mbeanInfo.addAttributeInfo(new GeronimoAttributeInfo("Realm", true, true, "Name of this realm"));
          return mbeanInfo;
      }
  
      public void setRealmName(String realmName) {
          this.realmName = realmName;
      }
  
      public String getRealmName() {
          return realmName;
      }
  
      public Set getGroupPrincipals() throws GeronimoSecurityException {
          return null;
      }
  
      public Set getGroupPrincipals(RE regexExpression) throws GeronimoSecurityException {
          return null;
      }
  
      public Set getUserPrincipals() throws GeronimoSecurityException {
          return null;
      }
  
      public Set getUserPrincipals(RE regexExpression) throws GeronimoSecurityException {
          return null;
      }
  
      public void refresh() throws GeronimoSecurityException {
      }
  
      public AppConfigurationEntry[] getAppConfigurationEntry() {
          Map options = new HashMap();
          options.put(REALM_INSTANCE, this);
          AppConfigurationEntry appConfigurationEntry = new AppConfigurationEntry(PasswordCredentialLoginModule.class.getName(),
                  AppConfigurationEntry.LoginModuleControlFlag.REQUISITE,
                  options);
          return new AppConfigurationEntry[] {appConfigurationEntry};
      }
  
      public void setManagedConnectionFactory(ManagedConnectionFactory managedConnectionFactory) {
          this.managedConnectionFactory = managedConnectionFactory;
      }
  
      ManagedConnectionFactory getManagedConnectionFactory() {
          return managedConnectionFactory;
      }
  
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/connector/outbound/security/ResourcePrincipal.java
  
  Index: ResourcePrincipal.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * ====================================================================
   */
  
  package org.apache.geronimo.connector.outbound.security;
  
  import java.security.Principal;
  
  /**
   *
   *
   * @version $Revision: 1.1 $ $Date: 2004/01/11 08:28:15 $
   *
   * */
  public class ResourcePrincipal implements Principal {
  
      private final String resourcePrincipal;
  
      public ResourcePrincipal(String resourcePrincipal) {
          this.resourcePrincipal = resourcePrincipal;
      }
  
      public String getName() {
          return resourcePrincipal;
      }
  }
  
  
  
  1.3       +8 -8      incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/model/geronimo/connector/GeronimoConnectionDefinition.java
  
  Index: GeronimoConnectionDefinition.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/deployment/model/geronimo/connector/GeronimoConnectionDefinition.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- GeronimoConnectionDefinition.java	13 Nov 2003 22:22:30 -0000	1.2
  +++ GeronimoConnectionDefinition.java	11 Jan 2004 08:28:15 -0000	1.3
  @@ -67,7 +67,7 @@
   
       private String name;
       private GeronimoConnectionManagerFactory geronimoConnectionManagerFactory;
  -    private String securityDomain;
  +    private String realmBridge;
   
       public GeronimoConnectionDefinition(ConnectionDefinition connectionDefinition) {
           setManagedConnectionFactoryClass(connectionDefinition.getManagedConnectionFactoryClass());
  @@ -107,17 +107,17 @@
       }
   
       /**
  -     * @return Returns the securityDomain.
  +     * @return Returns the realmBridge.
        */
  -    public String getSecurityDomain() {
  -        return securityDomain;
  +    public String getRealmBridge() {
  +        return realmBridge;
       }
   
       /**
  -     * @param securityDomain The securityDomain to set.
  +     * @param realmBridge The realmBridge to set.
        */
  -    public void setSecurityDomain(String securityDomain) {
  -        this.securityDomain = securityDomain;
  +    public void setRealmBridge(String realmBridge) {
  +        this.realmBridge = realmBridge;
       }
   
   }
  
  
  
  1.2       +56 -56    incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/GeronimoConnectorLoader.java
  
  Index: GeronimoConnectorLoader.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/xml/deployment/GeronimoConnectorLoader.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- GeronimoConnectorLoader.java	11 Nov 2003 21:11:58 -0000	1.1
  +++ GeronimoConnectorLoader.java	11 Jan 2004 08:28:15 -0000	1.2
  @@ -72,20 +72,20 @@
   /**
    * Knows how to load a set of POJOs from a DOM representing a ra.xml
    * deployment descriptor.
  - * 
  + *
    * @version $Revision$ $Date$
    */
   public class GeronimoConnectorLoader {
  -    
  +
       private GeronimoConnectorLoader() {
       }
  -    
  +
       public static GeronimoConnectorDocument load(Document doc, ConnectorDocument connectorDocument) {
           Element root = doc.getDocumentElement();
           if (!"connector".equals(root.getTagName())) {
               throw new IllegalArgumentException("Document is not a ra instance");
           }
  -        
  +
           Connector connector = connectorDocument.getConnector();
           GeronimoConnector geronimoConnector = new GeronimoConnector(connector);
           geronimoConnector.setResourceAdapter(loadResourceAdapter(root, connector));
  @@ -97,43 +97,43 @@
   
       private static GeronimoResourceAdapter loadResourceAdapter(Element econ, Connector connector) {
           Element era = LoaderUtil.getChild(econ, "resourceadapter");
  -        if( null == era ) {
  +        if (null == era) {
               throw new IllegalArgumentException("No resourceadapter element");
           }
           ResourceAdapter resourceAdapter = connector.getResourceAdapter();
  -		GeronimoResourceAdapter ra = new GeronimoResourceAdapter(resourceAdapter);
  -		ra.setName(LoaderUtil.getChildContent(era, "name"));
  -		ConfigProperty[] configProperty = ra.getConfigProperty();
  -		loadConfigSettings(era, configProperty);
  -		ra.setBootstrapContext(LoaderUtil.getChildContent(era, "bootstrapcontext-name"));
  -		ra.setOutboundResourceAdapter(loadOutboundResourceadapter(era, resourceAdapter.getOutboundResourceAdapter()));
  -		ra.setInboundResourceAdapter(loadInboundResourceadapter(era, resourceAdapter.getInboundResourceAdapter()));
  -		ra.setAdminObject(loadAdminobject(era, resourceAdapter.getAdminObject()));
  -        
  +        GeronimoResourceAdapter ra = new GeronimoResourceAdapter(resourceAdapter);
  +        ra.setName(LoaderUtil.getChildContent(era, "name"));
  +        ConfigProperty[] configProperty = ra.getConfigProperty();
  +        loadConfigSettings(era, configProperty);
  +        ra.setBootstrapContext(LoaderUtil.getChildContent(era, "bootstrapcontext-name"));
  +        ra.setOutboundResourceAdapter(loadOutboundResourceadapter(era, resourceAdapter.getOutboundResourceAdapter()));
  +        ra.setInboundResourceAdapter(loadInboundResourceadapter(era, resourceAdapter.getInboundResourceAdapter()));
  +        ra.setAdminObject(loadAdminobject(era, resourceAdapter.getAdminObject()));
  +
           return ra;
       }
  -    
  +
       private static void loadConfigSettings(Element era, ConfigProperty[] configProperty) {
           Element[] roots = LoaderUtil.getChildren(era, "config-property-setting");
  -        for(int i = 0; i < roots.length; i++)
  +        for (int i = 0; i < roots.length; i++)
               outer:
           {
  -            Element root = roots[i];
  -            String name = root.getAttribute("name");
  -            for (int j = 0; j < configProperty.length; j++) {
  -                if (configProperty[j].getConfigPropertyName().equals(name)) {
  -					configProperty[j].setConfigPropertyValue(LoaderUtil.getContent(root));
  -                    break outer;
  +                Element root = roots[i];
  +                String name = root.getAttribute("name");
  +                for (int j = 0; j < configProperty.length; j++) {
  +                    if (configProperty[j].getConfigPropertyName().equals(name)) {
  +                        configProperty[j].setConfigPropertyValue(LoaderUtil.getContent(root));
  +                        break outer;
  +                    }
                   }
  +                throw new IllegalArgumentException("No such property as " + name);
               }
  -            throw new IllegalArgumentException("No such property as " + name);
  -        }
       }
   
       private static ConfigProperty[] loadConfigPropertySettings(Element era) {
           Element[] roots = LoaderUtil.getChildren(era, "config-property-setting");
           ConfigProperty[] configProperties = new ConfigProperty[roots.length];
  -        for(int i = 0; i < roots.length; i++) {
  +        for (int i = 0; i < roots.length; i++) {
               Element root = roots[i];
               configProperties[i] = new ConfigProperty();
               configProperties[i].setConfigPropertyName(root.getAttribute("name"));
  @@ -155,27 +155,27 @@
       private static GeronimoConnectionDefinition[] loadConnectionDefinition(Element ecd, ConnectionDefinition[] connectionDefinition) {
           Element[] roots = LoaderUtil.getChildren(ecd, "connection-definition");
           GeronimoConnectionDefinition[] conDefinition = new GeronimoConnectionDefinition[roots.length];
  -        for(int i = 0; i < roots.length; i++)
  +        for (int i = 0; i < roots.length; i++)
               loaded:
           {
  -            Element root = roots[i];
  -            String connectionFactoryInterface = LoaderUtil.getChildContent(root, "connectionfactory-interface");
  -            for (int j = 0; j < connectionDefinition.length; j++) {
  -                if (connectionFactoryInterface.equals(connectionDefinition[j].getConnectionFactoryInterface())) {
  -					conDefinition[i] = new GeronimoConnectionDefinition(connectionDefinition[j]);
  -					ConfigProperty[] configProperty = conDefinition[i].getConfigProperty();
  -					loadConfigSettings(root, configProperty);
  -                    conDefinition[i].setName(LoaderUtil.getChildContent(root, "name"));
  -                    GeronimoConnectionManagerFactory connectionManagerFactory = new GeronimoConnectionManagerFactory();
  -                    Element ecmf = LoaderUtil.getChild(root, "connectionmanager-factory");
  -                    connectionManagerFactory.setConnectionManagerFactoryDescriptor(LoaderUtil.getChildContent(ecmf, "connectionmanagerfactory-descriptor"));
  -                    connectionManagerFactory.setConfigProperty(loadConfigPropertySettings(ecmf));
  -                    conDefinition[i].setGeronimoConnectionManagerFactory(connectionManagerFactory);
  -					break loaded;
  +                Element root = roots[i];
  +                String connectionFactoryInterface = LoaderUtil.getChildContent(root, "connectionfactory-interface");
  +                for (int j = 0; j < connectionDefinition.length; j++) {
  +                    if (connectionFactoryInterface.equals(connectionDefinition[j].getConnectionFactoryInterface())) {
  +                        conDefinition[i] = new GeronimoConnectionDefinition(connectionDefinition[j]);
  +                        ConfigProperty[] configProperty = conDefinition[i].getConfigProperty();
  +                        loadConfigSettings(root, configProperty);
  +                        conDefinition[i].setName(LoaderUtil.getChildContent(root, "name"));
  +                        GeronimoConnectionManagerFactory connectionManagerFactory = new GeronimoConnectionManagerFactory();
  +                        Element ecmf = LoaderUtil.getChild(root, "connectionmanager-factory");
  +                        connectionManagerFactory.setConnectionManagerFactoryDescriptor(LoaderUtil.getChildContent(ecmf, "connectionmanagerfactory-descriptor"));
  +                        connectionManagerFactory.setConfigProperty(loadConfigPropertySettings(ecmf));
  +                        conDefinition[i].setGeronimoConnectionManagerFactory(connectionManagerFactory);
  +                        break loaded;
  +                    }
                   }
  +                throw new IllegalArgumentException("No such connectionfactory-interface as " + connectionFactoryInterface);
               }
  -            throw new IllegalArgumentException("No such connectionfactory-interface as " + connectionFactoryInterface);
  -        }
           return conDefinition;
       }
   
  @@ -187,28 +187,28 @@
           Element root = LoaderUtil.getChild(era, "inbound-resourceadapter");
           GeronimoInboundResourceAdapter ira = new GeronimoInboundResourceAdapter();
           ira.setMessageAdapter(loadMessageAdapter(root, inboundResourceAdapter.getMessageAdapter()));
  -        return ira;    
  +        return ira;
       }
  -    
  +
       private static GeronimoMessageAdapter loadMessageAdapter(Element eira, MessageAdapter messageAdapter) {
  -		GeronimoMessageAdapter ma = null;
  +        GeronimoMessageAdapter ma = null;
           Element root = LoaderUtil.getChild(eira, "messageadapter");
  -        if ( null != root && null != messageAdapter ) {
  +        if (null != root && null != messageAdapter) {
               ma = new GeronimoMessageAdapter();
               ma.setMessageListener(loadMessagelistener(root, messageAdapter.getMessageListener()));
           }
  -        return ma;    
  +        return ma;
       }
   
       private static GeronimoMessageListener[] loadMessagelistener(Element ema, MessageListener[] messageListenerType) {
           Element[] roots = LoaderUtil.getChildren(ema, "messagelistener");
  -		GeronimoMessageListener[] messageListener = new GeronimoMessageListener[roots.length];
  -        for(int i = 0; i < roots.length; i++) {
  +        GeronimoMessageListener[] messageListener = new GeronimoMessageListener[roots.length];
  +        for (int i = 0; i < roots.length; i++) {
               Element root = roots[i];
               String messageListenerTypeName = LoaderUtil.getChildContent(root, "messagelistener-type");
               for (int j = 0; j < messageListenerType.length; j++) {
                   if (messageListenerType[j].getMessageListenerType().equals(messageListenerTypeName)) {
  -					messageListener[i] = new GeronimoMessageListener(messageListenerType[j]);
  +                    messageListener[i] = new GeronimoMessageListener(messageListenerType[j]);
                       messageListener[i].setMessageEndpointFactoryName(LoaderUtil.getChildContent(root, "message-endpoint-factory"));
                       break;
                   }
  @@ -216,17 +216,17 @@
           }
           return messageListener;
       }
  -    
  -    
  +
  +
       private static AdminObject[] loadAdminobject(Element era, AdminObject[] adminObjectType) {
           Element[] roots = LoaderUtil.getChildren(era, "adminobject");
           AdminObject[] adminObject = new AdminObject[roots.length];
  -        for(int i = 0; i < roots.length; i++) {
  +        for (int i = 0; i < roots.length; i++) {
               Element root = roots[i];
               adminObject[i] = new AdminObject();
               adminObject[i].setAdminObjectInterface(LoaderUtil.getChildContent(root, "adminobject-interface"));
               adminObject[i].setAdminObjectClass(LoaderUtil.getChildContent(root, "adminobject-class"));
  -            for (int j = 0; j < adminObjectType.length; j++ ) {
  +            for (int j = 0; j < adminObjectType.length; j++) {
                   if (adminObjectType[j].getAdminObjectInterface().equals(adminObject[i].getAdminObjectInterface())
                           && adminObjectType[j].getAdminObjectClass().equals(adminObject[i].getAdminObjectClass())) {
                       adminObject[i].setConfigProperty(
  @@ -238,5 +238,5 @@
           }
           return adminObject;
       }
  -    
  +
   }
  
  
  
  1.2       +14 -17    incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java
  
  Index: ConnectionManagerTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ConnectionManagerTest.java	23 Dec 2003 17:34:35 -0000	1.1
  +++ ConnectionManagerTest.java	11 Jan 2004 08:28:15 -0000	1.2
  @@ -56,26 +56,23 @@
   
   package org.apache.geronimo.connector.outbound;
   
  -import java.util.Set;
   import java.util.HashSet;
  +import java.util.Set;
   
  -import javax.transaction.TransactionManager;
  -import javax.transaction.Transaction;
  -import javax.transaction.Status;
  -import javax.resource.spi.ConnectionManager;
   import javax.security.auth.Subject;
  +import javax.transaction.TransactionManager;
   
   import junit.framework.TestCase;
  +import org.apache.geronimo.connector.mock.MockConnection;
  +import org.apache.geronimo.connector.mock.MockConnectionFactory;
  +import org.apache.geronimo.connector.mock.MockManagedConnection;
  +import org.apache.geronimo.connector.mock.MockManagedConnectionFactory;
  +import org.apache.geronimo.connector.mock.MockXAResource;
   import org.apache.geronimo.connector.outbound.connectiontracking.ConnectionTrackingCoordinator;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultComponentContext;
  -import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultTransactionContext;
  -import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultInterceptor;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultComponentInterceptor;
  -import org.apache.geronimo.connector.mock.MockManagedConnectionFactory;
  -import org.apache.geronimo.connector.mock.MockConnectionFactory;
  -import org.apache.geronimo.connector.mock.MockConnection;
  -import org.apache.geronimo.connector.mock.MockXAResource;
  -import org.apache.geronimo.connector.mock.MockManagedConnection;
  +import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultInterceptor;
  +import org.apache.geronimo.security.bridge.RealmBridge;
   import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
   
   /**
  @@ -84,7 +81,7 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class ConnectionManagerTest extends TestCase implements DefaultInterceptor, SecurityDomain {
  +public class ConnectionManagerTest extends TestCase implements DefaultInterceptor, RealmBridge {
   
       protected boolean useConnectionRequestInfo = false;
       protected boolean useSubject = true;
  @@ -95,7 +92,7 @@
       protected int blockingTimeout = 100;
       protected String jndiName = "testCF";
       //dependencies
  -    protected SecurityDomain securityDomain = this;
  +    protected RealmBridge realmBridge = this;
       protected ConnectionTrackingCoordinator connectionTrackingCoordinator;
   
       protected TransactionManager transactionManager;
  @@ -120,7 +117,7 @@
                   useTransactions,
                   maxSize,
                   blockingTimeout,
  -                securityDomain,
  +                realmBridge,
                   jndiName,
                   connectionTrackingCoordinator);
           connectionFactory = (MockConnectionFactory)connectionManagerDeployment.createConnectionFactory(mockManagedConnectionFactory);
  @@ -176,7 +173,7 @@
           return null;
       }
   
  -    public Subject getSubject() {
  +    public Subject mapSubject(Subject sourceSubject) {
           return subject;
       }
   }
  
  
  
  1.3       +5 -4      incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java
  
  Index: ConnectionManagerTestUtils.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/ConnectionManagerTestUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionManagerTestUtils.java	13 Dec 2003 23:33:54 -0000	1.2
  +++ ConnectionManagerTestUtils.java	11 Jan 2004 08:28:15 -0000	1.3
  @@ -74,6 +74,7 @@
   import junit.framework.TestCase;
   
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultTransactionContext;
  +import org.apache.geronimo.security.bridge.RealmBridge;
   
   /**
    *
  @@ -81,7 +82,7 @@
    * @version $Revision$ $Date$
    *
    * */
  -public class ConnectionManagerTestUtils extends TestCase implements SecurityDomain, ConnectionInterceptor {
  +public class ConnectionManagerTestUtils extends TestCase implements RealmBridge, ConnectionInterceptor {
       protected Subject subject;
       protected ConnectionInfo obtainedConnectionInfo;
       protected ConnectionInfo returnedConnectionInfo;
  @@ -100,8 +101,8 @@
       public void testNothing() throws Exception {
       }
   
  -    //SecurityDomain implementation
  -    public Subject getSubject() {
  +    //RealmBridge implementation
  +    public Subject mapSubject(Subject sourceSubject) {
           return subject;
       }
   
  
  
  
  1.3       +8 -8      incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java
  
  Index: ConnectionTrackingCoordinatorTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/test/org/apache/geronimo/connector/outbound/connectiontracking/ConnectionTrackingCoordinatorTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConnectionTrackingCoordinatorTest.java	10 Dec 2003 09:39:46 -0000	1.2
  +++ ConnectionTrackingCoordinatorTest.java	11 Jan 2004 08:28:15 -0000	1.3
  @@ -56,23 +56,23 @@
   
   package org.apache.geronimo.connector.outbound.connectiontracking;
   
  -import java.util.Set;
   import java.util.HashSet;
   import java.util.Map;
  +import java.util.Set;
   
   import javax.security.auth.Subject;
  -import javax.transaction.TransactionManager;
   import javax.transaction.Transaction;
  +import javax.transaction.TransactionManager;
   
   import junit.framework.TestCase;
  +import org.apache.geronimo.connector.outbound.ConnectionInfo;
   import org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor;
  -import org.apache.geronimo.connector.outbound.SecurityDomain;
   import org.apache.geronimo.connector.outbound.ConnectorComponentContext;
  -import org.apache.geronimo.connector.outbound.ConnectionInfo;
  -import org.apache.geronimo.connector.outbound.ManagedConnectionInfo;
   import org.apache.geronimo.connector.outbound.ConnectorTransactionContext;
  +import org.apache.geronimo.connector.outbound.ManagedConnectionInfo;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultComponentContext;
   import org.apache.geronimo.connector.outbound.connectiontracking.defaultimpl.DefaultTransactionContext;
  +import org.apache.geronimo.security.bridge.RealmBridge;
   import org.apache.geronimo.transaction.manager.TransactionManagerImpl;
   
   /**
  @@ -82,7 +82,7 @@
    *
    * */
   public class ConnectionTrackingCoordinatorTest extends TestCase
  -        implements SecurityDomain {
  +        implements RealmBridge {
   
       private static final String name1 = "foo";
       private static final String name2 = "bar";
  @@ -194,7 +194,7 @@
           assertNull("Expected no transactionContext", availableTransactionContext2);
       }
   
  -    public Subject getSubject() {
  +    public Subject mapSubject(Subject sourceSubject) {
           return subject;
       }
   }