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 criteria identifying a
24 * particular entity.
25 *
26 * Note that when used as a credential criteria for a credential resolver, the entity ID is the entity which owns
27 * the resolved credential. This entity ID may represent either a local entity (self) or remote entity, depending
28 * on the use case, e.g. in resolution of signature verification credentials, the owner entity ID
29 * would be a remote peer; in resolution of decryption credentials, the owner entity ID would be
30 * a local entity ID.
31 *
32 * See also {@link PeerEntityIDCriteria}.
33 */
34 public final class EntityIDCriteria implements Criteria {
35
36 /** Entity ID criteria. */
37 private String entityID;
38
39 /**
40 * Constructor.
41 *
42 * @param entity the entity ID represented by the criteria
43 */
44 public EntityIDCriteria(String entity) {
45 setEntityID(entity);
46 }
47
48 /**
49 * Get the entity ID represented by the criteria.
50 *
51 * @return the primary entity ID.
52 */
53 public String getEntityID() {
54 return entityID;
55 }
56
57 /**
58 * Set the entity ID represented by the criteria.
59 *
60 * @param entity The entityID to set.
61 */
62 public void setEntityID(String entity) {
63 String trimmed = DatatypeHelper.safeTrimOrNullString(entity);
64 if (trimmed == null) {
65 throw new IllegalArgumentException("Entity ID criteria must be supplied");
66 }
67 entityID = trimmed;
68 }
69
70 }