コード例 #1
0
  /**
   * Returns the decision associated with the current result.
   *
   * @return true if the user was granted access to the resource, otherwise false
   * @throws PepException if the <code>Behavior</code> configured in the <code>PepResponseFactory
   *     </code> indicates that for the specific AzDecision and AzStatus that an exception should be
   *     thrown
   */
  public boolean allowed() throws PepException {

    if (!(this.currentResult instanceof AzResult)) {
      return this.queryAllowed;
    }

    AzResult azResult = (AzResult) this.currentResult;

    switch (azResult.getAzDecision()) {
      case AZ_PERMIT:
        return true;
      case AZ_DENY:
        return false;
      case AZ_NOTAPPLICABLE:
        return enforceBehavior(this.getResponseFactory().getNotApplicableBehavior());
      case AZ_INDETERMINATE:
        switch (azResult.getAzStatusCode()) {
          case AZ_SYNTAX_ERROR:
            return enforceBehavior(this.getResponseFactory().getSyntaxErrorBehavior());
          case AZ_PROCESSING_ERROR:
            return enforceBehavior(this.getResponseFactory().getProcessingErrorBehavior());
          case AZ_MISSING_ATTRIBUTE:
            return enforceBehavior(this.getResponseFactory().getMissingAttributeBehavior());
        }
    } // end switch

    throw new PepException("AzResult.getAzDecision did not match any of the known values");
  }
コード例 #2
0
 static void printResultData(AzResult azResult, Log log) {
   log.debug(
       "\nTestAzAPI: "
           + "\n\t azResult.getAzResourceActionAssociation.getCorrelationId: "
           + azResult.getAzResourceActionAssociation().getCorrelationId()
           + "\n\t azResult.getAzResourceActionAssociationId: "
           + "\n\t\t "
           + azResult.getAzResourceActionAssociation()
           + "\n\t azResult.getAzDecision: "
           + azResult.getAzDecision()
           + "\n\t azResult.getAzStatusCode: "
           + azResult.getAzStatusCode()
           + "\n\t azResult.getStatusMessage: "
           + "\n\t\t "
           + azResult.getStatusMessage());
 }