[jboss-cvs] JBossAS SVN: r106295 - in projects/jboss-jca/trunk/codegenerator/src/main: java/org/jboss/jca/codegenerator/code and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Sun Jun 27 22:30:17 EDT 2010


Author: jeff.zhang
Date: 2010-06-27 22:30:16 -0400 (Sun, 27 Jun 2010)
New Revision: 106295

Added:
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AuthenMechanismType.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/SecurityPermissionType.java
Modified:
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/Ra10XmlGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java
   projects/jboss-jca/trunk/codegenerator/src/main/resources/definition.xml
Log:
[JBJCA-367] support reauthentication, AuthenticationMechanism and SecurityPermission


Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AuthenMechanismType.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AuthenMechanismType.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/AuthenMechanismType.java	2010-06-28 02:30:16 UTC (rev 106295)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.codegenerator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * A AuthenMechanismType.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+public class AuthenMechanismType
+{
+   /** define authMechanism */
+   @XmlElement(name = "authMechanism") 
+   private String authMechanism = "BasicPassword";
+   
+   /** define credentialInterface */
+   @XmlElement(name = "credentialInterface") 
+   private String credentialInterface = "PasswordCredential";
+
+   /**
+    * Set the authMechanism.
+    * 
+    * @param authMechanism The authMechanism to set.
+    */
+   public void setAuthMechanism(String authMechanism)
+   {
+      this.authMechanism = authMechanism;
+   }
+
+   /**
+    * Get the authMechanism.
+    * 
+    * @return the authMechanism.
+    */
+   public String getAuthMechanism()
+   {
+      return authMechanism;
+   }
+
+   /**
+    * Set the credentialInterface.
+    * 
+    * @param credentialInterface The credentialInterface to set.
+    */
+   public void setCredentialInterface(String credentialInterface)
+   {
+      this.credentialInterface = credentialInterface;
+   }
+
+   /**
+    * Get the credentialInterface.
+    * 
+    * @return the credentialInterface.
+    */
+   public String getCredentialInterface()
+   {
+      return credentialInterface;
+   }
+   
+}

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java	2010-06-26 14:59:35 UTC (rev 106294)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/Definition.java	2010-06-28 02:30:16 UTC (rev 106295)
@@ -74,7 +74,16 @@
    /** support transaction  */
    @XmlElement(name = "Transaction") 
    private String supportTransaction;
-
+   /** support re-authentication */
+   @XmlElement(name = "SupportReauthen")
+   private boolean supportReauthen = false;
+   /** define SecurityPermission */
+   @XmlElement(name = "SecurityPermission") 
+   private List<SecurityPermissionType> securityPermissions;
+   /** define AuthenMechanism */
+   @XmlElement(name = "AuthenMechanism") 
+   private List<AuthenMechanismType> authenMechanisms;
+   
    /** managed connection class name */
    @XmlElement(name = "ManagedConnection")
    private String mcClass;
@@ -140,6 +149,7 @@
    @XmlElement(name = "Method") 
    private List<MethodForConnection> methods;
    
+
    /**
     * Set the version.
     * 
@@ -854,4 +864,64 @@
       return defaultValue;
    }
 
+   /**
+    * Set the supportReauthen.
+    * 
+    * @param supportReauthen The supportReauthen to set.
+    */
+   public void setSupportReauthen(boolean supportReauthen)
+   {
+      this.supportReauthen = supportReauthen;
+   }
+
+   /**
+    * Get the supportReauthen.
+    * 
+    * @return the supportReauthen.
+    */
+   public boolean isSupportReauthen()
+   {
+      return supportReauthen;
+   }
+
+   /**
+    * Set the securityPermissions.
+    * 
+    * @param securityPermissions The securityPermissions to set.
+    */
+   public void setSecurityPermissions(List<SecurityPermissionType> securityPermissions)
+   {
+      this.securityPermissions = securityPermissions;
+   }
+
+   /**
+    * Get the securityPermissions.
+    * 
+    * @return the securityPermissions.
+    */
+   public List<SecurityPermissionType> getSecurityPermissions()
+   {
+      return securityPermissions;
+   }
+
+   /**
+    * Set the authenMechanisms.
+    * 
+    * @param authenMechanisms The authenMechanisms to set.
+    */
+   public void setAuthenMechanisms(List<AuthenMechanismType> authenMechanisms)
+   {
+      this.authenMechanisms = authenMechanisms;
+   }
+
+   /**
+    * Get the authenMechanisms.
+    * 
+    * @return the authenMechanisms.
+    */
+   public List<AuthenMechanismType> getAuthenMechanisms()
+   {
+      return authenMechanisms;
+   }
+
 }

