View Javadoc

1   /*
2    * Copyright [2007] [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.xml.security.keyinfo;
18  
19  import org.opensaml.xml.security.Criteria;
20  import org.opensaml.xml.signature.KeyInfo;
21  
22  /**
23   * An implementation of {@link Criteria} which specifies criteria based
24   * on the contents of a {@link KeyInfo} element.
25   */
26  public final class KeyInfoCriteria implements Criteria {
27      
28      /** The KeyInfo which serves as the source for credential criteria. */
29      private KeyInfo keyInfo;
30      
31      /**
32       * Constructor.
33       *
34       * @param newKeyInfo the KeyInfo credential criteria to use
35       */
36      public KeyInfoCriteria(KeyInfo newKeyInfo) {
37         setKeyInfo(newKeyInfo);
38      }
39  
40      /**
41       * Gets the KeyInfo which is the source of credential criteria.
42       * 
43       * @return the KeyInfo credential criteria
44       */
45      public KeyInfo getKeyInfo() {
46          return keyInfo;
47      }
48      
49      /**
50       * Sets the KeyInfo which is the source of credential criteria.
51       * 
52       * @param newKeyInfo the KeyInfo to use as credential criteria
53       * 
54       */
55      public void setKeyInfo(KeyInfo newKeyInfo) {
56          // Note: we allow KeyInfo to be null to handle case where application context,
57          // other accompanying criteria, etc should be used to resolve credentials.
58          keyInfo = newKeyInfo;
59      }
60  
61  }