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.common.binding; 18 19 import java.util.ArrayList; 20 import java.util.List; 21 22 import javax.xml.namespace.QName; 23 24 import org.opensaml.common.SAMLObject; 25 import org.opensaml.saml2.metadata.Endpoint; 26 import org.opensaml.saml2.metadata.EntityDescriptor; 27 import org.opensaml.saml2.metadata.RoleDescriptor; 28 import org.opensaml.saml2.metadata.provider.MetadataProvider; 29 30 /** 31 * Endpoint selectors choose the endpoint that should be used to contact a peer. 32 */ 33 public abstract class AbstractEndpointSelector { 34 35 /** Bindings supported by the issuer. */ 36 private List<String> supportedIssuerBindings; 37 38 /** SAML request within the message flow. */ 39 private SAMLObject samlRequest; 40 41 /** SAML response within the message flow. */ 42 private SAMLObject samlResponse; 43 44 /** Provider of metadata for the relying party. */ 45 private MetadataProvider metadataProvider; 46 47 /** Metadata of party to select endpoing for. */ 48 private EntityDescriptor entityMetadata; 49 50 /** Role metadata of party to select endpoing for. */ 51 private RoleDescriptor entityRoleMetadata; 52 53 /** Type of endpoint needed. */ 54 private QName endpointType; 55 56 /** Constructor. */ 57 public AbstractEndpointSelector() { 58 supportedIssuerBindings = new ArrayList<String>(5); 59 } 60 61 /** 62 * Gets type of endpoint needed. 63 * 64 * @return type of endpoint needed 65 */ 66 public QName getEndpointType() { 67 return endpointType; 68 } 69 70 /** 71 * Sets the type of endpoint needed. 72 * 73 * @param type type of endpoint needed 74 */ 75 public void setEndpointType(QName type) { 76 endpointType = type; 77 } 78 79 /** 80 * Gets the metadata provider used to look up entity information. 81 * 82 * @return metadata provider used to look up entity information 83 */ 84 public MetadataProvider getMetadataProvider() { 85 return metadataProvider; 86 } 87 88 /** 89 * Sets the metadata provider used to look up entity information. 90 * 91 * @param provider metadata provider used to look up entity information 92 */ 93 public void setMetadataProvider(MetadataProvider provider) { 94 metadataProvider = provider; 95 } 96 97 /** 98 * Gets the metadata of the entity. 99 * 100 * @return metadata of the entity 101 */ 102 public EntityDescriptor getEntityMetadata() { 103 return entityMetadata; 104 } 105 106 /** 107 * Sets the metadata of the entity. 108 * 109 * @param entity metadata of the entity 110 */ 111 public void setEntityMetadata(EntityDescriptor entity) { 112 entityMetadata = entity; 113 } 114 115 /** 116 * Gets the role of the entity. 117 * 118 * @return role of the entity 119 */ 120 public RoleDescriptor getEntityRoleMetadata() { 121 return entityRoleMetadata; 122 } 123 124 /** 125 * Sets the role of the entity. 126 * 127 * @param role role of the entity 128 */ 129 public void setEntityRoleMetadata(RoleDescriptor role) { 130 entityRoleMetadata = role; 131 } 132 133 /** 134 * Gets the SAML request made. 135 * 136 * @return SAML request made 137 */ 138 public SAMLObject getSamlRequest() { 139 return samlRequest; 140 } 141 142 /** 143 * Sets the SAML request made. 144 * 145 * @param request SAML request made 146 */ 147 public void setSamlRequest(SAMLObject request) { 148 samlRequest = request; 149 } 150 151 /** 152 * Gets the response to the SAML request. 153 * 154 * @return response to the SAML request 155 */ 156 public SAMLObject getSamlResponse() { 157 return samlResponse; 158 } 159 160 /** 161 * Sets the response to the SAML request. 162 * 163 * @param response response to the SAML request 164 */ 165 public void setSamlResponse(SAMLObject response) { 166 samlResponse = response; 167 } 168 169 /** 170 * Gets the list of bindings supported by the message issuer. 171 * 172 * @return list of bindings supported by the message issuer 173 */ 174 public List<String> getSupportedIssuerBindings() { 175 return supportedIssuerBindings; 176 } 177 178 /** 179 * Selects the endpoint to which messages should be sent. 180 * 181 * @return endpoint to which messages should be sent, or null if no suitable endpoint can be determined 182 */ 183 public abstract Endpoint selectEndpoint(); 184 }