Added: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/SecurityPermissionType.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/SecurityPermissionType.java	                        (rev 0)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/SecurityPermissionType.java	2010-06-28 02:30:16 UTC (rev 106295)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jca.codegenerator;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+/**
+ * A SecurityPermissionType.
+ * 
+ * @author Jeff Zhang
+ * @version $Revision: $
+ */
+ at XmlAccessorType(XmlAccessType.FIELD)
+public class SecurityPermissionType
+{
+   /** define permissionSpec */
+   @XmlElement(name = "permissionSpec") 
+   private String permissionSpec;
+
+   /**
+    * Set the permissionSpec.
+    * 
+    * @param permissionSpec The permissionSpec to set.
+    */
+   public void setPermissionSpec(String permissionSpec)
+   {
+      this.permissionSpec = permissionSpec;
+   }
+
+   /**
+    * Get the permissionSpec.
+    * 
+    * @return the permissionSpec.
+    */
+   public String getPermissionSpec()
+   {
+      return permissionSpec;
+   }
+}

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java	2010-06-26 14:59:35 UTC (rev 106294)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/code/RaCodeGen.java	2010-06-28 02:30:16 UTC (rev 106295)
@@ -52,7 +52,48 @@
          {
             out.write("(");
             writeEol(out);
+            if (def.getAuthenMechanisms() != null && def.getAuthenMechanisms().size() > 0)
+            {
+               writeIndent(out, 1);
+               out.write("authMechanisms = {");
+               writeEol(out);
+               for (int i = 0; i < def.getAuthenMechanisms().size(); i++)
+               {
+                  writeIndent(out, 2);
+                  out.write("@AuthenticationMechanism(");
+                  out.write("authMechanism = \"" + def.getAuthenMechanisms().get(i).getAuthMechanism());
+                  out.write("\", credentialInterface = CredentialInterface." + 
+                     def.getAuthenMechanisms().get(i).getCredentialInterface());
+                  if (i + 1 < def.getAuthenMechanisms().size())
+                     out.write("),");
+                  else
+                     out.write(")},");
+                  writeEol(out);
+               }
+            }
             writeIndent(out, 1);
+            out.write("reauthenticationSupport = " + def.isSupportReauthen() + ",");
+            writeEol(out);
+            if (def.getSecurityPermissions() != null && def.getSecurityPermissions().size() > 0)
+            {
+               writeIndent(out, 1);
+               out.write("securityPermissions = {");
+               writeEol(out);
+
+               for (int i = 0; i < def.getSecurityPermissions().size(); i++)
+               {
+                  writeIndent(out, 2);
+                  out.write("@SecurityPermission(");
+                  out.write("permissionSpec = \"" + 
+                     def.getSecurityPermissions().get(i).getPermissionSpec() + "\")");
+                  if (i + 1 < def.getSecurityPermissions().size())
+                     out.write(",");
+                  else
+                     out.write("},");
+                  writeEol(out);
+               }
+            }
+            writeIndent(out, 1);
             out.write("transactionSupport = TransactionSupport.TransactionSupportLevel." + 
                def.getSupportTransaction() + ")");
          }
@@ -167,6 +208,14 @@
       writeEol(out);
       out.write("import javax.resource.spi.ActivationSpec;");
       writeEol(out);
+      if (def.isUseAnnotation() && 
+         def.getAuthenMechanisms() != null && def.getAuthenMechanisms().size() > 0)
+      {
+         out.write("import javax.resource.spi.AuthenticationMechanism;");
+         writeEol(out);
+         out.write("import javax.resource.spi.AuthenticationMechanism.CredentialInterface;");
+         writeEol(out);
+      }
       out.write("import javax.resource.spi.BootstrapContext;");
       writeEol(out);
       if (def.isUseAnnotation())
@@ -180,6 +229,12 @@
       writeEol(out);
       out.write("import javax.resource.spi.ResourceAdapterInternalException;");
       writeEol(out);
+      if (def.isUseAnnotation() && 
+         def.getSecurityPermissions() != null && def.getSecurityPermissions().size() > 0)
+      {
+         out.write("import javax.resource.spi.SecurityPermission;");
+         writeEol(out);
+      }
       if (def.isUseAnnotation() && def.isSupportOutbound())
       {
          out.write("import javax.resource.spi.TransactionSupport;");

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/Ra10XmlGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/Ra10XmlGen.java	2010-06-26 14:59:35 UTC (rev 106294)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/Ra10XmlGen.java	2010-06-28 02:30:16 UTC (rev 106295)
@@ -158,7 +158,7 @@
       writeConfigPropsXml(def.getMcfConfigProps(), out, indent, false);
       
       writeIndent(out, indent);
-      out.write("<reauthentication-support>false</reauthentication-support>");
+      out.write("<reauthentication-support>" + def.isSupportReauthen() + "</reauthentication-support>");
       writeEol(out);
    }
 }

Modified: projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java	2010-06-26 14:59:35 UTC (rev 106294)
+++ projects/jboss-jca/trunk/codegenerator/src/main/java/org/jboss/jca/codegenerator/xml/RaXmlGen.java	2010-06-28 02:30:16 UTC (rev 106295)
@@ -78,7 +78,24 @@
       {
          writeInbound(def, out, indent + 1);
       }
