View Javadoc

1   /*
2    * Copyright [2006] [University Corporation for Advanced Internet Development, Inc.]
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.opensaml.ws.security;
18  
19  import java.util.List;
20  
21  import org.opensaml.ws.message.MessageContext;
22  
23  /**
24   * A security policy is a collection of {@link SecurityPolicyRule}, evaluated against a {@link MessageContext}, that
25   * is meant to determine if a message is well-formed, valid, and otherwise okay to process.
26   * 
27   * Security policies <strong>MUST</strong> be thread safe and stateless.
28   */
29  public interface SecurityPolicy {
30  
31      /**
32       * Gets the rules that are evaluated for this policy.
33       * 
34       * @return rules that are evaluated for this policy
35       */
36      public List<SecurityPolicyRule> getPolicyRules();
37  
38      /**
39       * Evaluates this policy.  Rules are evaluated in the order returned by {@link #getPolicyRules()}.
40       * 
41       * @param messageContext the message context being evaluated
42       * 
43       * @throws SecurityPolicyException thrown if the requirements of the security policy, including those of
44       *          any of its rules, are not satisfied by the given message context.  Also thrown if any error 
45       *          is encountered during evaluation
46       */
47      public void evaluate(MessageContext messageContext) throws SecurityPolicyException;
48  }