Package org.jboss.security

Examples of org.jboss.security.SecurityContext


public class JBossSecurityHelper implements SecurityHelper, Serializable {
  private static final long serialVersionUID = 3598997061994110254L;

  @Override
  public boolean assosiateSecurityContext(String securityDomain, Object newContext) {
    SecurityContext context = SecurityActions.getSecurityContext();
    if (context == null || (!context.getSecurityDomain().equals(securityDomain) && newContext != null)) {
      SecurityActions.setSecurityContext((SecurityContext)newContext);
      return true;
    }
    return false;
  }
View Full Code Here


    return false;
  }

  @Override
  public void clearSecurityContext(String securityDomain) {
    SecurityContext sc = SecurityActions.getSecurityContext();
    if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
      SecurityActions.clearSecurityContext();
    }
  }
View Full Code Here

    }
  }
 
  @Override
  public Object getSecurityContext(String securityDomain) {
    SecurityContext sc = SecurityActions.getSecurityContext();
    if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
      return sc;
    }
    return null;
 
View Full Code Here

    return getSecurityContext(securityDomain);
  }

  @Override
  public Subject getSubjectInContext(String securityDomain) {
    SecurityContext sc = SecurityActions.getSecurityContext();
    if (sc != null && sc.getSecurityDomain().equals(securityDomain)) {
      SubjectInfo si = sc.getSubjectInfo();
      Subject subject = si.getAuthenticatedSubject();
      return subject;
    }   
    return null;
  }
View Full Code Here

  }

  @Override
  public boolean sameSubject(String securityDomain, Object context, Subject subject) {
    Assertion.isNotNull(context);
    SecurityContext previousContext = (SecurityContext)context;
    Subject previousUser = previousContext.getSubjectInfo().getAuthenticatedSubject();
   
    SecurityContext currentContext = SecurityActions.getSecurityContext();
    if (currentContext != null && currentContext.getSecurityDomain().equals(securityDomain)) {
      Subject currentUser = currentContext.getSubjectInfo().getAuthenticatedSubject();
      if (previousUser.equals(currentUser)) {
        return true;
      }
    }
    return false;
View Full Code Here

    
     static void pushSecurityContext(final Principal p, final Object cred, final Subject subject, final String securityDomain)
     {
      AccessController.doPrivileged(new PrivilegedAction<Object>() {
        public Object run() {
          SecurityContext sc;
          try {
            sc = SecurityContextFactory.createSecurityContext(p, cred, subject, securityDomain);
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
View Full Code Here

public class JBossSecurityServices implements SecurityServices
{

   public Principal getPrincipal()
   {
      SecurityContext sc = SecurityContextAssociation.getSecurityContext();
      return sc.getUtil().getUserPrincipal();
   }
View Full Code Here

    * @inheritDoc
    *
    */
   public synchronized Subject authenticate(Object creds) {
      AuthenticationManager am;
      SecurityContext securityContext;

      // wine and complain if we don't get what we expect.
      if (creds == null) {
         throw new SecurityException(
            "JMXConnectorAuthenticator requires userid/password credentials to be passed in");
      }
      if (! (creds instanceof String[])) {
         // only support passing in array of Strings
         throw new SecurityException(
            "JMXConnectorAuthenticator can only handle authentication parameter that is array of two strings, instead got " +
            creds.getClass().getName());
      }
      String[] pair = (String[]) creds;
      if( pair.length != 2 ) {
         // only support passing userid + password
         throw new SecurityException(
            "JMXConnectorAuthenticator can only handle authentication parameter that is array of two strings, instead got " +
         pair.length +" strings");
      }

      String user, pass;
      user = pair[0];
      pass = pair[1];
      Principal principal = new JMXPrincipal(user);
      Subject subject = new Subject();

      securityContext = SecurityFactory.establishSecurityContext(securityDomainName);
      am = securityContext.getAuthenticationManager();

      boolean result = am.isValid(principal, pass , subject);
      if( result ) {
         subject.setReadOnly();
      }
View Full Code Here

            {
               // Security-domain use-case
               try
               {
                  // Create a security context on the association
                  SecurityContext securityContext = SecurityContextFactory.createSecurityContext(recoverSecurityDomain);
                  SecurityContextAssociation.setSecurityContext(securityContext);
              
                  // 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);

                  // Select the domain
                  String domain = recoverSecurityDomain;
                  if (domain == null)
                     domain = securityDomain;
View Full Code Here

            return getNext().invoke(mi);
         else
            return getNext().invokeHome(mi);
      }

      SecurityContext sc = SecurityActions.getSecurityContext();
      if (sc == null)
         throw new IllegalStateException("Security Context is null");

      RunAs callerRunAsIdentity = sc.getIncomingRunAs();
      if (log.isTraceEnabled())
         log.trace("Caller RunAs=" + callerRunAsIdentity + ": useCallerIdentity=" + this.isUseCallerIdentity);
      // Authenticate the subject and apply any declarative security checks
      try
      {
View Full Code Here

TOP

Related Classes of org.jboss.security.SecurityContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.