Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/sun/xacml/finder/PolicyFinderResult.java


1   
2   /*
3    * @(#)PolicyFinderResult.java
4    *
5    * Copyright 2003-2004 Sun Microsystems, Inc. All Rights Reserved.
6    *
7    * Redistribution and use in source and binary forms, with or without
8    * modification, are permitted provided that the following conditions are met:
9    *
10   *   1. Redistribution of source code must retain the above copyright notice,
11   *      this list of conditions and the following disclaimer.
12   * 
13   *   2. Redistribution in binary form must reproduce the above copyright
14   *      notice, this list of conditions and the following disclaimer in the
15   *      documentation and/or other materials provided with the distribution.
16   *
17   * Neither the name of Sun Microsystems, Inc. or the names of contributors may
18   * be used to endorse or promote products derived from this software without
19   * specific prior written permission.
20   * 
21   * This software is provided "AS IS," without a warranty of any kind. ALL
22   * EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING
23   * ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
24   * OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN MICROSYSTEMS, INC. ("SUN")
25   * AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE
26   * AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS
27   * DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE FOR ANY LOST
28   * REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL,
29   * INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY
30   * OF LIABILITY, ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE,
31   * EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32   *
33   * You acknowledge that this software is not designed or intended for use in
34   * the design, construction, operation or maintenance of any nuclear facility.
35   */
36  
37  package com.sun.xacml.finder;
38  
39  import com.sun.xacml.AbstractPolicy;
40  
41  import com.sun.xacml.ctx.Status;
42  
43  
44  /**
45   * This is used as the return value for the findPolicy() methods in the
46   * <code>PolicyFinder</code>. It communicates either a found policy that
47   * applied to the request (eg, the target matches), an Indeterminate state,
48   * or no applicable policies.
49   * <p>
50   * The OnlyOneApplicable combining logic is used in looking for a policy,
51   * so the result from calling findPolicy can never be more than one policy.
52   *
53   * @since 1.0
54   * @author Seth Proctor
55   */
56  public class PolicyFinderResult
57  {
58  
59      // the single policy being returned
60      private AbstractPolicy policy;
61  
62      // status that represents an error occurred
63      private Status status;
64  
65      /**
66       * Creates a result saying that no applicable policies were found.
67       */
68      public PolicyFinderResult() {
69          policy = null;
70          status = null;
71      }
72  
73      /**
74       * Creates a result containing a single applicable policy.
75       *
76       * @param policy the applicable policy
77       */
78      public PolicyFinderResult(AbstractPolicy policy) {
79          this.policy = policy;
80          status = null;
81      }
82  
83      /**
84       * Create a result of Indeterminate, including Status data.
85       *
86       * @param status the error information
87       */
88      public PolicyFinderResult(Status status) {
89          policy = null;
90          this.status = status;
91      }
92  
93      /**
94       * Returns true if the result was NotApplicable.
95       *
96       * @return true if the result was NotApplicable
97       */
98      public boolean notApplicable() {
99          return ((policy == null) && (status == null));
100     }
101 
102     /**
103      * Returns true if the result was Indeterminate.
104      *
105      * @return true if there was an error
106      */
107     public boolean indeterminate() {
108         return (status != null);
109     }
110 
111     /**
112      * Returns the found policy, or null if there was an error or no policy
113      * was found.
114      *
115      * @return the applicable policy or null
116      */
117     public AbstractPolicy getPolicy() {
118         return policy;
119     }
120 
121     /**
122      * Returns the status if there was an error, or null if no error occurred.
123      *
124      * @return the error status data or null
125      */
126     public Status getStatus() {
127         return status;
128     }
129 
130 }