[jboss-cvs] JBossAS SVN: r105635 - branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Jun 3 08:46:32 EDT 2010
Author: jesper.pedersen
Date: 2010-06-03 08:46:32 -0400 (Thu, 03 Jun 2010)
New Revision: 105635
Modified:
branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java
Log:
[JBPAPP-4375] Changed fallback semantics for recovery
Modified: branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java
===================================================================
--- branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java 2010-06-03 11:28:04 UTC (rev 105634)
+++ branches/JBPAPP_5_1/connector/src/main/org/jboss/resource/connectionmanager/ManagedConnectionFactoryDeployment.java 2010-06-03 12:46:32 UTC (rev 105635)
@@ -149,6 +149,7 @@
private XAResourceRecoveryRegistry xrrr = null;
private SubjectFactory subjectFactory = null;
private ManagedConnection recoverMC = null;
+ private String securityDomain = null;
private String recoverSecurityDomain = null;
private String recoverUserName = null;
private String recoverPassword = null;
@@ -440,15 +441,16 @@
// If we have an XAResourceRecoveryRegistry and the deployment is XA
// lets register it for XA Resource Recovery using the "recover" definitions
// from the -ds.xml file. Fallback to the standard definitions for
- // user name, password and security-domain
+ // user name, password. Keep a seperate reference to the security-domain
SecurityMetaData recoverSecurityDomainMD = xdsdm.getRecoverSecurityMetaData();
- if (recoverSecurityDomainMD == null)
- recoverSecurityDomainMD = xdsdm.getSecurityMetaData();
-
if (recoverSecurityDomainMD != null)
recoverSecurityDomain = recoverSecurityDomainMD.getDomain();
+ SecurityMetaData securityDomainMD = xdsdm.getSecurityMetaData();
+ if (securityDomainMD != null)
+ securityDomain = securityDomainMD.getDomain();
+
recoverUserName = xdsdm.getRecoverUserName();
recoverPassword = xdsdm.getRecoverPassWord();
@@ -473,18 +475,28 @@
if (recoverUserName == null)
recoverUserName = xdsdm.getUserName();
- if (recoverPassword == null)
+ if (recoverPassword == null)
recoverPassword = xdsdm.getPassWord();
if (log.isDebugEnabled())
log.debug("Registered for XA Resource Recovery: " + xdsdm.getJndiName());
if (log.isDebugEnabled())
- log.debug("RecoverUserName=" + recoverUserName);
+ {
+ if (recoverUserName != null)
+ {
+ log.debug("RecoverUserName=" + recoverUserName);
+ }
+ else if (recoverSecurityDomain != null)
+ {
+ log.debug("RecoverSecurityDomain=" + recoverSecurityDomain);
+ }
+ else if (securityDomain != null)
+ {
+ log.debug("RecoverSecurityDomain=" + securityDomain);
+ }
+ }
- if (log.isDebugEnabled())
- log.debug("RecoverSecurityDomain=" + recoverSecurityDomain);
-
getXAResourceRecoveryRegistry().addXAResourceRecovery(this);
recoveryRegistered = true;
}
@@ -639,7 +651,7 @@
{
public Subject run()
{
- if (recoverUserName != null && recoverPassword != null && recoverSecurityDomain == null)
+ if (recoverUserName != null && recoverPassword != null)
{
// User name and password use-case
Subject subject = new Subject();
@@ -670,25 +682,26 @@
SecurityContext securityContext = SecurityContextFactory.createSecurityContext(recoverSecurityDomain);
SecurityContextAssociation.setSecurityContext(securityContext);
- if (recoverUserName != null && recoverPassword != null)
- {
- Subject userPassword = new Subject();
-
- // Principals
- Principal principal = new SimplePrincipal(recoverUserName);
- userPassword.getPrincipals().add(principal);
-
- // Credentials
- PasswordCredential credential = new PasswordCredential(recoverUserName, recoverPassword.toCharArray());
- credential.setManagedConnectionFactory(mcf);
- userPassword.getPrivateCredentials().add(credential);
+ // Unauthenticated
+ Subject unauthenticated = new Subject();
- // Set the authenticated subject
- securityContext.getSubjectInfo().setAuthenticatedSubject(userPassword);
+ // Leave the subject empty as we don't have any information to do the
+ // authentication with - and we only need it to be able to get the
+ // real subject from the SubjectFactory
+
+ // Set the authenticated subject
+ securityContext.getSubjectInfo().setAuthenticatedSubject(unauthenticated);
- // Use the userPassword subject to get the real recovery subject instance
- Subject subject = subjectFactory.createSubject(recoverSecurityDomain);
+ // Select the domain
+ String domain = recoverSecurityDomain;
+ if (domain == null)
+ domain = securityDomain;
+ if (domain != null)
+ {
+ // Use the unauthenticated subject to get the real recovery subject instance
+ Subject subject = subjectFactory.createSubject(domain);
+
if (log.isDebugEnabled())
log.debug("Recovery Subject=" + subject);
@@ -696,23 +709,8 @@
}
else
{
- // Unauthenticated
- Subject unauthenticated = new Subject();
-
- // Leave the subject empty as we don't have any information to do the
- // authentication with - and we only need it to be able to get the
- // real subject from the SubjectFactory
-
- // Set the authenticated subject
- securityContext.getSubjectInfo().setAuthenticatedSubject(unauthenticated);
-
- // Use the unauthenticated subject to get the real recovery subject instance
- Subject subject = subjectFactory.createSubject(recoverSecurityDomain);
-
if (log.isDebugEnabled())
- log.debug("Recovery Subject=" + subject);
-
- return subject;
+ log.debug("RecoverySecurityDomain was empty");
}
}
catch (Throwable t)
More information about the jboss-cvs-commits
mailing list