ResourceResult.java revision 6636284dd99df27fda992fb77fb6236657269ec9
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2006 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: ResourceResult.java,v 1.5 2009/10/12 17:53:05 dillidorai Exp $
*
* Portions Copyrighted 2011-2014 ForgeRock AS.
*/
/**
* Class that encapsulates a tree of resource names, with each node
* having an associated policy decision.
* @supported.api
* @deprecated since 12.0.0
*/
public class ResourceResult {
/**
* Constant to indicate subtree level scope for ResourceResult evaluation
*
* @supported.api
*/
/**
* Constant to indicate strict subtree level scope for
* <code>ResourceResult</code> evaluation
*
* @supported.api
*/
/**
* Constant to indicate base (self) level scope for
* <code>ResourceResult</code> evaluation
*
* @supported.api
*/
/**
* Constant used internally as a place holder for all encompassing root
* resoure name. Any resource name is considered to be sub resource of
* this resource name.
*/
private boolean advicesAreSet = false;
//tracks the envMap used to compute ResourceResult
/**
* Used in remote api for result caching
*/
private boolean stale = false;
/**
*
* No argument constructor
*/
ResourceResult() {
}
/**
* Constructs a resource result given the resource name and policy decison
* @param resourceName resource name for this resource result
* @param policyDecision policy decision associated with the resource name
*/
policyDecision ) {
this.resourceName = resourceName;
}
/**
* Returns the resource name of this resource result
* @return resource name of this resource result
* @supported.api
*/
public String getResourceName() {
return resourceName;
}
/**
* Sets the resource name of this resource result
* @param resourceName resource name for this resource result
*/
this.resourceName = resourceName;
this.stringForm = null;
}
/**
* Returns the policy decision associated with this resource result
* @return policy decision associated with this resource result
* @supported.api
*/
public PolicyDecision getPolicyDecision() {
return policyDecision;
}
/**
* Sets the policy decision for this resource result
* @param policyDecision policy decision for this resource result
*/
this.policyDecision = policyDecision;
if ( pdTtl < timeToLive ) {
timeToLive = pdTtl;
}
this.stringForm = null;
}
/**
* Returns the child resource results of this resource result
* @return child resource results of this resource result
* @supported.api
*/
public Set getResourceResults() {
return resourceResults;
}
/**
* Sets the child resource results of this resource result
* @param resourceResults child resource results of this resource result
*/
if (resourceResults == null) {
this.resourceResults.clear();
} else {
this.resourceResults = resourceResults;
if (policyDecision != null) {
}
if ( ttl < timeToLive) {
timeToLive = ttl;
}
}
}
this.stringForm = null;
}
/**
* Converts an XML representation of resource result to ResourceResult
* @param resourceResultNode XML DOM node representing resource result
* @return <code>ResourceResult</code> object representation of resource
* result
* @throws PolicyException if the conversion fails
*/
throws PolicyException {
if (resourceName == null) {
}
} else {
}
}
}
return resourceResult;
}
/**
* Returns a string representation of this resource result
* @return a string representation of this resource result
* @supported.api
*/
if (stringForm == null) {
.append("PolicyDecision : ")
.append("Nested ResourceResults : ")
}
return stringForm;
}
/**
* Returns an XML representation of this resource result
* @return an XML representation of this resource result
* @supported.api
*/
.append("=\"")
/*
.append("\" ").append("timeToLive")
.append("=\"").append(timeToLive).append("\"")
.append( " ").append("hasAdvices")
.append("=\"").append(hasAdvices())
*/
.append("\">")
if (policyDecision != null) {
}
}
.append( ">")
}
return xmlForm;
}
/**
* Adds a resource result to the resource result sub tree rooted at
* this ResourceResult
* @param resourceResult resource result to be added
* @param serviceType service type of the resource result being added
* @throws PolicyException if the resourceResult could not be added
*/
}
/**
* Adds a resource result to the resource result sub tree rooted at
* this ResourceResult
* @param resourceResult resource result to be added
* @param resourceComparator resource name comparator
* @throws PolicyException if the resourceResult could not be added
*/
if (!this.isSuperResourceResultOf(resourceResult,
} else {
boolean directChild = true;
while (resourceResultIter.hasNext()) {
directChild = false;
break;
}
}
if (directChild) {
}
}
}
}
if ( rrTtl < timeToLive ) {
timeToLive = rrTtl;
}
this.stringForm = null;
}
/**
* Marks result as stale
*/
public void markStale() {
stale = true;
}
/**
* Determines if result is stale
*
* @return true if result is stale
*/
public boolean isStale() {
return stale;
}
/**
* Checks if this resource result is a super resource result of
* the argument resource result
* @param resourceResult resource result for which we want to check
* whether this resource result is a super resource result
* @param resourceComparator - resource comparator
* @return <code>true</code> if this resource result is a super
* resource result of resourceResult, else returns
* <code>false</code>
* @throws PolicyException if there is any error while comparing the
* resourceResult
*/
boolean isSuperResource = false;
isSuperResource = true;
} else if (resourceComparator != null) {
boolean interpretWildCard = false;
isSuperResource = true;
}
// Results will contain both incoming URL as well as matched policy URL with decision.
// The problem is we don't know which order results will come in.
// Incoming URL will be missing policyDecision so we need to check resourceResult contains '*'
// and if it does, check if resourceResult is parent of incoming URL and use parent's
// policyDecision for this object.
//check if policyDecision is null
//if null, then copy policyDecision from parents
}
}
}
} else {
}
return isSuperResource;
}
/**
* Returns the GMT time in milliseconds since epoch when this object is to
* be treated as expired. That is the resource result would
* likely be different after that time.
* This is computed as a result of time conditions specified in the Policy
* definitions.
*
* @return time to live
*/
public long getTimeToLive() {
return timeToLive;
}
/**
* Checks wether advices are set in this object
* @return <code>true</code>, if advices are set, else <code>false</code>
*/
public boolean hasAdvices() {
return advicesAreSet;
}
/**
* Sets the environment map that was used while computing the
* resource result
* @param envMap the environment map that was used while computing the
* resource result
*/
}
/**
* Returns the environment map that was used while computing the
* resource result
* @param the environment map that was used while computing the
* resource result
*/
return envMap;
}
}