Package com.orientechnologies.orient.core.metadata.security

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


 
 
  public static void moveUsersToRole(String from, String to) {
    String sqlAdd="update ouser add roles = {TO_ROLE} where roles contains {FROM_ROLE}";
    String sqlRemove="update ouser remove roles = {FROM_ROLE} where roles contains {FROM_ROLE}";
    ORole fromRole=RoleDao.getRole(from);
    ORole toRole=RoleDao.getRole(to);
   
    ORID fromRID=fromRole.getDocument().getRecord().getIdentity();
    ORID toRID=toRole.getDocument().getRecord().getIdentity();
   
    sqlAdd=sqlAdd.replace("{TO_ROLE}", toRID.toString()).replace("{FROM_ROLE}", fromRID.toString());
    sqlRemove=sqlRemove.replace("{TO_ROLE}", toRID.toString()).replace("{FROM_ROLE}", fromRID.toString());
   
    GenericDao.getInstance().executeCommand(sqlAdd, new String[] {});
View Full Code Here


    if(!DbHelper.currentUsername().equals(BBConfiguration.getBaasBoxAdminUsername())){
      DbHelper.reconnectAsAdmin();
      admin = false;
    }
    String sqlAdd="update ouser add roles = {TO_ROLE} where name = ?";
    ORole toRole=RoleDao.getRole(role);
    ORID toRID=toRole.getDocument().getRecord().getIdentity();
    sqlAdd=sqlAdd.replace("{TO_ROLE}", toRID.toString());
    GenericDao.getInstance().executeCommand(sqlAdd, new String[] {username});
    if(!admin){
      DbHelper.reconnectAsAuthenticatedUser();
    }
View Full Code Here

    if(!DbHelper.currentUsername().equals(BBConfiguration.getBaasBoxAdminUsername())){
      DbHelper.reconnectAsAdmin();
      admin = true;
    }
    String sqlRemove="update ouser remove roles = {FROM_ROLE} where roles contains {FROM_ROLE} and name = ?";
    ORole fromRole=RoleDao.getRole(role);
    ORID fromRID=fromRole.getDocument().getRecord().getIdentity();
    sqlRemove=sqlRemove.replace("{FROM_ROLE}", fromRID.toString());
    GenericDao.getInstance().executeCommand(sqlRemove, new String[] {username});
    if(admin){
      DbHelper.reconnectAsAuthenticatedUser();
    }
View Full Code Here

 
  public static void moveUserToRole(String username,String from, String to) {
    String sqlAdd="update ouser add roles = {TO_ROLE} where roles contains {FROM_ROLE} and name = ?";
    String sqlRemove="update ouser remove roles = {FROM_ROLE} where roles contains {FROM_ROLE} and name = ?";
   
    ORole fromRole=RoleDao.getRole(from);
    ORole toRole=RoleDao.getRole(to);
   
    ORID fromRID=fromRole.getDocument().getRecord().getIdentity();
    ORID toRID=toRole.getDocument().getRecord().getIdentity();
   
    sqlAdd=sqlAdd.replace("{TO_ROLE}", toRID.toString()).replace("{FROM_ROLE}", fromRID.toString());
    sqlRemove=sqlRemove.replace("{TO_ROLE}", toRID.toString()).replace("{FROM_ROLE}", fromRID.toString());

    GenericDao.getInstance().executeCommand(sqlAdd, new String[] {username});
View Full Code Here

    return UserDao.getInstance().getByUsernames(usernames);
   
  }
 
  public static boolean userCanByPassRestrictedAccess(String userName){
    ORole role = getUserRole(userName);
    return RoleService.roleCanByPassRestrictedAccess(role.getName());
  }
View Full Code Here

    }


    public static ODocument grantPermissionToRole(String id,Permissions permission, String rolename)
        throws RoleNotFoundException, FileNotFoundException, SqlInjectionException, InvalidModelException {
      ORole role=RoleDao.getRole(rolename);
      if (role==null) throw new RoleNotFoundException(rolename);
      ODocument doc = getById(id);
      if (doc==null) throw new FileNotFoundException(id);
      return PermissionsHelper.grant(doc, permission, role);
    }
View Full Code Here

    }


    public static ODocument revokePermissionToRole(String id,
        Permissions permission, String rolename) throws RoleNotFoundException, FileNotFoundException, SqlInjectionException, InvalidModelException  {
      ORole role=RoleDao.getRole(rolename);
      if (role==null) throw new RoleNotFoundException(rolename);
      ODocument doc = getById(id);
      if (doc==null) throw new FileNotFoundException(id);
      return PermissionsHelper.revoke(doc, permission, role);
   
View Full Code Here

    //create new class
    OClass documentClass = db.getMetadata().getSchema().getClass(CLASS_NODE_NAME);
    db.getMetadata().getSchema().createClass(collectionName, documentClass);
   
    //grants to the new class
    ORole registeredRole = RoleDao.getRole(DefaultRoles.REGISTERED_USER.toString());
    ORole anonymousRole = RoleDao.getRole(DefaultRoles.ANONYMOUS_USER.toString());
    registeredRole.addRule(ODatabaseSecurityResources.CLASS + "." + collectionName, ORole.PERMISSION_ALL);
    registeredRole.addRule(ODatabaseSecurityResources.CLUSTER + "." + collectionName, ORole.PERMISSION_ALL);
    anonymousRole.addRule(ODatabaseSecurityResources.CLASS + "." + collectionName, ORole.PERMISSION_READ);
    anonymousRole.addRule(ODatabaseSecurityResources.CLUSTER + "." + collectionName, ORole.PERMISSION_READ);
    PermissionsHelper.grantRead(doc, registeredRole);
    PermissionsHelper.grantRead(doc, anonymousRole);
    if (Logger.isTraceEnabled()) Logger.trace("Method End");
    return doc;
  }//getNewModelInstance(String collectionName)
View Full Code Here

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

  public static ODocument grantPermissionToRole(String collectionName, String rid, Permissions permission, String rolename) throws RoleNotFoundException, IllegalArgumentException, InvalidCollectionException, InvalidModelException, DocumentNotFoundException {
    ORole role=RoleDao.getRole(rolename);
    if (role==null) throw new RoleNotFoundException(rolename);
    ODocument doc = get(collectionName, rid);
    if (doc==null) throw new DocumentNotFoundException(rid);
        return PermissionsHelper.grant(doc, permission, role);
  }
View Full Code Here

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

  public static ODocument revokePermissionToRole(String collectionName, String rid, Permissions permission, String rolename) throws  IllegalArgumentException, InvalidCollectionException, InvalidModelException, DocumentNotFoundException, RoleNotFoundException {
    ORole role=RoleDao.getRole(rolename);
    if (role==null) throw new RoleNotFoundException(rolename);
    ODocument doc = get(collectionName, rid);
    if (doc==null) throw new DocumentNotFoundException(rid);
    return PermissionsHelper.revoke(doc, permission, role);
  }
View Full Code Here

TOP

Related Classes of com.orientechnologies.orient.core.metadata.security.ORole

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.