Package org.ejbca.core.model.ra

Examples of org.ejbca.core.model.ra.RAAuthorization


    query.add(ApprovalMatch.MATCH_WITH_STATUS, BasicMatch.MATCH_TYPE_EQUALS, "" + ApprovalDataVO.STATUS_WAITINGFORAPPROVAL, Query.CONNECTOR_AND);
    Date now = new Date();
    Calendar cal = Calendar.getInstance();
    cal.add(Calendar.HOUR_OF_DAY, -1);
    query.add(cal.getTime(), now);
        RAAuthorization raAuthorization = new RAAuthorization(admin, globalConfigurationSession, authorizationSession, caSession, endEntityProfileSession);
    List<ApprovalDataVO> approvals = approvalSession.query(admin, query, 0, 25, raAuthorization.getCAAuthorizationString(), raAuthorization.getEndEntityProfileAuthorizationString());
    // If there is an request waiting for approval we don't have to go on and try to add the user
        if (approvals.size() > 0) {
          log.debug("Found at least one waiting approval request for approvalid: "+approvalid);
          throw new ApprovalException("There is already an existing approval request pending for approvalid: "+approvalid);
        }
       
    // If there is no waiting request which should be the most common, we check If there is an existing reject withing the last 30 minutes
        // If there is a reject, we will cancel this request. A new request will then probably not be possible to create until 30 minutes have passed
    query = new Query(Query.TYPE_APPROVALQUERY);   
    query.add(ApprovalMatch.MATCH_WITH_APPROVALID, BasicMatch.MATCH_TYPE_EQUALS, Integer.toString(approvalid), Query.CONNECTOR_AND);
    query.add(ApprovalMatch.MATCH_WITH_STATUS, BasicMatch.MATCH_TYPE_EQUALS, "" + ApprovalDataVO.STATUS_EXECUTIONDENIED, Query.CONNECTOR_AND);
    cal = Calendar.getInstance();
    cal.add(Calendar.MINUTE, APPROVAL_REJECT_TIMEOUT);
    query.add(cal.getTime(), now);
    approvals = approvalSession.query(admin, query, 0, 25, raAuthorization.getCAAuthorizationString(), raAuthorization.getEndEntityProfileAuthorizationString());
    // If there is an request waiting for approval we don't have to go on and try to add the user
        if (approvals.size() > 0) {
          log.debug("Found at least one rejected approval request for approvalid: "+approvalid);
          throw new Exception("Approval request was rejected for approvalid: "+approvalid);
        }

    // Check if it failed as well...
    query = new Query(Query.TYPE_APPROVALQUERY);   
    query.add(ApprovalMatch.MATCH_WITH_APPROVALID, BasicMatch.MATCH_TYPE_EQUALS, Integer.toString(approvalid), Query.CONNECTOR_AND);
    query.add(ApprovalMatch.MATCH_WITH_STATUS, BasicMatch.MATCH_TYPE_EQUALS, "" + ApprovalDataVO.STATUS_EXECUTIONFAILED, Query.CONNECTOR_AND);
    cal = Calendar.getInstance();
    cal.add(Calendar.MINUTE, -30);
    query.add(cal.getTime(), now);
    approvals = approvalSession.query(admin, query, 0, 25, raAuthorization.getCAAuthorizationString(), raAuthorization.getEndEntityProfileAuthorizationString());
    // If there is an request waiting for approval we don't have to go on and try to add the user
        if (approvals.size() > 0) {
          log.debug("Found at least one failed approval request for approvalid: "+approvalid);
          throw new Exception("Approval request execution failed for approvalid: "+approvalid);
        }
