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

Examples of org.jboss.soa.esb.services.security.SecurityConfig.Builder


  @Test
  public void authenticateUserpassword() throws ConfigurationException, SecurityServiceException
  {
    final String userName = "testUser";
    final String password = "testPassword";
    Builder builder = new SecurityConfig.Builder("UserPassLogin");
    builder.callBackhandler("org.jboss.internal.soa.esb.services.security.UserPassCallbackHandler");
    SecurityConfig configInfo = builder.build();
    TestPrincipal principal = new TestPrincipal(userName);
    Set<Object> credentials = new HashSet<Object>();
    credentials.add(password);

    AuthenticationRequest authRequest = new AuthenticationRequestImpl.Builder(principal, credentials).build();
View Full Code Here


  }

  @Test
  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

  }

  @Test
  public void authenticateWithExistingRole() throws ConfigurationException, SecurityServiceException
  {
    Builder builder = new SecurityConfig.Builder("SuccessfulLogin");
    builder.runAs("adminRole");
    SecurityConfig configInfo = builder.build();
    Group group = new Group("Roles");
    group.addMember(new Role("adminRole1"));

    subject.getPrincipals().add(group);
View Full Code Here

  @Test
  public void isCallerInRole() throws SecurityServiceException
  {
    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

  }

  @Test
    public void rolesAllowed() throws ConfigurationException, SecurityServiceException
    {
        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 );
    }
View Full Code Here

  public static SecurityConfig createSecurityConfig(final ConfigTree securityFragment)
  {
    final String moduleName = securityFragment.getAttribute(ListenerTagNames.MODULE_NAME_TAG);

    Builder builder = new SecurityConfig.Builder(moduleName);
    builder.runAs(securityFragment.getAttribute(ListenerTagNames.RUN_AS_TAG));
    builder.useCallerIdentity(securityFragment.getAttribute(ListenerTagNames.USE_CALLERS_IDENTIDY_TAG));
    builder.rolesAllowed(securityFragment.getAttribute(ListenerTagNames.ROLES_ALLOWED));
    builder.callBackhandler(securityFragment.getAttribute(ListenerTagNames.CALLBACK_HANDLER_TAG));

    ConfigTree[] children = securityFragment.getChildren("property");
    for (ConfigTree configTree : children)
    {
      String propertyName = configTree.getAttribute("name");
      String propertyValue = configTree.getAttribute("value");
      builder.property(propertyName, propertyValue);
    }
    return builder.build();
  }
View Full Code Here

TOP

Related Classes of org.jboss.soa.esb.services.security.SecurityConfig.Builder

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.