[jboss-cvs] JBossAS SVN: r114817 - in projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc: local and 1 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 4 15:00:46 EDT 2014


Author: jolee
Date: 2014-09-04 15:00:46 -0400 (Thu, 04 Sep 2014)
New Revision: 114817

Modified:
   projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java
   projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java
   projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/local/LocalManagedConnectionFactory.java
   projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/xa/XAManagedConnectionFactory.java
Log:
BZ1138425: JBJCA-1082

Modified: projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java
===================================================================
--- projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java	2014-09-04 18:55:24 UTC (rev 114816)
+++ projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnection.java	2014-09-04 19:00:46 UTC (rev 114817)
@@ -826,7 +826,7 @@
 
    private void checkIdentity(Subject subject, ConnectionRequestInfo cri) throws ResourceException
    {
-      Properties newProps = mcf.getConnectionProperties(subject, cri);
+      Properties newProps = mcf.getConnectionProperties(props, subject, cri);
 
       if (Boolean.TRUE.equals(mcf.getReauthEnabled()))
       {

Modified: projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java	2014-09-04 18:55:24 UTC (rev 114816)
+++ projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/BaseWrapperManagedConnectionFactory.java	2014-09-04 19:00:46 UTC (rev 114817)
@@ -108,12 +108,6 @@
    /** The password */
    protected String password;
 
-   /** This is used by Local wrapper for all properties, and is left
-    * in this class for ease of writing getConnectionProperties,
-    * which always holds the user/pw.
-    */
-   protected final Properties connectionProps = new Properties();
-
    /** The transaction isolation level */
    protected int transactionIsolation = -1;
 
@@ -940,19 +934,23 @@
     *
     * <p>In fact, we have a problem here. Theoretically, there is a possible
     * name collision between config properties and "user"/"password".
+    * @param connectionProps The connection properties
     * @param subject The subject
     * @param cri The connection request info
     * @return The properties
     * @exception ResourceException Thrown if an error occurs
     */
-   protected synchronized Properties getConnectionProperties(Subject subject, ConnectionRequestInfo cri)
+   protected Properties getConnectionProperties(Properties connectionProps, Subject subject, ConnectionRequestInfo cri)
       throws ResourceException
    {
       if (cri != null && cri.getClass() != WrappedConnectionRequestInfo.class)
          throw new ResourceException("Wrong kind of ConnectionRequestInfo: " + cri.getClass());
 
       Properties props = new Properties();
-      props.putAll(connectionProps);
+      
+      if (connectionProps != null && connectionProps.size() > 0)
+         props.putAll(connectionProps);
+      
       if (subject != null)
       {
          if (SubjectActions.addMatchingProperties(subject, cri, props, userName, password, this))
@@ -1209,12 +1207,12 @@
          this.mcf = mcf;
       }
 
-      /**
-       * Run
-       * @return The result
-       */
-      public Boolean run()
-      {
+       /**
+        * doCheck
+        * @return The result
+        */
+       private Boolean doCheck()
+       {
          Set<PasswordCredential> creds = subject.getPrivateCredentials(PasswordCredential.class);
          if (creds != null && creds.size() > 0)
          {
@@ -1257,6 +1255,15 @@
       }
 
       /**
+        * Run
+        * @return The result
+        */
+       public Boolean run()
+       {
+          return doCheck();
+       }
+
+       /**
        * Add matching properties
        * @param subject The subject
        * @param cri The connection request info
@@ -1270,7 +1277,15 @@
                                            String userName, String password, ManagedConnectionFactory mcf)
       {
          SubjectActions action = new SubjectActions(subject, cri, props, userName, password, mcf);
-         Boolean matched = AccessController.doPrivileged(action);
+         Boolean matched = Boolean.FALSE;
+         if (System.getSecurityManager() == null)
+         {
+            matched = action.doCheck();
+         }
+         else
+         {
+            matched = AccessController.doPrivileged(action);
+         }
          return matched.booleanValue();
       }
    }

Modified: projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/local/LocalManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/local/LocalManagedConnectionFactory.java	2014-09-04 18:55:24 UTC (rev 114816)
+++ projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/local/LocalManagedConnectionFactory.java	2014-09-04 19:00:46 UTC (rev 114817)
@@ -75,6 +75,9 @@
 
    /** The connection properties */
    protected String connectionProperties;
+   
+   /** The connection properties */
+   protected final Properties connectionProps = new Properties();   
 
    private static Map<String, Driver> driverCache = new ConcurrentHashMap<String, Driver>();
 
@@ -139,7 +142,7 @@
     *
     * @param driverClass The new DriverClass value.
     */
-   public synchronized void setDriverClass(final String driverClass)
+   public void setDriverClass(final String driverClass)
    {
       this.driverClass = driverClass;
       driver = null;
@@ -160,7 +163,7 @@
     *
     * @param dataSourceClass The new DataSourceClass value.
     */
-   public synchronized void setDataSourceClass(final String dataSourceClass)
+   public void setDataSourceClass(final String dataSourceClass)
    {
       this.dataSourceClass = dataSourceClass;
       driver = null;
@@ -207,10 +210,10 @@
    /**
     * {@inheritDoc}
     */
-   public synchronized ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cri)
+   public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cri)
       throws ResourceException
    {
-      Properties props = getConnectionProperties(subject, cri);
+      Properties props = getConnectionProperties(connectionProps, subject, cri);
       // Some friendly drivers (Oracle, you guessed right) modify the props you supply.
       // Since we use our copy to identify compatibility in matchManagedConnection, we need
       // a pristine copy for our own use.  So give the friendly driver a copy.
@@ -444,7 +447,7 @@
    public ManagedConnection matchManagedConnections(final Set mcs, final Subject subject,
                                                     final ConnectionRequestInfo cri) throws ResourceException
    {
-      Properties newProps = getConnectionProperties(subject, cri);
+      Properties newProps = getConnectionProperties(connectionProps, subject, cri);
 
       for (Iterator<?> i = mcs.iterator(); i.hasNext();)
       {
@@ -472,6 +475,19 @@
       return null;
    }
 
+   /*
+    * Is the properties equal
+    * @param other The other properties
+    * @return True if equal, otherwise false
+    */
+   private boolean isEqual(Properties other)
+   {
+      synchronized (connectionProps)
+      {
+         return connectionProps.equals(other);
+      }
+   }
+
    /**
     * {@inheritDoc}
     */

Modified: projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/xa/XAManagedConnectionFactory.java
===================================================================
--- projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/xa/XAManagedConnectionFactory.java	2014-09-04 18:55:24 UTC (rev 114816)
+++ projects/jboss-jca/tags/IRONJACAMAR_1_0_17_FINAL_BZ1138425/adapters/src/main/java/org/jboss/jca/adapters/jdbc/xa/XAManagedConnectionFactory.java	2014-09-04 19:00:46 UTC (rev 114817)
@@ -386,7 +386,7 @@
    /**
     * {@inheritDoc}
     */
-   public synchronized ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cri)
+   public ManagedConnection createManagedConnection(Subject subject, ConnectionRequestInfo cri)
       throws javax.resource.ResourceException
    {
       if (urlProperty != null && !urlProperty.trim().equals("") && xadsSelector == null)
@@ -433,7 +433,7 @@
       throws ResourceException
    {
       XAConnection xaConnection = null;
-      Properties props = getConnectionProperties(subject, cri);
+      Properties props = getConnectionProperties(null, subject, cri);
 
       try
       {
@@ -481,7 +481,7 @@
    public ManagedConnection matchManagedConnections(Set mcs, Subject subject, ConnectionRequestInfo cri)
       throws ResourceException
    {
-      Properties newProps = getConnectionProperties(subject, cri);
+      Properties newProps = getConnectionProperties(null, subject, cri);
       for (Iterator<?> i = mcs.iterator(); i.hasNext();)
       {
          Object o = i.next();
@@ -506,6 +506,19 @@
       return null;
    }
 
+    /**
+    * Is the properties equal
+    * @param other The other properties
+    * @return True if equal, otherwise false
+    */
+   private boolean isEqual(Map<String, String> other)
+   {
+      synchronized (xaProps)
+      {
+         return xaProps.equals(other);
+      }
+   }   
+   
    /**
     * {@inheritDoc}
     */
@@ -534,7 +547,7 @@
          return false;
 
       XAManagedConnectionFactory otherMcf = (XAManagedConnectionFactory) other;
-      return this.xaDataSourceClass.equals(otherMcf.xaDataSourceClass) && this.xaProps.equals(otherMcf.xaProps)
+      return this.xaDataSourceClass.equals(otherMcf.xaDataSourceClass) && isEqual(otherMcf.xaProps)
          && ((this.userName == null) ? otherMcf.userName == null : this.userName.equals(otherMcf.userName))
          && ((this.password == null) ? otherMcf.password == null : this.password.equals(otherMcf.password))
          && this.transactionIsolation == otherMcf.transactionIsolation;



More information about the jboss-cvs-commits mailing list