-      
+
+      if (def.getSecurityPermissions() != null && def.getSecurityPermissions().size() > 0)
+      {
+         for (int i = 0; i < def.getSecurityPermissions().size(); i++)
+         {
+            writeIndent(out, indent + 1);
+            out.write("<security-permission>");
+            writeEol(out);
+            writeIndent(out, indent + 2);
+            out.write("<security-permission-spec>" + def.getSecurityPermissions().get(i).getPermissionSpec() + 
+               "</security-permission-spec>");
+            writeEol(out);
+            writeIndent(out, indent + 1);
+            out.write("</security-permission>");
+            writeEol(out);
+         }
+      }
+   
       writeIndent(out, indent);
       out.write("</resourceadapter>");
       writeEol(out);
@@ -263,8 +280,34 @@
       writeIndent(out, indent + 1);
       out.write("<transaction-support>" + def.getSupportTransaction() + "</transaction-support>");
       writeEol(out);
+      
+      if (def.getAuthenMechanisms() != null && def.getAuthenMechanisms().size() > 0)
+      {
+         for (int i = 0; i < def.getAuthenMechanisms().size(); i++)
+         {
+            writeIndent(out, indent + 1);
+            out.write("<authentication-mechanism>");
+            writeEol(out);
+            writeIndent(out, indent + 2);
+            out.write("<authentication-mechanism-type>" + def.getAuthenMechanisms().get(i).getAuthMechanism() + 
+               "</authentication-mechanism-type>");
+            writeEol(out);
+            writeIndent(out, indent + 2);
+            out.write("<credential-interface>");
+            if (def.getAuthenMechanisms().get(i).getCredentialInterface().equals("GSSCredential"))
+               out.write("org.ietf.jgss.GSSCredential");
+            else
+               out.write("javax.resource.spi.security." + def.getAuthenMechanisms().get(i).getCredentialInterface());
+            out.write("</credential-interface>");
+            writeEol(out);
+            writeIndent(out, indent + 1);
+            out.write("</authentication-mechanism>");
+            writeEol(out);
+         }
+      }
+      
       writeIndent(out, indent + 1);
-      out.write("<reauthentication-support>false</reauthentication-support>");
+      out.write("<reauthentication-support>" + def.isSupportReauthen() + "</reauthentication-support>");
       writeEol(out);
       writeIndent(out, indent);
       out.write("</outbound-resourceadapter>");

Modified: projects/jboss-jca/trunk/codegenerator/src/main/resources/definition.xml
===================================================================
--- projects/jboss-jca/trunk/codegenerator/src/main/resources/definition.xml	2010-06-26 14:59:35 UTC (rev 106294)
+++ projects/jboss-jca/trunk/codegenerator/src/main/resources/definition.xml	2010-06-28 02:30:16 UTC (rev 106295)
@@ -13,7 +13,7 @@
    <ResourceAdapter>AcmeResourceAdapter</ResourceAdapter>
    <RaConfigProp>
       <name>p1</name>
-      <type>java.lang.String</type>
+      <type>String</type>
       <value>hello</value>
    </RaConfigProp>
    <RaAssociation/>
@@ -22,12 +22,22 @@
    <ManagedConnectionFactory>AcmeManagedConnectionFactory</ManagedConnectionFactory>
    <McfConfigProp>
       <name>p2</name>
-      <type>java.lang.Integer</type>
+      <type>Integer</type>
       <value>13</value>
    </McfConfigProp>
    <ManagedConnection>AcmeManagedConnection</ManagedConnection>
 
    <Transaction>LocalTransaction</Transaction>
+   <SupportReauthen>false</SupportReauthen>
+   <SecurityPermission><permissionSpec>MyPermissionSpec</permissionSpec></SecurityPermission>
+   <AuthenMechanism>
+      <authMechanism>BasicPassword</authMechanism>
+      <credentialInterface>PasswordCredential</credentialInterface>
+   </AuthenMechanism>
+   <AuthenMechanism>
+      <authMechanism>BasicPassword</authMechanism>
+      <credentialInterface>GenericCredential</credentialInterface>
+   </AuthenMechanism>
 
    <UseCciConnection>false</UseCciConnection>
    <ConnectionFactoryInterface>AcmeConnectionFactoryInterface</ConnectionFactoryInterface>
@@ -41,11 +51,11 @@
       <ReturnType>void</ReturnType>
       <params>
          <name>m1</name>
-         <type>java.lang.Integer</type>
+         <type>Integer</type>
       </params>
       <params>
          <name>m2</name>
-         <type>java.lang.String</type>
+         <type>String</type>
       </params>
       <ExceptionType>Exception</ExceptionType>
    </Method>
@@ -55,7 +65,7 @@
    <ActivationSpec>AcmeActivationSpec</ActivationSpec>
    <AsConfigProp>
       <name>p3</name>
-      <type>java.lang.Float</type>
+      <type>Float</type>
       <value>3.14</value>
       <required>3.14</required>
    </AsConfigProp>



More information about the jboss-cvs-commits mailing list