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 name criteria.
24 */
25 public final class KeyNameCriteria implements Criteria {
26
27 /** Key name of resolved credentials. */
28 private String keyName;
29
30 /**
31 * Constructor.
32 *
33 * @param name key name
34 */
35 public KeyNameCriteria(String name) {
36 setKeyName(name);
37 }
38
39 /**
40 * Get the key name criteria.
41 *
42 * @return Returns the keyName.
43 */
44 public String getKeyName() {
45 return keyName;
46 }
47
48 /**
49 * Set the key name criteria.
50 *
51 * @param name The keyName to set.
52 */
53 public void setKeyName(String name) {
54 if (DatatypeHelper.isEmpty(name)) {
55 throw new IllegalArgumentException("Key name criteria value must be supplied");
56 }
57 keyName = DatatypeHelper.safeTrimOrNullString(name);
58 }
59
60 }