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 pertaining
24 * to peer entity IDs. This is typically used only in conjunction with a
25 * {@link EntityIDCriteria}, where the peer is interpreted to be relative
26 * to that primary entity ID. In this sense it serves to scope the primary entity ID.
27 *
28 * Note that the peer entity ID may be either local or remote,
29 * depending on whether the associated primary entity ID is remote or local.
30 */
31 public final class PeerEntityIDCriteria implements Criteria {
32
33 /** Peer entity ID criteria. */
34 private String peerID;
35
36 /**
37 * Constructor.
38 *
39 * @param peer the entity ID which is the peer relative to a primary entity ID
40 */
41 public PeerEntityIDCriteria(String peer) {
42 setPeerID(peer);
43 }
44
45 /**
46 * Get the entity ID which is the peer relative to a primary entity ID.
47 *
48 * @return the peer entity ID.
49 */
50 public String getPeerID() {
51 return peerID;
52 }
53
54 /**
55 * Set the entity ID which is the peer relative to a primary entity ID.
56 *
57 * @param peer The peerID to set.
58 */
59 public void setPeerID(String peer) {
60 String trimmed = DatatypeHelper.safeTrimOrNullString(peer);
61 if (trimmed == null) {
62 throw new IllegalArgumentException("Peer entity ID criteria must be supplied");
63 }
64 peerID = trimmed;
65 }
66
67 }