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.criteria;
18  
19  import org.opensaml.xml.security.Criteria;
20  import org.opensaml.xml.util.DatatypeHelper;
21  
22  /**
23   * An implementation of {@link Criteria} which specifies key algorithm criteria.
24   */
25  public final class KeyAlgorithmCriteria implements Criteria {
26      
27      /** Key algorithm type of resolved credentials. */
28      private String keyAlgorithm;
29      
30      /**
31       * Constructor.
32       *
33       * @param algorithm key algorithm
34       */
35      public KeyAlgorithmCriteria(String algorithm) {
36          setKeyAlgorithm(algorithm);
37      }
38   
39      /**
40       * Get the key algorithm criteria.
41       * 
42       * @return returns the keyAlgorithm.
43       */
44      public String getKeyAlgorithm() {
45          return keyAlgorithm;
46      }
47  
48      /**
49       * Set the key algorithm criteria.
50       * 
51       * @param algorithm The keyAlgorithm to set.
52       */
53      public void setKeyAlgorithm(String algorithm) {
54          if (DatatypeHelper.isEmpty(algorithm)) {
55              throw new IllegalArgumentException("Key algorithm criteria value must be supplied");
56          }
57          keyAlgorithm = DatatypeHelper.safeTrimOrNullString(algorithm);
58      }
59  
60  }