Package org.jboss.soa.esb.services.security

Examples of org.jboss.soa.esb.services.security.SecurityContext


    TestPrincipal principal = new TestPrincipal(userName);
    Set<Object> credentials = new HashSet<Object>();
    credentials.add(password);

    AuthenticationRequest authRequest = new AuthenticationRequestImpl.Builder(principal, credentials).build();
    SecurityContext context = new SecurityContext(subject, SecurityContext.getConfigurationTimeout());
    service.configure();
    service.authenticate(configInfo, context, authRequest);

    Set<TestPrincipal> principals = subject.getPrincipals( TestPrincipal.class );
    assertEquals( 1, principals.size() );
View Full Code Here


  public void authenticateWithRole() throws ConfigurationException, SecurityServiceException
  {
    Builder builder = new SecurityConfig.Builder("SuccessfulLogin");
    builder.runAs("adminRole");
    SecurityConfig configInfo = builder.build();
    SecurityContext context = new SecurityContext(subject, SecurityContext.getConfigurationTimeout());
    service.authenticate(configInfo, context, null);
    Set<Principal> principals = subject.getPrincipals( Principal.class );
    assertEquals( 2, principals.size() );
  }
View Full Code Here

    Group group = new Group("Roles");
    group.addMember(new Role("adminRole1"));

    subject.getPrincipals().add(group);

    SecurityContext context = new SecurityContext(subject, SecurityContext.getConfigurationTimeout());
    service.authenticate(configInfo, context, null);

    Set<Principal> principals = subject.getPrincipals( Principal.class );
    assertEquals( 2, principals.size() );
  }
View Full Code Here

  {
    final String roleName = "adminRole";
    Builder builder = new SecurityConfig.Builder("SuccessfulLogin");
    builder.runAs(roleName);
    SecurityConfig configInfo = builder.build();
    SecurityContext context = new SecurityContext(subject, SecurityContext.getConfigurationTimeout());
    service.authenticate(configInfo, context, null);
    assertTrue( service.isCallerInRole(subject, new Role(roleName)));
  }
View Full Code Here

  @Test ( expected = SecurityServiceException.class )
  public void loginFailure() throws ConfigurationException, SecurityServiceException
  {
    Builder builder = new SecurityConfig.Builder("FailureLogin");
    SecurityConfig configInfo = builder.build();
    SecurityContext context = new SecurityContext(subject, SecurityContext.getConfigurationTimeout());
    service.authenticate( configInfo, context, null );
  }
View Full Code Here

    {
        Builder builder = new SecurityConfig.Builder("SuccessfulLogin");
        builder.runAs("esbRole");
        builder.rolesAllowed("esbRole");
        SecurityConfig configInfo = builder.build();
    SecurityContext context = new SecurityContext(subject, SecurityContext.getConfigurationTimeout());
        service.authenticate( configInfo, context, null );
        boolean checkRolesAllowed = service.checkRolesAllowed(configInfo.getRolesAllowed(), context);
        assertTrue(checkRolesAllowed);
    }
View Full Code Here

  private void threadLogin() throws SecurityServiceException
  {
    Builder builder = new SecurityConfig.Builder("SuccessfulLogin");
    SecurityConfig configInfo = builder.build();
    SecurityContext context = new SecurityContext(new Subject(), SecurityContext.getConfigurationTimeout());
    try
    {
      service.authenticate( configInfo, context, null );
    }
    catch (SecurityServiceException e)
View Full Code Here

    @Test
    public void pushAndPop()
    {
        final SecurityConfig securityConfig = getSecurityConfig();
        final SecurityContext context = getSecurityContext();

        propagator.pushSecurityContext(context, null, securityConfig, as4Operations);

        Subject pushedSubject = SecurityAssociation.getSubject();
        assertEquals(context.getSubject(), pushedSubject);

        propagator.popSecurityContext(context, securityConfig, as4Operations);
        pushedSubject = SecurityAssociation.getSubject();
        assertNull(pushedSubject);
    }
View Full Code Here

    @Test
    public void pushAndPopWithNullSecurityConfig()
    {
        final SecurityConfig securityConfig = getSecurityConfig();
        final SecurityContext context = getSecurityContext();

        propagator.pushSecurityContext(context, null, null, as4Operations);

        Subject pushedSubject = SecurityAssociation.getSubject();
        assertEquals(context.getSubject(), pushedSubject);

        propagator.popSecurityContext(context, securityConfig, as4Operations);
        pushedSubject = SecurityAssociation.getSubject();
        assertNull(pushedSubject);
    }
View Full Code Here

    @Test
    public void pushAndPopAS5()
    {
        final SecurityConfig securityConfig = getSecurityConfig();
        final SecurityContext context = getSecurityContext();

        propagator.pushSecurityContext(context, null, securityConfig, as5Operations);

        final org.jboss.security.SecurityContext securityContext = SecurityContextAssociation.getSecurityContext() ;
        assertNotNull("securityContext", securityContext) ;
       
        final SubjectInfo subjectInfo = securityContext.getSubjectInfo() ;
        assertNotNull("subjectInfo", subjectInfo) ;
       
        final Subject pushedSubject = subjectInfo.getAuthenticatedSubject() ;
        assertEquals("Subject comparison", context.getSubject(), pushedSubject);

        propagator.popSecurityContext(context, securityConfig, as5Operations);
        assertNull("securityContext", SecurityContextAssociation.getSecurityContext());
    }
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.services.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.