[jboss-cvs] JBossAS SVN: r110784 - in projects/jboss-jca/trunk: doc/userguide/en-US/modules and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Feb 25 10:25:46 EST 2011
Author: jesper.pedersen
Date: 2011-02-25 10:25:46 -0500 (Fri, 25 Feb 2011)
New Revision: 110784
Modified:
projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/security/DefaultSubjectFactory.java
projects/jboss-jca/trunk/doc/userguide/en-US/modules/configuration.xml
projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml
Log:
Expose SubjectFactory properties for easier configuration
Modified: projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/security/DefaultSubjectFactory.java
===================================================================
--- projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/security/DefaultSubjectFactory.java 2011-02-25 14:39:29 UTC (rev 110783)
+++ projects/jboss-jca/trunk/core/src/main/java/org/jboss/jca/core/security/DefaultSubjectFactory.java 2011-02-25 15:25:46 UTC (rev 110784)
@@ -26,16 +26,28 @@
import org.jboss.security.SubjectFactory;
+/**
+ * Implements a basic subject factory
+ */
public class DefaultSubjectFactory implements SubjectFactory
{
+ /** The security domain name */
+ private String securityDomain;
- private final String securityDomain;
+ /** The user name */
+ private String userName;
- private final String userName;
+ /** The password */
+ private String password;
- private final String password;
+ /**
+ * Create a new DefaultSubjectFactory.
+ */
+ public DefaultSubjectFactory()
+ {
+ this(null, null, null);
+ }
-
/**
* Create a new DefaultSubjectFactory.
*
@@ -45,22 +57,53 @@
*/
public DefaultSubjectFactory(String securityDomain, String userName, String password)
{
- super();
this.securityDomain = securityDomain;
this.userName = userName;
this.password = password;
}
+ /**
+ * Set the security domain
+ * @param v The value
+ */
+ public void setSecurityDomain(String v)
+ {
+ this.securityDomain = v;
+ }
+
+ /**
+ * Set the user name
+ * @param v The value
+ */
+ public void setUserName(String v)
+ {
+ this.userName = v;
+ }
+
+ /**
+ * Set the password
+ * @param v The value
+ */
+ public void setPassword(String v)
+ {
+ this.password = v;
+ }
+
@Override
public Subject createSubject()
{
+ if (userName == null)
+ throw new IllegalStateException("UserName is null");
+
+ if (password == null)
+ throw new IllegalStateException("Password is null");
+
Subject subject = new Subject();
PasswordCredential credential = new PasswordCredential(userName, password.toCharArray());
subject.getPrivateCredentials().add(credential);
return subject;
}
-
@Override
public Subject createSubject(String securityDomain)
{
@@ -119,6 +162,5 @@
return "DefaultSubjectFactory [securityDomain=" + securityDomain + ", userName=" + userName + ", password=" +
password + "]";
}
-
}
Modified: projects/jboss-jca/trunk/doc/userguide/en-US/modules/configuration.xml
===================================================================
--- projects/jboss-jca/trunk/doc/userguide/en-US/modules/configuration.xml 2011-02-25 14:39:29 UTC (rev 110783)
+++ projects/jboss-jca/trunk/doc/userguide/en-US/modules/configuration.xml 2011-02-25 15:25:46 UTC (rev 110784)
@@ -438,6 +438,28 @@
]]>
</programlisting>
+ <para>There is support for creating a basic security domain which can provide
+ a <code>javax.security.auth.Subject</code> instance to deployments that
+ are using <code><security-domain></code> or
+ <code><security-domain-and-application></code> in their setup.</para>
+
+ <para>A security domain can be configured through</para>
+
+ <programlisting language="xml">
+ <![CDATA[
+<!-- SubjectFactory -->
+<bean name="DefaultSecurityDomain"
+ interface="org.jboss.security.SubjectFactory"
+ class="org.jboss.jca.core.security.DefaultSubjectFactory">
+ <property name="SecurityDomain">DefaultSecurityDomain</property>
+ <property name="UserName">user</property>
+ <property name="Password">password</property>
+</bean>
+ ]]>
+ </programlisting>
+
+ <para>beans.</para>
+
</section>
</section>
Modified: projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml
===================================================================
--- projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml 2011-02-25 14:39:29 UTC (rev 110783)
+++ projects/jboss-jca/trunk/embedded/src/main/resources/jca.xml 2011-02-25 15:25:46 UTC (rev 110784)
@@ -150,6 +150,15 @@
<bean name="ManagementRepository"
class="org.jboss.jca.core.api.management.ManagementRepository"/>
+ <!-- SubjectFactory -->
+ <bean name="DefaultSecurityDomain"
+ interface="org.jboss.security.SubjectFactory"
+ class="org.jboss.jca.core.security.DefaultSubjectFactory">
+ <property name="SecurityDomain">DefaultSecurityDomain</property>
+ <property name="UserName">user</property>
+ <property name="Password">password</property>
+ </bean>
+
<!-- Deployer configuration -->
<bean name="DeployerConfiguration"
class="org.jboss.jca.deployers.fungal.RAConfiguration">
@@ -218,15 +227,4 @@
<depends>JBossStdioContextSelector</depends>
</bean>
- <!-- SubjectFactory -->
- <bean name="default-domain-subjectfactory"
- interface="org.jboss.security.SubjectFactory"
- class="org.jboss.jca.core.security.DefaultSubjectFactory">
- <constructor>
- <parameter>default-context</parameter>
- <parameter>user-name</parameter>
- <parameter>password</parameter>
- </constructor>
- </bean>
-
</deployment>
More information about the jboss-cvs-commits
mailing list