1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.opensaml.saml2.binding.decoding;
18
19
20 import org.opensaml.common.binding.SAMLMessageContext;
21 import org.opensaml.common.xml.SAMLConstants;
22 import org.opensaml.ws.message.MessageContext;
23 import org.opensaml.ws.message.decoder.MessageDecodingException;
24 import org.opensaml.ws.transport.http.HTTPInTransport;
25 import org.opensaml.xml.parse.ParserPool;
26 import org.opensaml.xml.util.DatatypeHelper;
27 import org.slf4j.Logger;
28 import org.slf4j.LoggerFactory;
29
30
31
32
33
34
35 public class HTTPArtifactDecoder extends BaseSAML2MessageDecoder {
36
37
38 private final Logger log = LoggerFactory.getLogger(HTTPArtifactDecoder.class);
39
40
41
42
43
44
45 public HTTPArtifactDecoder(ParserPool pool) {
46 super(pool);
47 }
48
49
50 public String getBindingURI() {
51 return SAMLConstants.SAML2_ARTIFACT_BINDING_URI;
52 }
53
54
55 protected boolean isIntendedDestinationEndpointURIRequired(SAMLMessageContext samlMsgCtx) {
56 return false;
57 }
58
59
60 protected String getIntendedDestinationEndpointURI(SAMLMessageContext samlMsgCtx) throws MessageDecodingException {
61
62
63 return null;
64 }
65
66
67 protected void doDecode(MessageContext messageContext) throws MessageDecodingException {
68 if (!(messageContext instanceof SAMLMessageContext)) {
69 log.error("Invalid message context type, this decoder only support SAMLMessageContext");
70 throw new MessageDecodingException(
71 "Invalid message context type, this decoder only support SAMLMessageContext");
72 }
73
74 if (!(messageContext.getInboundMessageTransport() instanceof HTTPInTransport)) {
75 log.error("Invalid inbound message transport type, this decoder only support HTTPInTransport");
76 throw new MessageDecodingException(
77 "Invalid inbound message transport type, this decoder only support HTTPInTransport");
78 }
79
80 SAMLMessageContext samlMsgCtx = (SAMLMessageContext) messageContext;
81
82 HTTPInTransport inTransport = (HTTPInTransport) samlMsgCtx.getInboundMessageTransport();
83 String relayState = DatatypeHelper.safeTrim(inTransport.getParameterValue("RelayState"));
84 samlMsgCtx.setRelayState(relayState);
85
86 processArtifact(samlMsgCtx);
87
88 populateMessageContext(samlMsgCtx);
89 }
90
91
92
93
94
95
96
97
98
99 protected void processArtifact(SAMLMessageContext samlMsgCtx) throws MessageDecodingException {
100 HTTPInTransport inTransport = (HTTPInTransport) samlMsgCtx.getInboundMessageTransport();
101 String encodedArtifact = DatatypeHelper.safeTrimOrNullString(inTransport.getParameterValue("SAMLart"));
102 if (encodedArtifact == null) {
103 log.error("URL SAMLart parameter was missing or did not contain a value.");
104 throw new MessageDecodingException("URL TARGET parameter was missing or did not contain a value.");
105 }
106
107
108
109 }
110 }