Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

https://jira.jboss.org/browse/HORNETQ-415 - Setting the subject properly

  • Loading branch information...
commit f57cfa6a54c7a72b28fe0a8e9a56edd5a3d27dee 1 parent 0868ec5
@clebertsuconic clebertsuconic authored
Showing with 31 additions and 11 deletions.
  1. +31 −11 src/main/org/hornetq/integration/jboss/security/SecurityActions.java
View
42 src/main/org/hornetq/integration/jboss/security/SecurityActions.java
@@ -19,6 +19,7 @@
import javax.security.auth.Subject;
+import org.hornetq.core.logging.Logger;
import org.jboss.security.SecurityContext;
import org.jboss.security.SecurityContextAssociation;
import org.jboss.security.SecurityContextFactory;
@@ -31,6 +32,8 @@
*/
class SecurityActions
{
+ private static final Logger log = Logger.getLogger(JBossASSecurityManager.class);
+
interface PrincipalInfoAction
{
PrincipalInfoAction PRIVILEGED = new PrincipalInfoAction()
@@ -44,23 +47,40 @@ public void push(final Principal principal,
{
public Object run()
{
- // SecurityAssociation.pushSubjectContext(subject, principal, credential);
- SecurityContext sc = SecurityContextAssociation.getSecurityContext();
- if (sc == null)
+
+ try
{
- try
+ log.info("========================================================");
+ log.info("Setting subject = " + subject);
+ // SecurityAssociation.pushSubjectContext(subject, principal, credential);
+ SecurityContext sc = SecurityContextAssociation.getSecurityContext();
+ if (sc == null)
{
- sc = SecurityContextFactory.createSecurityContext(principal,
- credential,
- subject,
- securityDomain);
+ try
+ {
+ sc = SecurityContextFactory.createSecurityContext(principal,
+ credential,
+ subject,
+ securityDomain);
+ }
+ catch (Exception e)
+ {
+ throw new RuntimeException(e);
+ }
}
- catch (Exception e)
+ else
{
- throw new RuntimeException(e);
+ sc.getUtil().createSubjectInfo(principal, credential, subject);
}
+
+ SecurityContextAssociation.setSecurityContext(sc);
+ log.info("========================================================");
+ }
+ catch (Throwable t)
+ {
+ log.warn("An error happened while setting the context", t);
}
- SecurityContextAssociation.setSecurityContext(sc);
+
return null;
}
});
Please sign in to comment.
Something went wrong with that request. Please try again.