Package org.jboss.ejb3.annotation

Examples of org.jboss.ejb3.annotation.SecurityDomain


                  .getUnauthenticatedPrincipal());

         addClassAnnotation(container, annotation.annotationType(), annotation);
      } else if (dd.getUnauthenticatedPrincipal() != null)
      {
         SecurityDomain annotation = ejbClass.getAnnotation(SecurityDomain.class);
         SecurityDomainImpl override;
         if (annotation != null)
         {
            override = new SecurityDomainImpl(annotation.value());
            override.setUnauthenticatedPrincipal(dd
                  .getUnauthenticatedPrincipal());
         }
         else
         {
View Full Code Here


            shelper.isMDB(container))
         return invocation.invokeNext();
     
      try
      {
         SecurityDomain domain = (SecurityDomain)container.getAnnotation(SecurityDomain.class);
        
         boolean domainExists = domain != null && domain.value() != null
         && domain.value().length() > 0;
        
         if(domainExists)
         {
            SecurityContext sc = SecurityActions.getSecurityContext();
            if(sc == null)
View Full Code Here

   public Object createPerClass(Advisor advisor)
   {
      // Must be a separate line (EJBContainer cannot be dereferenced)
      EJBContainer container = EJBContainer.getEJBContainer(advisor);
      SecurityDomain securityAnnotation = (SecurityDomain) advisor.resolveAnnotation(SecurityDomain.class);
        
      //If there is no annotation, return a null action interceptor
      if(securityAnnotation == null)
         return new NullInterceptor();
      CodeSource ejbCS = advisor.getClazz().getProtectionDomain().getCodeSource();
View Full Code Here

         return invocation.invokeNext();
      
      SecurityContext prevSC = SecurityActions.getSecurityContext();
      SecurityContext invSC = (SecurityContext) invocation.getMetaData("security","context");
     
      SecurityDomain domain = container.getAnnotation(SecurityDomain.class);
     
      boolean domainExists = domain != null && domain.value() != null
                    && domain.value().length() > 0;
      
      /**
       * TODO: Decide if you want to allow zero security based on non-availability
       * of a security domain, as per the configuration on the container
       */
      if(domainExists)
      { 
         String domainValue = canonicalizeSecurityDomain(domain.value());
        
         /* Need to establish the security context. For local calls, we pick the outgoing runas
          * of the existing sc. For remote calls, we create a new security context with the information
          * from the invocation sc
          */
 
View Full Code Here

   public Principal getCallerPrincipal()
   {
      if(beanPrincipal == null)
      {
         EJBContainer ec = (EJBContainer) container;
         SecurityDomain domain = ec.getAnnotation(SecurityDomain.class);
         Principal callerPrincipal = ejbContextHelper.getCallerPrincipal(SecurityActions.getSecurityContext(),
               rm, domain);
                
         // This method never returns null.
         if (callerPrincipal == null)
View Full Code Here

   public <T> T getSecurityManager(Class<T> type)
   {
      try
      {
         InitialContext ctx = getInitialContext();
         SecurityDomain securityAnnotation = (SecurityDomain) resolveAnnotation(SecurityDomain.class);
         if (securityAnnotation != null && securityAnnotation.value().length() > 0)
         {
            return (T) SecurityDomainManager.getSecurityManager(securityAnnotation.value(),ctx);
         }
         return null;
      }
      catch (NamingException e)
      {
View Full Code Here

    * @see EJBContext#getCallerPrincipal()
    */
   public Principal getCallerPrincipal()
   {
      EJBContainer ec = (EJBContainer) container;
      SecurityDomain domain = ec.getAnnotation(SecurityDomain.class);
      Principal callerPrincipal = ejbContextHelper.getCallerPrincipal(SecurityActions.getSecurityContext(),
            rm, domain);
             
      // This method never returns null.
      if (callerPrincipal == null)
View Full Code Here

      Object domain = null;
      try
      {
         InitialContext ctx = container.getInitialContext();
         SecurityDomain securityDomain = (SecurityDomain) advisor.resolveAnnotation(SecurityDomain.class);
         if (securityDomain != null)
         {
            String domainName = securityDomain.value();
            domain = SecurityDomainManager.getSecurityManager(domainName, ctx);
         }
      }
      catch (NamingException e)
      {
View Full Code Here

       * through AuthenticationInterceptor. This is probably because
       * we are an MDB. So create a new SecurityContext
       */
      if(sc == null)
      {
         SecurityDomain domain = (SecurityDomain)container.resolveAnnotation(SecurityDomain.class);
         if(domain != null)
         {
            sc = SecurityActions.createSecurityContext(domain.value());
            SecurityActions.setSecurityContext(sc);
        
      }
     
      if(sc != null)
View Full Code Here

      try
      {
         // See org.jboss.ejb3.security.client.SecurityClientInterceptor
         SecurityContext invSC = (SecurityContext) invocation.getMetaData("security","context");
        
         SecurityDomain domain = container.getAnnotation(SecurityDomain.class);
        
         boolean domainExists = domain != null && domain.value() != null
                       && domain.value().length() > 0;
         
         /**
          * TODO: Decide if you want to allow zero security based on non-availability
          * of a security domain, as per the configuration on the container
          */
         if(domainExists)
         { 
            String domainValue = canonicalizeSecurityDomain(domain.value());
           
            /* Need to establish the security context. For local calls, we pick the outgoing runas
             * of the existing sc. For remote calls, we create a new security context with the information
             * from the invocation sc
             */
            final SecurityContext sc = SecurityActions.createSecurityContext(domainValue);

            if(invSC == null)
            {
               if(prevSC == null)
                  throw new IllegalStateException("Local Call: Security Context is null");
               populateSecurityContext(sc, prevSC);
            }
            else
            {
               populateSecurityContext(sc, invSC);
            }
           
            SecurityActions.setSecurityContext(sc);
              
            //TODO: Need to get the SecurityManagement instance
            AccessController.doPrivileged(new PrivilegedExceptionAction<Object>()
            {
               public Object run() throws Exception
               {
                  sc.setSecurityManagement(getSecurityManagement());
                  return null;
               }
            });
           
             
            //Check if there is a RunAs configured and can be trusted
            EJBAuthenticationHelper helper = null;
            try
            {
               helper = SecurityHelperFactory.getEJBAuthenticationHelper(sc);
            }
            catch(Exception e)
            {
               throw new RuntimeException(e);
            }
            boolean trustedCaller = hasIncomingRunAsIdentity(sc) || helper.isTrusted();
            if(!trustedCaller)
            {
               Subject subject = new Subject();
               /**
                * Special Case: Invocation has no principal set,
                * but an unauthenticatedPrincipal has been configured in JBoss DD
                */
               Principal userPrincipal = sc.getUtil().getUserPrincipal();
               String unauthenticatedPrincipal = domain.unauthenticatedPrincipal();
               if(userPrincipal == null && unauthenticatedPrincipal !=null &&
                     unauthenticatedPrincipal.length() > 0)
               {
                  Identity unauthenticatedIdentity = new SimpleIdentity(unauthenticatedPrincipal);
                  sc.getSubjectInfo().addIdentity(unauthenticatedIdentity);
View Full Code Here

TOP

Related Classes of org.jboss.ejb3.annotation.SecurityDomain

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.