Package es.ipsa.atril.sec.user

Examples of es.ipsa.atril.sec.user.AuthorizationManager


    } catch (ElementNotFoundException enfe) {
      d = new Deposits(oSes);
      d.put("disabled", 0);
      d.save(oSes);
      oSes.commit();
      AuthorizationManager oAum = oSes.getAuthorizationManager();
        UsersGroup oUsrsGrp = new UsersGroup(oAum, Zesped.getUsersGroup(oAum));
      UsersGroup oOpersGrp = new UsersGroup(oAum, Zesped.getOperatorsGroup(oAum));
      oUsrsGrp.grantAll(d.getDocument());
      oOpersGrp.grantAll(d.getDocument());
    }
View Full Code Here


    }
    return true;
  }

  public boolean isOperator(AtrilSession oSes) {
    AuthorizationManager oAum = oSes.getAuthorizationManager();
    Group oGrp = Zesped.getOperatorsGroup(oAum);
    long lId = getAdministeredUser().getId();
    for (es.ipsa.atril.sec.user.User u : oGrp.getMembers())
      if (u.getId()==lId)
        return true;
View Full Code Here

   
    if (null==getPassword()) throw new NullPointerException("User.create() password cannot be null");
    if (null==getEmail()) throw new NullPointerException("User.create() email cannot be null");
    if (getEmail().length()==0) throw new NullPointerException("User.create() email cannot be empty");
   
    AuthorizationManager oAum = oSes.getAuthorizationManager();
    AuthorizationAdminManager oAam = oSes.getAuthorizationAdminManager();
    AdministeredGroup oGrp = oAam.getGroup("Zesped Users");
   
    if (null==sNickName) sNickName = Gadgets.generateUUID();

    Log.out.debug("AuthorizationAdminManager.createUser("+sNickName+","+getPassword()+","+getFirstName()+","+getLastName()+","+oGrp.getName()+")");
   
    setAdministeredUser(oAam.createUser(sNickName, getPassword(), getFirstName(), getLastName(), oGrp));

    String sUsrs = Users.top(oSes).getDocument().id();
   
    DocumentIndexer oIdx = oSes.getDocumentIndexer();
    SortableList<Document> oLst = (SortableList<Document>) oSes.getDms().query("User$email='"+getEmail()+"'");
    if (!oLst.isEmpty()) {
      Log.out.error("E-mail address "+getEmail()+" already belongs to another user");
      throw new IllegalArgumentException("E-mail address "+getEmail()+" already belongs to another user");
    }
   
    Dms oDms = oSes.getDms();
    Document oDoc = oDms.newDocument(oDms.getDocumentType("User"), oDms.getDocument(sUsrs));
    oDoc.save("");
    setDocument(oDoc);
   
    AttributeMultiValue oUid = oDoc.attribute("user_id");
    oUid.set(oDoc.id());
    AttributeMultiValue oUuid = oDoc.attribute("user_uuid");
    oUuid.set(sNickName);
    AttributeMultiValue oAttr = oDoc.attribute("email");
    oAttr.set(getEmail());
    AttributeMultiValue oActv = oDoc.attribute("active");
    oActv.set(getStringNull("active","1"));
    AttributeMultiValue oSrvs = oDoc.attribute("allowed_services");
    oSrvs.set(String.valueOf(CaptureService.INVOICES.toInt())+","+String.valueOf(CaptureService.BILLNOTES.toInt()));
    AttributeMultiValue oPassw = oDoc.attribute("password");
    oPassw.set(ACL.encript(getPassword(), ACL.PWD_DTIP_RC4_64));
    AttributeMultiValue oApr = oDoc.attribute("can_approve");
    oApr.set("1");
    AttributeMultiValue oStl = oDoc.attribute("can_settle");
    oStl.set("1");
    AttributeMultiValue oPre = oDoc.attribute("can_premium");
    oPre.set("1");
    oDoc.save("");
    oIdx.indexDocument(oDoc);

    put("user_id", oDoc.id());
    put("user_uuid", sNickName);
    put("can_approve", "1");
    put("can_settle", "1");
    put("can_premium", "1");
    put("active", getStringNull("active","1"));
    put("allowed_services", String.valueOf(CaptureService.INVOICES.toInt())+","+String.valueOf(CaptureService.BILLNOTES.toInt()));

    es.ipsa.atril.sec.user.User oUsr = oAum.getUser(getNickName());
   
    oAum.setDocumentRights(oUsr, oDoc, RightsFactory.getDocumentRightsAllGrant());

    try {
      oAum.setDocumentRights(oUsr, Deposits.top(oSes).getDocument(), RightsFactory.getDocumentRightsAllGrant());
    } catch (ElementNotFoundException ignore) { }
   
    DAO.log(oSes, oDoc, User.class, "CREATE USER", AtrilEvent.Level.INFO, String.valueOf(getAdministeredUser().getId())+";"+getEmail());

    Log.out.debug("End com.zesped.model.User.create() : "+oDoc.id());
View Full Code Here

      if (eRole.equals(Role.guest)) {
        oAcc.grantGuest(oSes, this);
        try { oAcc.denyAdmin(oSes, this); } catch (ElementNotFoundException ignore) { }
        try { oAcc.denyUser(oSes, this); } catch (ElementNotFoundException ignore) { }
      }
      AuthorizationManager oAum = oSes.getAuthorizationManager();
      UsersGroup oAdm = new UsersGroup(oAum, oAcc.getAdminsGroup(oAum));
      oAdm.grantAll(getDocument());     
    }
    Log.out.debug("End User.setRole()");
  }
View Full Code Here

TOP

Related Classes of es.ipsa.atril.sec.user.AuthorizationManager

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.