Package org.jboss.security.javaee

Examples of org.jboss.security.javaee.EJBAuthenticationHelper


         throw new SecurityException("Role mapping manager has not been set");
      }

      SecurityContext sc = SecurityActions.getSecurityContext();

      EJBAuthenticationHelper helper = SecurityHelperFactory.getEJBAuthenticationHelper(sc);
      boolean isTrusted = containsTrustableRunAs(sc) || helper.isTrusted();

      if (!isTrusted)
      {
         // Check the security info from the method invocation
         Subject subject = new Subject();
View Full Code Here


         }
      });
      SecurityContextAssociation.setSecurityContext(sc);
      try
      {
         EJBAuthenticationHelper authenticationHelper = SecurityHelperFactory.getEJBAuthenticationHelper(sc);
         Subject subject = new Subject();
         boolean isValid = authenticationHelper.isValid(subject, "getCallerPrincipal");
         if(!isValid)
         {
            Exception cause = (Exception) sc.getData().get("org.jboss.security.exception");
            throw new RuntimeException("no valid principal", cause);
         }
         authenticationHelper.pushSubjectContext(subject);
         //RealmMapping rm = (RealmMapping) sc.getAuthenticationManager();
         RealmMapping rm = lookup("java:AuthenticationManager", RealmMapping.class);
         SecurityDomain domain = null;
         return helper.getCallerPrincipal(sc, rm, domain);
      }
View Full Code Here

               }
            });
           
             
            //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);
                  subject.getPrincipals().add(unauthenticatedIdentity.asPrincipal());
               }
               else
               {
                  //Authenticate the caller now
                  if(!helper.isValid(subject, method.getName()))
                     throw new EJBAccessException("Invalid User");
               }
               helper.pushSubjectContext(subject);
            }
            else
           
               //Trusted caller. No need for authentication. Straight to authorization
            }
View Full Code Here

               }
            });
           
             
            //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);
                  subject.getPrincipals().add(unauthenticatedIdentity.asPrincipal());
               }
               else
               {
                  //Authenticate the caller now
                  if(!helper.isValid(subject, method.getName()))
                     throw new EJBAccessException("Invalid User");
               }
               helper.pushSubjectContext(subject);
            }
            else
           
               //Trusted caller. No need for authentication. Straight to authorization
            }
View Full Code Here

            }
         });
        
          
         //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
             */
            String unauthenticatedPrincipal = domain.unauthenticatedPrincipal();
            if(sc.getUtil().getUserPrincipal() == null && unauthenticatedPrincipal !=null &&
                  unauthenticatedPrincipal.length() > 0)
            {
               Identity unauthenticatedIdentity = new SimpleIdentity(unauthenticatedPrincipal);
               sc.getSubjectInfo().addIdentity(unauthenticatedIdentity);
               subject.getPrincipals().add(unauthenticatedIdentity.asPrincipal());
            }
            else
            {
               //Authenticate the caller now
               if(!helper.isValid(subject, method.getName()))
                  throw new EJBAccessException("Invalid User");
            }
            helper.pushSubjectContext(subject);
         }
         else
        
            //Trusted caller. No need for authentication. Straight to authorization
         }
View Full Code Here

           
         //TODO: Need to get the SecurityManagement instance
         sc.setSecurityManagement(getSecurityManagement());
          
         //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();
            //Authenticate the caller now
            if(!helper.isValid(subject, method.getName()))
               throw new EJBAccessException("Invalid User");
            helper.pushSubjectContext(subject);
         }
         else
        
            //Trusted caller. No need for authentication. Straight to authorization
         }
View Full Code Here

         throw new SecurityException("Role mapping manager has not been set");
      }

      SecurityContext sc = SecurityActions.getSecurityContext();

      EJBAuthenticationHelper helper = SecurityHelperFactory.getEJBAuthenticationHelper(sc);
      boolean isTrusted = containsTrustableRunAs(sc) || helper.isTrusted();

      if (!isTrusted)
      {
         // Check the security info from the method invocation
         Subject subject = new Subject();
View Full Code Here

           
         //TODO: Need to get the SecurityManagement instance
         sc.setSecurityManagement(getSecurityManagement());
          
         //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 = helper.isTrusted();
         if(!trustedCaller)
         {
            Subject subject = new Subject();
            //Authenticate the caller now
            if(!helper.isValid(subject, method.getName()))
               throw new EJBAccessException("Invalid User");
            helper.pushSubjectContext(subject);
         }
         else
        
            //Trusted caller. No need for authentication. Straight to authorization
         }
View Full Code Here

               }
            });
           
             
            //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);
                  subject.getPrincipals().add(unauthenticatedIdentity.asPrincipal());
               }
               else
               {
                  //Authenticate the caller now
                  if(!helper.isValid(subject, method.getName()))
                     throw new EJBAccessException("Invalid User");
               }
               helper.pushSubjectContext(subject);
            }
            else
           
               //Trusted caller. No need for authentication. Straight to authorization
            }
View Full Code Here

{
   private SecurityContext sc = new JBossSecurityContext("test");
   
   public void testEJBAuthenticationHelper()
   {
     EJBAuthenticationHelper eah = SecurityHelperFactory.getEJBAuthenticationHelper(sc);    
     assertNotNull("auth helper",eah);
   }
View Full Code Here

TOP

Related Classes of org.jboss.security.javaee.EJBAuthenticationHelper

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.