Examples of OUser


Examples of com.orientechnologies.orient.core.metadata.security.OUser

      if (doc==null) throw new FileNotFoundException(id);
      return PermissionsHelper.grant(doc, permission, user);
    }

    public static ODocument revokePermissionToUser(String id, Permissions permission, String username) throws UserNotFoundException, RoleNotFoundException, FileNotFoundException, SqlInjectionException, IllegalArgumentException, InvalidModelException {
      OUser user=UserService.getOUserByUsername(username);
      if (user==null) throw new UserNotFoundException(username);
      ODocument doc = getById(id);
      if (doc==null) throw new FileNotFoundException(id);
      return PermissionsHelper.revoke(doc, permission, user);
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.security.OUser

 
  public static Result following(String username){
    if(!UserService.exists(username)){
      return notFound("User "+username+" does not exists");
    }
     OUser user = UserService.getOUserByUsername(username);
     Set<ORole> roles = user.getRoles();
     List<String> usernames = new ArrayList<String>();
     for (ORole oRole : roles) {
       
      if(oRole.getName().startsWith(RoleDao.FRIENDS_OF_ROLE)){
        usernames.add(StringUtils.difference(RoleDao.FRIENDS_OF_ROLE,oRole.getName()));
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.security.OUser

   
    return getConnection();
  }

    public static boolean isConnectedAsAdmin(boolean excludeInternal){
        OUser user = getConnection().getUser();
        Set<ORole> roles = user.getRoles();
        boolean isAdminRole = roles.contains(RoleDao.getRole(DefaultRoles.ADMIN.toString()));
        return excludeInternal ? isAdminRole && !BBConfiguration.getBaasBoxAdminUsername().equals(user.getName()) : isAdminRole;
    }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.security.OUser

 
  public static void updateDefaultUsers() throws Exception{
    if (Logger.isTraceEnabled()) Logger.trace("Method Start");
    ODatabaseRecordTx db = DbHelper.getConnection();
    OUser user=db.getMetadata().getSecurity().getUser(BBConfiguration.getBaasBoxUsername());
    user.setPassword(BBConfiguration.getBaasBoxPassword());
    user.save();

    user=db.getMetadata().getSecurity().getUser(BBConfiguration.getBaasBoxAdminUsername());
    user.setPassword(BBConfiguration.getBaasBoxAdminPassword());
    user.save();

    if (Logger.isTraceEnabled()) Logger.trace("Method End");
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.security.OUser

      throw new InvalidCollectionException("The document " + rid + " does no belong to the collection " + collectionName);
    }
  }

  public static ODocument grantPermissionToUser(String collectionName, String rid, Permissions permission, String username) throws UserNotFoundException, IllegalArgumentException, InvalidCollectionException, InvalidModelException, DocumentNotFoundException {
    OUser user=UserService.getOUserByUsername(username);
    if (user==null) throw new UserNotFoundException(username);
    ODocument doc = get(collectionName, rid);
    if (doc==null) throw new DocumentNotFoundException(rid);
    return PermissionsHelper.grant(doc, permission, user);
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.security.OUser

    if (doc==null) throw new DocumentNotFoundException(rid);
    return PermissionsHelper.grant(doc, permission, user);
  }

  public static ODocument revokePermissionToUser(String collectionName, String rid, Permissions permission, String username) throws UserNotFoundException, IllegalArgumentException, InvalidCollectionException, InvalidModelException, DocumentNotFoundException {
    OUser user=UserService.getOUserByUsername(username);
    if (user==null) throw new UserNotFoundException(username);
    ODocument doc = get(collectionName, rid);
    if (doc==null) throw new DocumentNotFoundException(rid);
    return PermissionsHelper.revoke(doc, permission, user);
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.security.OUser


  public ODocument create(String username, String password, String role) throws UserAlreadyExistsException {
    OrientGraph db = DbHelper.getOrientGraphConnection();
    if (existsUserName(username)) throw new UserAlreadyExistsException("User " + username + " already exists");
    OUser user=null;
    if (role==null) user=db.getRawGraph().getMetadata().getSecurity().createUser(username,password,new String[]{DefaultRoles.REGISTERED_USER.toString()});
    else {
      ORole orole = RoleDao.getRole(role);
      if (orole==null) throw new InvalidParameterException("Role " + role + " does not exists");
      user=db.getRawGraph().getMetadata().getSecurity().createUser(username,password,new String[]{role});
    }
   
    ODocument doc = new ODocument(this.MODEL_NAME);
    ODocument vertex = db.addVertex("class:"+CLASS_VERTEX_NAME,FIELD_TO_DOCUMENT_FIELD,doc).getRecord();
    doc.field(FIELD_LINK_TO_VERTEX,vertex);
    doc.field(FIELD_CREATION_DATE,new Date());

    doc.field(USER_LINK,user.getDocument().getIdentity());
    doc.save();
    return doc;
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.security.OUser

    return result;
  }

  public void disableUser(String username) throws UserNotFoundException, OpenTransactionException{
    db = DbHelper.reconnectAsAdmin();
    OUser user = db.getMetadata().getSecurity().getUser(username);
    if (user==null) throw new UserNotFoundException("The user " + username + " does not exist.");
    user.setAccountStatus(STATUSES.SUSPENDED);
    user.save();
    //cannot resume the old connection because now the user is disabled
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.security.OUser

    //cannot resume the old connection because now the user is disabled
  }
 
  public void enableUser(String username) throws UserNotFoundException, OpenTransactionException{
    db = DbHelper.reconnectAsAdmin();
    OUser user = db.getMetadata().getSecurity().getUser(username);
    if (user==null) throw new UserNotFoundException("The user " + username + " does not exist.");
    user.setAccountStatus(STATUSES.ACTIVE);
    user.save();
  }
View Full Code Here

Examples of com.orientechnologies.orient.core.metadata.security.OUser

  }
 
  public static boolean hasRole(String username,String roleName){
    boolean result = false;
    if(UserDao.getInstance().existsUserName(username)){
      OUser user = UserService.getOUserByUsername(username);
      Set<ORole> roles = user.getRoles();
      if(roles!=null){
        for (ORole oRole : roles) {
          if(oRole.getName().equals(roleName)){
            result = true;
            break;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.