View Full Code Here


    public void updateApprovalRequestData(int id){
      Query query = new Query(Query.TYPE_APPROVALQUERY);
      query.add(ApprovalMatch.MATCH_WITH_UNIQUEID, BasicMatch.MATCH_TYPE_EQUALS, Integer.toString(id));
      List<ApprovalDataVO> result;
      try {
        RAAuthorization raAuthorization = new RAAuthorization(EjbcaJSFHelper.getBean().getAdmin(), ejb.getGlobalConfigurationSession(),
            ejb.getAuthorizationSession(), ejb.getCaSession(), ejb.getEndEntityProfileSession());
        result = ejb.getApprovalSession().query( EjbcaJSFHelper.getBean().getAdmin(), query, 0, 1, raAuthorization.getCAAuthorizationString(), raAuthorization.getEndEntityProfileAuthorizationString());
        if (result.size() > 0) {
          this.approveRequestData = new ApprovalDataVOView(result.get(0));
        }
      } catch (IllegalQueryException e) {
        addErrorMessage("INVALIDQUERY");
View Full Code Here

      query.add(ApprovalMatch.MATCH_WITH_STATUS, BasicMatch.MATCH_TYPE_EQUALS, selectedStatus, Query.CONNECTOR_AND);
      query.add(getStartDate(), new Date());
    }
        List<ApprovalDataVO> result = new ArrayList<ApprovalDataVO>();
    try {
            RAAuthorization raAuthorization = new RAAuthorization(EjbcaJSFHelper.getBean().getAdmin(), ejb.getGlobalConfigurationSession(),
                ejb.getAuthorizationSession(), ejb.getCaSession(), ejb.getEndEntityProfileSession());
      result = ejb.getApprovalSession().query(EjbcaJSFHelper.getBean().getAdmin(), query, 0, QUERY_MAX_NUM_ROWS, raAuthorization.getCAAuthorizationString(), raAuthorization.getEndEntityProfileAuthorizationString());
      if(result.size() == QUERY_MAX_NUM_ROWS){
        String messagestring = getEjbcaWebBean().getText("MAXAPPROVALQUERYROWS1", true) + " " + QUERY_MAX_NUM_ROWS + " " + getEjbcaWebBean().getText("MAXAPPROVALQUERYROWS2", true);
        FacesContext ctx = FacesContext.getCurrentInstance();
        ctx.addMessage("error", new FacesMessage(FacesMessage.SEVERITY_ERROR,messagestring,messagestring));
      }
View Full Code Here

      this.publishersession = publishersession;
      this.userdatasourcesession = userdatasourcesession;
      this.globalconfiguration = globalconfiguration;
      this.certificateProfileSession = certificateProfileSession;
      this.caSession = caSession;
      this.raauthorization = new RAAuthorization(administrator, globalConfigurationSession, authorizationsession, caSession, endEntityProfileSession);
      this.caauthorization = new CAAuthorization(administrator, caadminsession, caSession, authorizationsession, certificateProfileSession);
      this.logauthorization = new LogAuthorization(administrator, authorizationsession, caSession);
      this.hardtokenauthorization = new HardTokenAuthorization(administrator, adminGroupSession, hardtokensession, authorizationsession, caSession);
    }
View Full Code Here

        boolean authorizedtoanyprofile = true;
        String caauthorizationstring = StringTools.strip(caauthorizationstr);
        String endentityprofilestring = StringTools.strip(endentityprofilestr);
        ArrayList<UserDataVO> returnval = new ArrayList<UserDataVO>();
        GlobalConfiguration globalconfiguration = getGlobalConfiguration(admin);
        RAAuthorization raauthorization = null;
        String caauthstring = caauthorizationstring;
        String endentityauth = endentityprofilestring;
        String sqlquery = "";
        int fetchsize = UserAdminConstants.MAXIMUM_QUERY_ROWCOUNT;

        if (numberofrows != 0) {
            fetchsize = numberofrows;
        }

        // Check if query is legal.
        if (query != null && !query.isLegalQuery()) {
            throw new IllegalQueryException();
        }

        if (query != null) {
            sqlquery = sqlquery + query.getQueryString();
        }

        if (caauthorizationstring == null || endentityprofilestring == null) {
            raauthorization = new RAAuthorization(admin, globalConfigurationSession, authorizationSession, caSession, endEntityProfileSession);
            caauthstring = raauthorization.getCAAuthorizationString();
            if (globalconfiguration.getEnableEndEntityProfileLimitations()) {
                endentityauth = raauthorization.getEndEntityProfileAuthorizationString(true);
            } else {
                endentityauth = "";
            }
        }
View Full Code Here

TOP

Related Classes of org.ejbca.core.model.ra.RAAuthorization

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.