logger.debug("Received IDP Discovery request without entityId");
throw new ServletException(new SAMLException("Entity ID parameter must be specified"));
}
// Load entity metadata (IDP Disco, 318)
SAMLMessageContext messageContext;
try {
request.setAttribute(SAMLConstants.LOCAL_ENTITY_ID, entityId);
messageContext = contextProvider.getLocalEntity(request, response);
} catch (MetadataProviderException e) {
logger.debug("Error loading metadata", e);
throw new ServletException(new SAMLException("Error loading metadata", e));
}
// URL to return the selected IDP to, use default when not present
String returnURL = request.getParameter(RETURN_URL_PARAM);
if (returnURL == null) {
returnURL = getDefaultReturnURL(messageContext);
} else if (!isResponseURLValid(returnURL, messageContext)) {
logger.debug("Return URL {} designated in IDP Discovery request for entity {} is not valid", returnURL, entityId);
throw new ServletException(new SAMLException("Return URL designated in IDP Discovery request for entity is not valid"));
}
// Cannot determine the return URL
if (returnURL == null) {
throw new ServletException(new SAMLException("Can't determine IDP Discovery return URL for entity " + messageContext.getLocalEntityRoleMetadata().getID()));
}
// Policy to be used, MAY be present, only default "single" policy is supported
String policy = request.getParameter(POLICY_PARAM);
if (policy != null && !policy.equals(IDP_DISCO_PROTOCOL_SINGLE)) {