View Javadoc

1   /**
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied. See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.ws.security.components.crypto;
21  
22  import java.util.HashSet;
23  import java.util.Collections;
24  import java.util.Set;
25  
26  /**
27   * This class holds the permitted values for encryption/signature/etc. algorithms on the
28   * inbound side. If the corresponding value is not null then the received algorithm must
29   * match the appropriate algorithm stored in this class.
30   */
31  public class AlgorithmSuite {
32      
33      private Set<String> signatureMethods = Collections.emptySet();
34      private Set<String> c14nAlgorithms = Collections.emptySet();
35      private Set<String> digestAlgorithms = Collections.emptySet();
36      private Set<String> transformAlgorithms = Collections.emptySet();
37      
38      private Set<String> encryptionMethods = Collections.emptySet();
39      private Set<String> keyWrapAlgorithms = Collections.emptySet();
40      
41      private Set<String> derivedKeyAlgorithms = Collections.emptySet();
42      
43      private int maximumSymmetricKeyLength = 256;
44      private int minimumSymmetricKeyLength = 128;
45      private int maximumAsymmetricKeyLength = 4096;
46      private int minimumAsymmetricKeyLength = 1024;
47      
48      private int signatureDerivedKeyLength;
49      private int encryptionDerivedKeyLength;
50  
51      public void addSignatureMethod(String signatureMethod) {
52          if (signatureMethods.isEmpty()) {
53              signatureMethods = new HashSet<String>();
54          }
55          signatureMethods.add(signatureMethod);
56      }
57      
58      public Set<String> getSignatureMethods() {
59          return signatureMethods;
60      }
61      
62      public void addC14nAlgorithm(String c14nAlgorithm) {
63          if (c14nAlgorithms.isEmpty()) {
64              c14nAlgorithms = new HashSet<String>();
65          }
66          c14nAlgorithms.add(c14nAlgorithm);
67      }
68      
69      public Set<String> getC14nAlgorithms() {
70          return c14nAlgorithms;
71      }
72      
73      public void addDigestAlgorithm(String digestAlgorithm) {
74          if (digestAlgorithms.isEmpty()) {
75              digestAlgorithms = new HashSet<String>();
76          }
77          digestAlgorithms.add(digestAlgorithm);
78      }
79      
80      public Set<String> getDigestAlgorithms() {
81          return digestAlgorithms;
82      }
83      
84      public void addTransformAlgorithm(String transformAlgorithm) {
85          if (transformAlgorithms.isEmpty()) {
86              transformAlgorithms = new HashSet<String>();
87          }
88          transformAlgorithms.add(transformAlgorithm);
89      }
90      
91      public Set<String> getTransformAlgorithms() {
92          return transformAlgorithms;
93      }
94      
95      public void addEncryptionMethod(String encryptionMethod) {
96          if (encryptionMethods.isEmpty()) {
97              encryptionMethods = new HashSet<String>();
98          }
99          encryptionMethods.add(encryptionMethod);
100     }
101     
102     public Set<String> getEncryptionMethods() {
103         return encryptionMethods;
104     }
105     
106     public void addKeyWrapAlgorithm(String keyWrapAlgorithm) {
107         if (keyWrapAlgorithms.isEmpty()) {
108             keyWrapAlgorithms = new HashSet<String>();
109         }
110         keyWrapAlgorithms.add(keyWrapAlgorithm);
111     }
112     
113     public Set<String> getKeyWrapAlgorithms() {
114         return keyWrapAlgorithms;
115     }
116     
117     public void addDerivedKeyAlgorithm(String derivedKeyAlgorithm) {
118         if (derivedKeyAlgorithms.isEmpty()) {
119             derivedKeyAlgorithms = new HashSet<String>();
120         }
121         derivedKeyAlgorithms.add(derivedKeyAlgorithm);
122     }
123     
124     public Set<String> getDerivedKeyAlgorithms() {
125         return derivedKeyAlgorithms;
126     }
127 
128     public int getMaximumSymmetricKeyLength() {
129         return maximumSymmetricKeyLength;
130     }
131 
132     public void setMaximumSymmetricKeyLength(int maximumSymmetricKeyLength) {
133         this.maximumSymmetricKeyLength = maximumSymmetricKeyLength;
134     }
135 
136     public int getMinimumAsymmetricKeyLength() {
137         return minimumAsymmetricKeyLength;
138     }
139 
140     public void setMinimumAsymmetricKeyLength(int minimumAsymmetricKeyLength) {
141         this.minimumAsymmetricKeyLength = minimumAsymmetricKeyLength;
142     }
143 
144     public int getMaximumAsymmetricKeyLength() {
145         return maximumAsymmetricKeyLength;
146     }
147 
148     public void setMaximumAsymmetricKeyLength(int maximumAsymmetricKeyLength) {
149         this.maximumAsymmetricKeyLength = maximumAsymmetricKeyLength;
150     }
151 
152     public int getEncryptionDerivedKeyLength() {
153         return encryptionDerivedKeyLength;
154     }
155 
156     public void setEncryptionDerivedKeyLength(int encryptionDerivedKeyLength) {
157         this.encryptionDerivedKeyLength = encryptionDerivedKeyLength;
158     }
159 
160     public int getSignatureDerivedKeyLength() {
161         return signatureDerivedKeyLength;
162     }
163 
164     public void setSignatureDerivedKeyLength(int signatureDerivedKeyLength) {
165         this.signatureDerivedKeyLength = signatureDerivedKeyLength;
166     }
167 
168     public int getMinimumSymmetricKeyLength() {
169         return minimumSymmetricKeyLength;
170     }
171 
172     public void setMinimumSymmetricKeyLength(int minimumSymmetricKeyLength) {
173         this.minimumSymmetricKeyLength = minimumSymmetricKeyLength;
174     }
175 
176 }