Java源码示例:org.wso2.balana.attr.DateTimeAttribute

示例1
private AttributeValue getAttributeValue(Literal literal) {
    IRI datatype = literal.getDatatype();
    switch (datatype.stringValue()) {
        case "http://www.w3.org/2001/XMLSchema#string":
            return new StringAttribute(literal.stringValue());
        case "http://www.w3.org/2001/XMLSchema#boolean":
            return BooleanAttribute.getInstance(literal.booleanValue());
        case "http://www.w3.org/2001/XMLSchema#double":
            return new DoubleAttribute(literal.doubleValue());
        case "http://www.w3.org/2001/XMLSchema#integer":
            return new IntegerAttribute(literal.longValue());
        case "http://www.w3.org/2001/XMLSchema#anyURI":
            try {
                return new AnyURIAttribute(new URI(literal.stringValue()));
            } catch (URISyntaxException e) {
                throw new ProcessingException("Not a valid URI");
            }
        case "https://www.w3.org/2001/XMLSchema#dateTime":
            return new DateTimeAttribute(new Date(literal.dateTimeValue().toInstant().toEpochMilli()));
        default:
            throw new ProcessingException("Datatype " + datatype + " is not supported");
    }
}
 
示例2
/**
 * Private helper that returns the return type for the given standard function. Note that this
 * doesn't check on the return value since the method always is called after getId, so we assume
 * that the function is present.
 */
private static String getReturnType(String functionName) {
	if (functionName.equals(NAME_DATE_ADD_YEARMONTHDURATION)
			|| functionName.equals(NAME_DATE_SUBTRACT_YEARMONTHDURATION))
		return DateAttribute.identifier;
	else
		return DateTimeAttribute.identifier;
}
 
示例3
/**
 * Handles requests for the current DateTime.
 */
private EvaluationResult handleDateTime(URI type, String 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());
}
 
示例4
public AttributeValue getInstance(Node root) throws Exception {
    return DateTimeAttribute.getInstance(root);
}
 
示例5
public AttributeValue getInstance(String value) throws Exception {
    return DateTimeAttribute.getInstance(value);
}
 
示例6
/**
 * Creates a new <code>Attribute</code>
 * 
 * @param id the id of the attribute
 * @param type the type of the attribute
 * @param issuer the attribute's issuer or null if there is none
 * @param issueInstant the moment when the attribute was issued, or null if it's unspecified
 * @param attributeValues actual <code>List</code> of <code>AttributeValue</code>  associated with
 * @param includeInResult whether to include this attribute in the result.
 * @param xacmlVersion xacml version
 */
public Attribute(URI id, URI type, String issuer, DateTimeAttribute issueInstant,
        List<AttributeValue> attributeValues, boolean includeInResult, int xacmlVersion) {
    this.id = id;
    this.type = type;
    this.issuer = issuer;
    this.issueInstant = issueInstant;
    this.attributeValues = attributeValues;
    this.includeInResult = includeInResult;
    this.xacmlVersion = xacmlVersion;
}
 
示例7
/**
 * Returns the value for the current dateTime. The current time, current date, and current
 * dateTime are consistent, so that they all represent the same moment. If this is the first
 * time that one of these three values has been requested, and caching is enabled, then the
 * three values will be resolved and stored.
 * <p/>
 * Note that the value supplied here applies only to dynamically resolved values, not those
 * supplied in the Request. In other words, this always returns a dynamically resolved value
 * local to the PDP, even if a different value was supplied in the Request. This is handled
 * correctly when the value is requested by its identifier.
 *
 * @return the current dateTime
 */
public synchronized DateTimeAttribute getCurrentDateTime() {
    long millis = dateTimeHelper();

    if (useCachedEnvValues)
        return currentDateTime;
    else
        return new DateTimeAttribute(new Date(millis));
}
 
示例8
/**
 * Creates a new <code>Attribute</code> of the type specified in the given
 * <code>AttributeValue</code>.for XACML 3 with one  <code>AttributeValue</code>
 *
 * @param id the id of the attribute
 * @param issuer the attribute's issuer or null if there is none
 * @param issueInstant the moment when the attribute was issued, or null if it's unspecified
 * @param value the actual value associated with the attribute meta-data
 * @param includeInResult  whether to include this attribute in the result.
 * @param version XACML version
 */
public Attribute(URI id, String issuer, DateTimeAttribute issueInstant, AttributeValue value,
                  boolean includeInResult, int version) {
    this(id, value.getType(), issuer, issueInstant, Arrays.asList(value), includeInResult,version);
}
 
示例9
/**
 * Creates a new <code>Attribute</code>  for XACML 2 and XACML 1.X with one <code>AttributeValue</code>
 *
 * @param id the id of the attribute
 * @param issuer the attribute's issuer or null if there is none
 * @param issueInstant the moment when the attribute was issued, or null if it's unspecified
 * @param value actual <code>List</code> of <code>AttributeValue</code>  associated with
 * @param version XACML version
 */
public Attribute(URI id, String issuer, DateTimeAttribute issueInstant, AttributeValue value,
                                                                                int version) {

    this(id, value.getType(), issuer, issueInstant, Arrays.asList(value), false, version);
}
 
示例10
/**
 * Returns the moment at which the attribute was issued, or null if no issue time was provided
 * 
 * @return the time of issuance or null
 */
public DateTimeAttribute getIssueInstant() {
    return issueInstant;
}
 
示例11
/**
 * Returns the value for the current dateTime as known by the PDP (if this value was also
 * supplied in the Request, this will generally be a different value). Details of caching or
 * location-based resolution are left to the underlying implementation.
 * 
 * @return the current date
 */
public DateTimeAttribute getCurrentDateTime();