Package org.jboss.security

Examples of org.jboss.security.SecurityContext


   {
      static PrivilegedAction ACTION = new GetPrincipalAction();
      public Object run()
      {
         //Principal principal = SecurityAssociation.getPrincipal();
         SecurityContext sc = getSecurityContext();
         if(sc == null)
            throw new IllegalStateException("Security Context is null");
         return sc.getUtil().getUserPrincipal();
      }
View Full Code Here


      static PrivilegedAction ACTION = new GetCredentialAction();
      public Object run()
      {
         //Object credential = SecurityAssociation.getCredential();
         //return credential;
         SecurityContext sc = getSecurityContext();
         if(sc == null)
            throw new IllegalStateException("Security Context is null");
         return sc.getUtil().getCredential();
      }
View Full Code Here

      {
         this.principal = principal;
      }
      public Object run()
      {
         SecurityContext sc = getSecurityContext();
         if(sc == null)
            throw new IllegalStateException("Security Context is null");
         sc.setOutgoingRunAs(principal);
         //SecurityAssociation.pushRunAsIdentity(principal);
         return null;
      }
View Full Code Here

   {
      static PrivilegedAction ACTION = new PopRunAsRoleAction();
      public Object run()
      {
         //RunAsIdentity principal = SecurityAssociation.popRunAsIdentity();
         SecurityContext sc = getSecurityContext();
         if(sc == null)
            throw new IllegalStateException("Security Context is null");
         RunAs principal = null;
         principal = sc.getOutgoingRunAs();
         sc.setOutgoingRunAs(null);
         return principal;
      }
View Full Code Here

   {
      static PrivilegedAction ACTION = new GetAuthExceptionAction();
      public Object run()
      {
         //Object exception = SecurityAssociation.getContextInfo(AUTH_EXCEPTION_KEY);
         SecurityContext sc = getSecurityContext();
         if(sc == null)
            throw new IllegalStateException("Security Context is null");
         Object exception = sc.getData().get(AUTH_EXCEPTION_KEY) ;
         return exception;
      }
View Full Code Here

   {
      static PrivilegedAction ACTION = new ClearAuthExceptionAction();
      public Object run()
      {
         //Object exception = SecurityAssociation.setContextInfo(AUTH_EXCEPTION_KEY, null);
         SecurityContext sc = getSecurityContext();
         if(sc == null)
            throw new IllegalStateException("Security Context is null");
         sc.getData().put(AUTH_EXCEPTION_KEY, null);
         return null;
         //return exception;
      }
View Full Code Here

      this.process(request, response, null);    
   }
  
   private SecurityContext createSecurityContext()
   {
      SecurityContext securityContext = null;
      try
      {
         securityContext =
            SecurityAssociationActions.createSecurityContext(this.configuredSecurityDomainName,
               this.securityContextClass);
      }
      catch (PrivilegedActionException e)
      {
         throw new RuntimeException(e);
      }
     
      securityContext.setSecurityManagement(securityManagement);
      return securityContext;
   }
View Full Code Here

   }
  
   private void process(Request request, Response response, HttpEvent event)
   throws IOException, ServletException
   {
      SecurityContext cachedContext = null;
     
      boolean createdSecurityContext = false;
      //Set the security context if one is unavailable
      SecurityContext sc = SecurityAssociationActions.getSecurityContext();
      if(sc != null &&
            sc.getSecurityDomain().equals(configuredSecurityDomainName) == false)
      {
         cachedContext = sc;
         SecurityContext newSC = createSecurityContext();
         SecurityAssociationActions.setSecurityContext(newSC);
         createdSecurityContext = true;
      }
     
      if(sc == null)
View Full Code Here

        final ObjectCloner resultCloner = ObjectCloners.getSerializingObjectClonerFactory().createCloner(config);
        if (async) {
            if (ejbComponent instanceof SessionBeanComponent) {
                final SessionBeanComponent component = (SessionBeanComponent) ejbComponent;
                final CancellationFlag flag = new CancellationFlag();
                final SecurityContext securityContext = SecurityContextAssociation.getSecurityContext();
                final AsyncInvocationTask task = new AsyncInvocationTask(flag) {

                    @Override
                    protected Object runInvocation() throws Exception {
                        setSecurityContextOnAssociation(securityContext);
View Full Code Here

        final NamespaceContextSelector selector = componentView.getComponent().getNamespaceContextSelector();
        final ClassLoader oldCl = SecurityActions.getContextClassLoader();
        NamespaceContextSelector.pushCurrentSelector(selector);
        try {
            SecurityActions.setContextClassLoader(classLoader);
            SecurityContext sc = null;
            org.omg.CORBA_2_3.portable.OutputStream out;
            try {
                Object retVal;

                if (!home && opName.equals("_get_handle")) {
                    retVal = new HandleImplIIOP(orb.object_to_string(_this_object()));
                } else if (home && opName.equals("_get_homeHandle")) {
                    retVal = homeHandle;
                } else if (home && opName.equals("_get_EJBMetaData")) {
                    retVal = ejbMetaData;
                } else {
                    Transaction tx = null;
                    if (inboundTxCurrent != null)
                        tx = inboundTxCurrent.getCurrentTransaction();
                    if (tx != null) {
                        transactionManager.resume(tx);
                    }
                    try {
                        SimplePrincipal principal = null;
                        Object credential = null;

                        if (sasCurrent != null) {
                            final byte[] incomingName = sasCurrent.get_incoming_principal_name();

                            if ( incomingName != null && incomingName.length > 0) {
                                //we have an identity token, which is a trust based mechanism
                                if (incomingName.length > 0) {
                                    String name = new String(incomingName, "UTF-8");
                                    int domainIndex = name.indexOf('@');
                                    if (domainIndex > 0)
                                        name = name.substring(0, domainIndex);
                                    principal = new SimplePrincipal(name);
                                    //we don't have any real way to establish trust here
                                    //we just use the SASCurrent as a credential, and a custom login
                                    //module can make a decision for us.
                                    credential = sasCurrent;
                                }
                            } else {
                                //the client has just sent a username and password
                                final byte[] username = sasCurrent.get_incoming_username();
                                final byte[] incomingPassword = sasCurrent.get_incoming_password();
                                if(username.length > 0) {
                                    String name = new String(username, "UTF-8");
                                    int domainIndex = name.indexOf('@');
                                    if (domainIndex > 0) {
                                        name = name.substring(0, domainIndex);
                                    }
                                    principal = new SimplePrincipal(name);
                                    credential = new String(incomingPassword, "UTF-8").toCharArray();
                                }
                            }

                            if (securityDomain != null) {
                                sc = SecurityContextFactory.createSecurityContext(securityDomain);
                                sc.getUtil().createSubjectInfo(principal, credential, null);
                            }
                        }
                        final Object[] params = op.readParams((org.omg.CORBA_2_3.portable.InputStream) in);

                        if (!home && opName.equals("isIdentical") && params.length == 1) {
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.