*
* <p>This SAML 2-specific implementation extracts the value of the protocol message Destination attribute.</p>
*
* */
protected String getIntendedDestinationEndpointURI(SAMLMessageContext samlMsgCtx) throws MessageDecodingException {
SAMLObject samlMessage = samlMsgCtx.getInboundSAMLMessage();
String messageDestination = null;
if (samlMessage instanceof RequestAbstractType) {
RequestAbstractType request = (RequestAbstractType) samlMessage;
messageDestination = DatatypeHelper.safeTrimOrNullString(request.getDestination());
} else if (samlMessage instanceof StatusResponseType) {
StatusResponseType response = (StatusResponseType) samlMessage;
messageDestination = DatatypeHelper.safeTrimOrNullString(response.getDestination());
} else {
log.error("Invalid SAML message type encountered: {}", samlMessage.getElementQName().toString());
throw new MessageDecodingException("Invalid SAML message type encountered");
}
return messageDestination;
}