Package org.pentaho.platform.plugin.services.security.userrole.ldap

Examples of org.pentaho.platform.plugin.services.security.userrole.ldap.RolePreprocessingMapper


  public void testGetAuthoritiesForUser1() throws Exception {
    LdapUserSearch userSearch = getUserSearch( "ou=users", "(uid={0})" ); //$NON-NLS-1$//$NON-NLS-2$

    LdapUserDetailsService service = new LdapUserDetailsService( userSearch, new NoOpLdapAuthoritiesPopulator() );

    RolePreprocessingMapper mapper = new RolePreprocessingMapper();
    mapper.setRoleAttributes( new String[] { "uniqueMember" } ); //$NON-NLS-1$
    mapper.setTokenName( "cn" ); //$NON-NLS-1$
    service.setUserDetailsMapper( mapper );

    DefaultLdapUserRoleListService userRoleListService = new DefaultLdapUserRoleListService();

    userRoleListService.setUserDetailsService( service );
View Full Code Here


    LdapUserSearch userSearch = getUserSearch( "ou=users", "(uid={0})" ); //$NON-NLS-1$//$NON-NLS-2$

    LdapUserDetailsService service = new LdapUserDetailsService( userSearch, new NoOpLdapAuthoritiesPopulator() );

    RolePreprocessingMapper mapper = new RolePreprocessingMapper();
    mapper.setRoleAttributes( new String[] { "uniqueMember" } ); //$NON-NLS-1$
    mapper.setTokenName( "cn" ); //$NON-NLS-1$
    service.setUserDetailsMapper( mapper );

    DefaultLdapUserRoleListService userRoleListService = new DefaultLdapUserRoleListService();

    userRoleListService.setUserDetailsService( service );
View Full Code Here

public class RolePreprocessingMapperTests extends AbstractPentahoLdapIntegrationTests {

  @SuppressWarnings( "unchecked" )
  @Test
  public void testMapUserFromContext() throws Exception {
    RolePreprocessingMapper mapper = new RolePreprocessingMapper();
    mapper.setTokenName( "cn" ); //$NON-NLS-1$
    mapper.setRolePrefix( "" ); //$NON-NLS-1$
    mapper.setRoleAttributes( new String[] { "uniqueMember" } ); //$NON-NLS-1$

    // get the user record
    DirContextOperations ctx = new SpringSecurityLdapTemplate( getContextSource() ).retrieveEntry( "uid=suzy,ou=users", //$NON-NLS-1$
        null );

    // get any roles that aren't in the user record
    Set<String> extraRoles =
        new SpringSecurityLdapTemplate( getContextSource() ).searchForSingleAttributeValues(
            "ou=roles", "roleoccupant={0}", new String[] { "uid=suzy,ou=users,dc=pentaho,dc=org", "suzy" }, "cn" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$

    GrantedAuthority[] authorities = new GrantedAuthority[extraRoles.size()];
    int i = 0;
    for ( String extraRole : extraRoles ) {
      authorities[i++] = new GrantedAuthorityImpl( extraRole );
    }

    // use the mapper to create a UserDetails instance
    UserDetails userDetails = mapper.mapUserFromContext( ctx, "suzy", authorities ); //$NON-NLS-1$
    System.out.println( userDetails );

    // this asserts the ordering too; not strictly necessary
    GrantedAuthority[] expected =
        new GrantedAuthority[] { new GrantedAuthorityImpl( "A" ), new GrantedAuthorityImpl( "cto" ), //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

TOP

Related Classes of org.pentaho.platform.plugin.services.security.userrole.ldap.RolePreprocessingMapper

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.