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

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


  @Path ( "/assignAllUsersToRole" )
  @Consumes ( { WILDCARD } )
  @Facet ( name = "Unsupported" )
  public Response assignAllUsersToRole( @QueryParam ( "tenant" ) String tenantPath,
                                        @QueryParam ( "roleName" ) String roleName ) {
    IUserRoleDao roleDao =
        PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
    Set<String> assignedUserNames = new HashSet<String>();
    for ( IPentahoUser pentahoUser : roleDao.getUsers( getTenant( tenantPath ) ) ) {
      assignedUserNames.add( pentahoUser.getUsername() );
    }
    roleDao.setRoleMembers( getTenant( tenantPath ), roleName, assignedUserNames.toArray( new String[0] ) );
    return Response.ok().build();
  }
View Full Code Here


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

  @PUT
  @Path ( "/createUser" )
  @Consumes ( { WILDCARD } )
  @Facet ( name = "Unsupported" )
  public Response createUser( @QueryParam ( "tenant" ) String tenantPath, User user ) {
    IUserRoleDao roleDao =
        PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
    String userName = user.getUserName();
    String password = user.getPassword();
    try {
      userName = URLDecoder.decode( userName.replace( "+", "%2B" ), "UTF-8" );
    } catch ( UnsupportedEncodingException e ) {
      userName = user.getUserName();
      logger.warn( e.getMessage(), e );
    }
    try {
      password = URLDecoder.decode( password.replace( "+", "%2B" ), "UTF-8" );
    } catch ( UnsupportedEncodingException e ) {
      password = user.getPassword();
      logger.warn( e.getMessage(), e );
    }
    roleDao.createUser( getTenant( tenantPath ), userName, password, "", new String[0] );
    return Response.ok().build();
  }
View Full Code Here

  @PUT
  @Path ( "/createRole" )
  @Consumes ( { WILDCARD } )
  @Facet ( name = "Unsupported" )
  public Response createRole( @QueryParam ( "tenant" ) String tenantPath, @QueryParam ( "roleName" ) String roleName ) {
    IUserRoleDao roleDao =
        PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
    roleDao.createRole( getTenant( tenantPath ), roleName, "", new String[0] );
    return Response.ok().build();
  }
View Full Code Here

  @Consumes ( { WILDCARD } )
  @Facet ( name = "Unsupported" )
  public Response deleteRole( @QueryParam ( "roleNames" ) String roleNames ) {
    if ( canAdminister() ) {
      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        StringTokenizer tokenizer = new StringTokenizer( roleNames, "\t" );
        while ( tokenizer.hasMoreTokens() ) {
          IPentahoRole role = roleDao.getRole( null, tokenizer.nextToken() );
          if ( role != null ) {
            roleDao.deleteRole( role );
          }
        }
      } catch ( Throwable th ) {
        return processErrorResponse( th.getLocalizedMessage() );
      }
View Full Code Here

  @Consumes ( { WILDCARD } )
  @Facet ( name = "Unsupported" )
  public Response deleteUser( @QueryParam ( "userNames" ) String userNames ) {
    if ( canAdminister() ) {
      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        StringTokenizer tokenizer = new StringTokenizer( userNames, "\t" );
        while ( tokenizer.hasMoreTokens() ) {
          IPentahoUser user = roleDao.getUser( null, tokenizer.nextToken() );
          if ( user != null ) {
            roleDao.deleteUser( user );
          }
        }
      } catch ( Throwable th ) {
        return processErrorResponse( th.getLocalizedMessage() );
      }
View Full Code Here

  @Consumes ( { WILDCARD } )
  @Facet ( name = "Unsupported" )
  public Response updatePassword( User user ) {
    if ( canAdminister() ) {
      try {
        IUserRoleDao roleDao =
            PentahoSystem.get( IUserRoleDao.class, "userRoleDaoProxy", PentahoSessionHolder.getSession() );
        String userName = user.getUserName();
        String password = user.getPassword();
        try {
          userName = URLDecoder.decode( userName.replace( "+", "%2B" ), "UTF-8" );
        } catch ( UnsupportedEncodingException e ) {
          userName = user.getUserName();
          logger.warn( e.getMessage(), e );
        }
        try {
          password = URLDecoder.decode( password.replace( "+", "%2B" ), "UTF-8" );
        } catch ( UnsupportedEncodingException e ) {
          password = user.getPassword();
          logger.warn( e.getMessage(), e );
        }
        IPentahoUser puser = roleDao.getUser( null, userName );
        if ( puser != null ) {
          roleDao.setPassword( null, userName, password );
        }
        return Response.ok().build();
      } catch ( Throwable t ) {
        throw new WebApplicationException( t );
      }
View Full Code Here

  protected IUserRoleDao getDao() throws UserRoleException {
    if ( !isAdmin() ) {
      throw new UserRoleException( Messages.getInstance().getErrorString( "UserRoleWebService.ERROR_0001_NOT_ADMIN" ) ); //$NON-NLS-1$
    }
    IUserRoleDao dao = PentahoSystem.get( IUserRoleDao.class, "userRoleDaoTxn", PentahoSessionHolder.getSession() ); //$NON-NLS-1$
    if ( dao == null ) {
      throw new UserRoleException( Messages.getInstance().getErrorString(
          "UserRoleWebService.ERROR_0002_IUSERROLEDAO_NOT_AVAILABLE" ) ); //$NON-NLS-1$
    }
    return dao;
View Full Code Here

  }

  @Override
  public UserRoleSecurityInfo getUserRoleSecurityInfo() throws UserRoleException {
    UserRoleSecurityInfo userRoleSecurityInfo = new UserRoleSecurityInfo();
    IUserRoleDao dao = getDao();
    List<IPentahoUser> users = dao.getUsers();
    if ( users != null ) {
      for ( IPentahoUser user : users ) {
        userRoleSecurityInfo.getUsers().add( ProxyPentahoUserRoleHelper.toProxyUser( user ) );
        List<IPentahoRole> roles = dao.getUserRoles( user.getTenant(), user.getUsername() );
        if ( roles != null ) {
          for ( IPentahoRole role : roles ) {
            userRoleSecurityInfo.getAssignments().add( new UserToRoleAssignment( user.getUsername(), role.getName() ) );
          }
        }
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.