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.security;
18
19 import javax.xml.namespace.QName;
20
21 import org.opensaml.xml.security.Criteria;
22 import org.opensaml.xml.util.DatatypeHelper;
23
24 /**
25 * An implementation of {@link Criteria} which specifies criteria pertaining
26 * to SAML 2 metadata.
27 */
28 public final class MetadataCriteria implements Criteria {
29
30 /** Metadata role indicated by the criteria. */
31 private QName entityRole;
32
33 /** Metadata protocol of the role indicated by the criteria. */
34 private String entityProtocol;
35
36 /**
37 * Constructor.
38 *
39 * @param role the entity role
40 * @param protocol the entity protocol
41 */
42 public MetadataCriteria(QName role, String protocol) {
43 setRole(role);
44 setProtocol(protocol);
45 }
46
47 /**
48 * Get the entity protocol.
49 *
50 * @return the protocol.
51 */
52 public String getProtocol() {
53 return entityProtocol;
54 }
55
56 /**
57 * Set the entity protocol.
58 *
59 * @param protocol The protocol to set.
60 */
61 public void setProtocol(String protocol) {
62 entityProtocol = DatatypeHelper.safeTrimOrNullString(protocol);
63 }
64
65 /**
66 * Get the entity role.
67 *
68 * @return Returns the role.
69 */
70 public QName getRole() {
71 return entityRole;
72 }
73
74 /**
75 * Set the entity role.
76 *
77 * @param role the QName of entity role
78 */
79 public void setRole(QName role) {
80 if (role == null) {
81 throw new IllegalArgumentException("Role criteria may not be null");
82 }
83 entityRole = role;
84 }
85
86
87
88
89
90 }