コード例 #1
0
  /**
   * Used to get the current time, date, or dateTime. If one of those values isn't being asked for,
   * or if the types are wrong, then an empty bag is returned.
   *
   * @param attributeType the datatype of the attributes to find, which must be time, date, or
   *     dateTime for this module to resolve a value
   * @param attributeId the identifier of the attributes to find, which must be one of the three
   *     ENVIRONMENT_* fields for this module to resolve a value
   * @param issuer the issuer of the attributes, or null if unspecified
   * @param subjectCategory the category of the attribute or null, which ignored since this only
   *     handles non-subjects
   * @param context the representation of the request data
   * @param designatorType the type of designator, which must be ENVIRONMENT_TARGET for this module
   *     to resolve a value
   * @return the result of attribute retrieval, which will be a bag with a single attribute, an
   *     empty bag, or an error
   */
  public EvaluationResult findAttribute(
      URI attributeType,
      URI attributeId,
      URI issuer,
      URI subjectCategory,
      EvaluationCtx context,
      int designatorType) {
    // we only know about environment attributes
    if (designatorType != AttributeDesignator.ENVIRONMENT_TARGET)
      return new EvaluationResult(BagAttribute.createEmptyBag(attributeType));

    // figure out which attribute we're looking for
    String attrName = attributeId.toString();

    if (attrName.equals(ENVIRONMENT_CURRENT_TIME)) {
      return handleTime(attributeType, issuer, context);
    } else if (attrName.equals(ENVIRONMENT_CURRENT_DATE)) {
      return handleDate(attributeType, issuer, context);
    } else if (attrName.equals(ENVIRONMENT_CURRENT_DATETIME)) {
      return handleDateTime(attributeType, issuer, context);
    }

    // if we got here, then it's an attribute that we don't know
    return new EvaluationResult(BagAttribute.createEmptyBag(attributeType));
  }
コード例 #2
0
  /** Handles requests for the current DateTime. */
  private EvaluationResult handleDateTime(URI type, URI issuer, EvaluationCtx context) {
    // make sure they're asking for a dateTime attribute
    if (!type.toString().equals(DateTimeAttribute.identifier))
      return new EvaluationResult(BagAttribute.createEmptyBag(type));

    // get the value from the context
    return makeBag(context.getCurrentDateTime());
  }
コード例 #3
0
  /**
   * Creates an empty evaluation result for the provided attribute type.
   *
   * @param attributeType The URI specifying the attribute type.
   * @return Returns an empty evaluation result.
   */
  public static EvaluationResult createEmptyEvaluationResult(final URI attributeType) {

    return new EvaluationResult(BagAttribute.createEmptyBag(attributeType));
  }