Package org.pentaho.platform.api.engine.security.userroledao

Examples of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao


  @Produces ( { APPLICATION_XML, APPLICATION_JSON } )
  @Facet( name = "Unsupported" )
  public UserListWrapper getUsers() throws Exception {
    if ( canAdminister() ) {
      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        return new UserListWrapper( roleDao.getUsers() );
      } catch ( Throwable t ) {
        throw new WebApplicationException( t );
      }
    } else {
      throw new WebApplicationException( new Throwable() );
View Full Code Here


  @Produces ( { APPLICATION_XML, APPLICATION_JSON } )
  @Facet ( name = "Unsupported" )
  public RoleListWrapper getRoles() throws Exception {
    if ( canAdminister() ) {
      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        return new RoleListWrapper( roleDao.getRoles() );
      } catch ( Throwable t ) {
        throw new WebApplicationException( t );
      }
    } else {
      throw new WebApplicationException( new Throwable() );
View Full Code Here

  @Facet ( name = "Unsupported" )
  public RoleListWrapper getUserRoles( @QueryParam ( "tenant" ) String tenantPath,
                                       @QueryParam ( "userName" ) String userName ) throws Exception {
    if ( canAdminister() ) {
      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        return new RoleListWrapper( roleDao.getUserRoles( getTenant( tenantPath ), userName ) );
      } catch ( Throwable t ) {
        throw new WebApplicationException( t );
      }
    } else {
      throw new WebApplicationException( new Throwable() );
View Full Code Here

  @Path ( "/roleMembers" )
  @Produces ( { APPLICATION_XML, APPLICATION_JSON } )
  @Facet ( name = "Unsupported" )
  public UserListWrapper getRoleMembers( @QueryParam ( "tenant" ) String tenantPath,
                                         @QueryParam ( "roleName" ) String roleName ) throws Exception {
    IUserRoleDao roleDao =
        PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
    return new UserListWrapper( roleDao.getRoleMembers( getTenant( tenantPath ), roleName ) );
  }
View Full Code Here

  @Consumes ( { WILDCARD } )
  @Facet ( name = "Unsupported" )
  public Response assignRoleToUser( @QueryParam ( "tenant" ) String tenantPath,
                                    @QueryParam ( "userName" ) String userName, @QueryParam ( "roleNames" ) String roleNames ) {
    if ( canAdminister() ) {
      IUserRoleDao roleDao =
          PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
      StringTokenizer tokenizer = new StringTokenizer( roleNames, "\t" );
      Set<String> assignedRoles = new HashSet<String>();
      for ( IPentahoRole pentahoRole : roleDao.getUserRoles( getTenant( tenantPath ), userName ) ) {
        assignedRoles.add( pentahoRole.getName() );
      }
      while ( tokenizer.hasMoreTokens() ) {
        assignedRoles.add( tokenizer.nextToken() );
      }
      try {
        roleDao.setUserRoles( getTenant( tenantPath ), userName, assignedRoles.toArray( new String[0] ) );
      } catch ( Throwable th ) {
        return processErrorResponse( th.getLocalizedMessage() );
      }
      return Response.ok().build();
    } else {
View Full Code Here

  @Facet ( name = "Unsupported" )
  public Response removeRoleFromUser( @QueryParam ( "tenant" ) String tenantPath,
                                      @QueryParam ( "userName" ) String userName, @QueryParam ( "roleNames" ) String roleNames ) {
    if ( canAdminister() ) {
      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        StringTokenizer tokenizer = new StringTokenizer( roleNames, "\t" );
        Set<String> assignedRoles = new HashSet<String>();
        for ( IPentahoRole pentahoRole : roleDao.getUserRoles( getTenant( tenantPath ), userName ) ) {
          assignedRoles.add( pentahoRole.getName() );
        }
        while ( tokenizer.hasMoreTokens() ) {
          assignedRoles.remove( tokenizer.nextToken() );
        }
        roleDao.setUserRoles( getTenant( tenantPath ), userName, assignedRoles.toArray( new String[0] ) );
        return Response.ok().build();
      } catch ( Throwable th ) {
        return processErrorResponse( th.getLocalizedMessage() );
      }
    } else {
View Full Code Here

  @Path ( "/assignAllRolesToUser" )
  @Consumes ( { WILDCARD } )
  @Facet ( name = "Unsupported" )
  public Response assignAllRolesToUser( @QueryParam ( "tenant" ) String tenantPath,
                                        @QueryParam ( "userName" ) String userName ) {
    IUserRoleDao roleDao =
        PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
    Set<String> assignedRoles = new HashSet<String>();
    for ( IPentahoRole pentahoRole : roleDao.getRoles( getTenant( tenantPath ) ) ) {
      assignedRoles.add( pentahoRole.getName() );
    }
    roleDao.setUserRoles( getTenant( tenantPath ), userName, assignedRoles.toArray( new String[0] ) );
    return Response.ok().build();
  }
View Full Code Here

  @Facet ( name = "Unsupported" )
  public Response removeAllRolesFromUser( @QueryParam ( "tenant" ) String tenantPath,
                                          @QueryParam ( "userName" ) String userName ) {
    if ( canAdminister() ) {
      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        roleDao.setUserRoles( getTenant( tenantPath ), userName, new String[0] );
        return Response.ok().build();
      } catch ( Throwable th ) {
        return processErrorResponse( th.getLocalizedMessage() );
      }
    } else {
View Full Code Here

  @Consumes ( { WILDCARD } )
  @Facet ( name = "Unsupported" )
  public Response assignUserToRole( @QueryParam ( "tenant" ) String tenantPath,
                                    @QueryParam ( "userNames" ) String userNames, @QueryParam ( "roleName" ) String roleName ) {
    if ( canAdminister() ) {
      IUserRoleDao roleDao =
          PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
      StringTokenizer tokenizer = new StringTokenizer( userNames, "\t" );
      Set<String> assignedUserNames = new HashSet<String>();
      for ( IPentahoUser pentahoUser : roleDao.getRoleMembers( getTenant( tenantPath ), roleName ) ) {
        assignedUserNames.add( pentahoUser.getUsername() );
      }
      while ( tokenizer.hasMoreTokens() ) {
        assignedUserNames.add( tokenizer.nextToken() );
      }
      try {
        roleDao.setRoleMembers( getTenant( tenantPath ), roleName, assignedUserNames.toArray( new String[0] ) );
        return Response.ok().build();
      } catch ( Throwable th ) {
        return processErrorResponse( th.getLocalizedMessage() );
      }
    } else {
View Full Code Here

  @Facet ( name = "Unsupported" )
  public Response removeUserFromRole( @QueryParam ( "tenant" ) String tenantPath,
                                      @QueryParam ( "userNames" ) String userNames, @QueryParam ( "roleName" ) String roleName ) {
    if ( canAdminister() ) {
      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        StringTokenizer tokenizer = new StringTokenizer( userNames, "\t" );
        Set<String> assignedUserNames = new HashSet<String>();
        for ( IPentahoUser pentahoUser : roleDao.getRoleMembers( getTenant( tenantPath ), roleName ) ) {
          assignedUserNames.add( pentahoUser.getUsername() );
        }
        while ( tokenizer.hasMoreTokens() ) {
          assignedUserNames.remove( tokenizer.nextToken() );
        }
        roleDao.setRoleMembers( getTenant( tenantPath ), roleName, assignedUserNames.toArray( new String[0] ) );
        return Response.ok().build();
      } catch ( Throwable th ) {
        return processErrorResponse( th.getLocalizedMessage() );
      }
    } else {
View Full Code Here

TOP

Related Classes of org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao

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.