Package org.jboss.security.plugins

Examples of org.jboss.security.plugins.JBossSecurityContext


      new SingletonNamingServer();

      InitialContext ctx = new InitialContext();
      ctx.bind("java:policyRegistration", new SimplePolicyRegistration());

      JBossSecurityContext context = new JBossSecurityContext("TestApp");
      JBossAuthenticationManager authenticationManager = (JBossAuthenticationManager) context.getAuthenticationManager();
      TimedCachePolicy domainCache = new TimedCachePolicy();
      domainCache.create();
      domainCache.start();
      authenticationManager.setCachePolicy(domainCache);
      NonSerializableFactory.rebind(ctx, "java:AuthenticationManager", authenticationManager);
View Full Code Here


*
*/
public class SecurityUtil {

    public static JBossSecurityContextProxy wrapCurrentContext(){
        final JBossSecurityContext current = (JBossSecurityContext) SecurityContextAssociation.getSecurityContext();
        if(current == null){
            return null;
        }
        return new JBossSecurityContextProxy(current);
    }
View Full Code Here

   private EJBAuthorizationHelper eah;
   private RoleGroup methodRoleGroup;
  
   protected void setUp() throws Exception
   {
      sc = new JBossSecurityContext("test");
      eah = new EJBAuthorizationHelper();
      eah.setSecurityContext(sc);
      eah.setPolicyRegistration(new JBossPolicyRegistration());
      methodRoleGroup = SecurityTestUtil.getRoleGroup(new String[]{"roleA", "roleC"});
     
View Full Code Here

   private SecurityContext sc;
   private WebAuthorizationHelper wah;
   
   protected void setUp() throws Exception
   {
      sc = new JBossSecurityContext("test");
      wah = new WebAuthorizationHelper();
      wah.setSecurityContext(sc);
      wah.setPolicyRegistration(new JBossPolicyRegistration());
       
      Map<String,Object> moduleOptions = SecurityTestUtil.getWebDelegateOptions();
View Full Code Here

   public void testCallerPrincipal()
   {
      //With no security context
      assertNull("Caller Principal is null", SecurityAssociation.getCallerPrincipal());
      //Create a security context
      SecurityContext sc =  new JBossSecurityContext("TEST");
      Principal p = new SimplePrincipal("anil");
      sc.getUtil().createSubjectInfo(p, "pass", null);
      SecurityContextAssociation.setSecurityContext(sc);
     
      assertEquals("CallerPrincipal=anil",p,SecurityAssociation.getCallerPrincipal());
     
      //Clear the SecurityContext
      SecurityContextAssociation.clearSecurityContext();
      assertNull("Caller Principal is null", SecurityAssociation.getCallerPrincipal());
     
      //Create a security context with runas
      sc =  new JBossSecurityContext("TEST");
     
      @SuppressWarnings("unchecked")
      RunAs ras = new RunAs()
      {
         public <T> T getIdentity()
         {
            return (T) getName();
         }

         public <T> T getProof()
         {
            return null;
         }

         public String getName()
         {
            return "anil";
         }};
        
      sc.setIncomingRunAs(ras);
      SecurityContextAssociation.setSecurityContext(sc);
      assertEquals("CallerPrincipal=anil",p,SecurityAssociation.getCallerPrincipal());
   }
View Full Code Here

   protected void setUp() throws Exception
   {
      factory = AuthConfigFactory.getFactory();
      factory.registerConfigProvider(new JBossAuthConfigProvider(new HashMap()), layer, appId, "Test Config Provider");

      JBossSecurityContext jsc = new JBossSecurityContext("conf-jaspi-2");
      SecurityContextAssociation.setSecurityContext(jsc);

      XMLLoginConfigImpl xli = XMLLoginConfigImpl.getInstance();
      SecurityActions.setJAASConfiguration(xli);
View Full Code Here

   protected void setUp() throws Exception
   {
      factory = AuthConfigFactory.getFactory();
      factory.registerConfigProvider(new JBossAuthConfigProvider(new HashMap()), layer, appId, "Test Config Provider");

      SecurityContext jsc = new JBossSecurityContext("conf-jaspi");
      SecurityContextAssociation.setSecurityContext(jsc);

      XMLLoginConfigImpl xli = XMLLoginConfigImpl.getInstance();
      SecurityActions.setJAASConfiguration(xli);
View Full Code Here

      assertTrue("DENY?", false == result);
   }

   private boolean getResult(String policyName) throws Exception
  
      SecurityContext securityContext = new JBossSecurityContext(policyName);
      SecurityContextAssociation.setSecurityContext(securityContext);
     
      CallbackHandler handler = new TestCallbackHandler();
      JASPIServerAuthenticationManager aContext = new JASPIServerAuthenticationManager(policyName,
            handler)
View Full Code Here

      xli.loadConfig();
   }

   public void testPermit_Permit_Permit() throws Exception
   {
      JBossSecurityContext sc = new JBossSecurityContext("Permit-Permit-Permit");
      sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
      assertNotNull("SecurityContext is not null", sc);
      IdentityTrustManager itm = sc.getIdentityTrustManager();
      assertNotNull("IdentityTrustManager is not null", itm);
      assertEquals("Is Trusted", TrustDecision.Permit, itm.isTrusted(sc));
   }
View Full Code Here

      assertEquals("Is Trusted", TrustDecision.Permit, itm.isTrusted(sc));
   }

   public void testPermit_Permit_Deny() throws Exception
   {
      JBossSecurityContext sc = new JBossSecurityContext("Permit-Permit-Deny");
      sc.setIncomingRunAs(new RunAsIdentity("theduke", "jduke"));
      assertNotNull("SecurityContext is not null", sc);
      IdentityTrustManager itm = sc.getIdentityTrustManager();
      assertNotNull("IdentityTrustManager is not null", itm);
      assertEquals("Is Trusted Deny", TrustDecision.Deny, itm.isTrusted(sc));
   }
View Full Code Here

TOP

Related Classes of org.jboss.security.plugins.JBossSecurityContext

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.