// Principals
Principal p = new SimplePrincipal(recoverUserName);
subject.getPrincipals().add(p);
// PrivateCredentials
PasswordCredential pc = new PasswordCredential(recoverUserName, recoverPassword.toCharArray());
pc.setManagedConnectionFactory(mcf);
subject.getPrivateCredentials().add(pc);
// PublicCredentials
// None
log.debugf("Recovery Subject=%s", subject);
return subject;
}
else
{
// Security-domain use-case
try
{
// Select the domain
String domain = recoverSecurityDomain;
if (domain != null && subjectFactory != null)
{
Subject subject = subjectFactory.createSubject(domain);
Set<PasswordCredential> pcs = subject.getPrivateCredentials(PasswordCredential.class);
if (pcs != null && pcs.size() > 0)
{
for (PasswordCredential pc : pcs)
{
pc.setManagedConnectionFactory(mcf);
}
}
log.debugf("Recovery Subject=%s", subject);