View Javadoc

1   /*
2    * Copyright [2006] [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.ws.soap.soap11.decoder.http;
18  
19  import org.opensaml.ws.message.MessageContext;
20  import org.opensaml.ws.message.decoder.MessageDecodingException;
21  import org.opensaml.ws.soap.soap11.decoder.SOAP11Decoder;
22  import org.opensaml.ws.transport.http.HTTPInTransport;
23  import org.opensaml.xml.parse.ParserPool;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  
27  /**
28   * Basic SOAP 1.1 over decoder for HTTP transport.
29   */
30  public class HTTPSOAP11Decoder extends SOAP11Decoder {
31  
32      /** Class logger. */
33      private final Logger log = LoggerFactory.getLogger(HTTPSOAP11Decoder.class);
34      
35      /** Constructor. */
36      public HTTPSOAP11Decoder() {
37          super();
38      }
39  
40      /**
41       * Constructor.
42       * 
43       * @param pool parser pool used to deserialize messages
44       */
45      public HTTPSOAP11Decoder(ParserPool pool) {
46          super(pool);
47      }
48  
49      /** {@inheritDoc} */
50      protected void doDecode(MessageContext messageContext) throws MessageDecodingException {
51          
52          if (!(messageContext.getInboundMessageTransport() instanceof HTTPInTransport)) {
53              log.error("Invalid inbound message transport type, this decoder only support HTTPInTransport");
54              throw new MessageDecodingException(
55                      "Invalid inbound message transport type, this decoder only support HTTPInTransport");
56          }
57  
58          HTTPInTransport inTransport = (HTTPInTransport) messageContext.getInboundMessageTransport();
59          if (!inTransport.getHTTPMethod().equalsIgnoreCase("POST")) {
60              throw new MessageDecodingException("This message deocoder only supports the HTTP POST method");
61          }
62          
63          super.doDecode(messageContext);
64  
65      }
66  
67  }