Package com.google.code.lightssh.project.security.entity

Examples of com.google.code.lightssh.project.security.entity.Role


      root = new LoginAccount( );
      root.setCreateDate( new Date() );
      root.setLoginName(ROOT_LOGIN_NAME);
      root.setStatus(AuditStatus.EFFECTIVE);
      root.setType(LoginAccountType.ADMIN);
      Role superRole = roleManager.initRole(true);
      root.addRole(superRole);
      root.setPassword(CryptographyUtil.hashMd5Hex(DEFAULT_PASSWORD ) );
      root.setDescription("系统初始化自动创建。");
     
      try{
View Full Code Here


    if( account.getRoles() != null ){
      Set<Role> dbRoles = new HashSet<Role>();
      for( Role role:account.getRoles() ){
        if( role == null )
          continue;
        Role dbRole = roleManager.get(role);
        if( dbRole == null )
          throw new ApplicationException( "所选角色["+role.getId()+"]已不存在!" );
        dbRoles.add(dbRole);
       
      }
View Full Code Here

   * 根据角色ID查询有效登录帐户
   * @param id 角色ID
   * @return 有效登录帐户
   */
  public List<LoginAccount> listByRole(String id ){
    Role role = new Role();
    role.setId(id);
   
    return getDao().listByRole( AuditStatus.EFFECTIVE,role );
  }
View Full Code Here

      Party party = partyMgr.get( val );
     
      return party==null?"":party.getName();
    }else if( ReceiveType.ROLE.equals(type) ){
      RoleManager roleMgr = (RoleManager)SpringContextHelper.getBean( "roleManager" );
      Role role = roleMgr.get( val );
     
      return role==null?"":role.getName();
    }else if( ReceiveType.USER.equals(type) ){
      /*
      LoginAccountManager mgr = (LoginAccountManager)SpringContextHelper.getBean( "loginAccountManager" );
      List<LoginAccount> users = mgr.listByIds( val.split(",") );
      if( users == null || users.isEmpty() )
View Full Code Here

public class RoleConverter extends StrutsTypeConverter{
 
  @SuppressWarnings("rawtypes")
  public Object convertFromString(Map context, String[] values, Class toClass){
    if( values != null ){
      Role role = new Role();
      role.setId(values[0]);
      return role;
    }
    return null;
  }
View Full Code Here

    /*Role exist = getRoleDao().get( role.getName() );
    if( exist != null && !exist.getIdentity().equals( role.getIdentity()))
      throw new SecurityException( "该角色名称'"+role.getName()+"'已经存在!" );
    */
    if( update ){
      Role db_role = get( role );
      if( db_role == null )
        throw new DaoException( "该角色已不存在,不能进行修改操作!" );
     
      db_role.setName( role.getName() );
      db_role.setDescription( role.getDescription() );
      //修改审核拒绝的角色进入待审核列表
      if(AuditStatus.AUDIT_REJECT.equals(db_role.getStatus()))
        db_role.setStatus(AuditStatus.NEW);
      dao.update( db_role );
    }else{
      role.setId( sequenceManager.nextSequenceNumber(role) );
      role.setStatus(AuditStatus.NEW);
      dao.create( role );
View Full Code Here

  @Override
  public void save(Role role,Collection<Navigation> colls,LoginAccount user) {
    if( role == null )
      throw new ApplicationException("参数为空!");
   
    Role db_role = get(role);
    Role originalRole = null,newRole = role;
    if( db_role == null ){
      db_role = role;
    }else{
      originalRole = db_role.clone();
      if( !db_role.isEffective() ){
View Full Code Here

    String bizName = "角色变更审核流程_"+db_role.getName()+"_"+user.getLoginName();
    workflowManager.start(WorkflowType.SEC_ROLE.getName(),rc.getId(),bizName,user.getLoginName(),null);
  }
 
  public void remove(Role role,LoginAccount operator,String remark) {
    Role dbRole = dao.read(role.getId());
    if( dbRole == null )
      throw new ApplicationException("角色不存在!");
   
    if( remark == null )
      remark = "删除角色";
    Role newRole = dbRole.clone();
    newRole.setStatus(AuditStatus.DELETE);
    roleChangeManager.save(operator
        ,EntityChange.Type.DELETE,dbRole, newRole,remark);
  }
View Full Code Here

  }

  @Override
  public Role initRole( boolean forceUpdatePermission ) {
    //super role init
    Role role = getRoleDao().read(SUPER_ROLE);
    boolean no_role = false;
    if( role == null ){
      no_role = true;
      role = new Role();
      role.setId(SUPER_ROLE);
      role.setDescription("系统初始化创建超级用户.");
      role.setName("超级管理角色");
      role.setReadonly( Boolean.TRUE );
      role.setStatus(AuditStatus.EFFECTIVE);
    }
    //是否更新角色权限
   
    //list all permission
    ListPage<Permission> page = new ListPage<Permission>(Integer.MAX_VALUE);
    page = permissionManager.list(page);
    if( (no_role || forceUpdatePermission) &&
        page.getList() != null && !page.getList().isEmpty() ){
      role.setPermissions( new HashSet<Permission>( page.getList() ) );
    }
   
    if( no_role )
      create(role);
    else
View Full Code Here

   
    RoleChange rc = this.roleChangeManager.get(roleChange);
    if( rc == null )
      throw new ApplicationException("角色变更信息["+roleChange.getId()+"]不存在!");
   
    Role db_role = roleManager.get(roleChange.getRole());
    Role newRole = null;
    byte[] newObject = rc.getNewObject();
    if( newObject != null )
      newRole = (Role)IoSerialUtil.deserialize(newObject);
    if( newObject == null || newRole == null )
      throw new ApplicationException("数据异常,变更角色信息为空!");
   
    boolean passed = AuditResult.LAST_AUDIT_PASSED.equals(ra.getResult());
    if( passed && EntityChange.Type.DELETE.equals(rc.getType()) ){//删除
      db_role.setStatus( AuditStatus.DELETE );
    }else if( passed && AuditStatus.EFFECTIVE.equals(newRole.getStatus())){
      db_role.setName( newRole.getName() );
      db_role.setDescription( newRole.getDescription() );
      db_role.setPermissions( newRole.getPermissions() );
    }else if( passed ){
      db_role.setStatus( AuditStatus.EFFECTIVE );
    }else if( !passed && AuditStatus.NEW.equals( newRole.getStatus() )){
      db_role.setStatus( AuditStatus.AUDIT_REJECT );
    }
   
    roleManager.update(db_role);
    //dao.create(ra); TODO
View Full Code Here

TOP

Related Classes of com.google.code.lightssh.project.security.entity.Role

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.