This project has retired. For details please refer to its Attic page.
WssMUTube xref

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.chemistry.opencmis.commons.impl.tube.client;
20  
21  import javax.xml.namespace.QName;
22  
23  import org.apache.chemistry.opencmis.commons.exceptions.CmisConnectionException;
24  import org.apache.chemistry.opencmis.commons.impl.tube.AbstractWssTube;
25  
26  import com.sun.xml.ws.api.SOAPVersion;
27  import com.sun.xml.ws.api.WSBinding;
28  import com.sun.xml.ws.api.message.Header;
29  import com.sun.xml.ws.api.message.HeaderList;
30  import com.sun.xml.ws.api.message.Packet;
31  import com.sun.xml.ws.api.pipe.NextAction;
32  import com.sun.xml.ws.api.pipe.Tube;
33  import com.sun.xml.ws.api.pipe.TubeCloner;
34  
35  public class WssMUTube extends AbstractWssTube {
36  
37      private final SOAPVersion soapVersion;
38  
39      public WssMUTube(WSBinding binding, Tube next) {
40          super(next);
41          soapVersion = binding.getSOAPVersion();
42      }
43  
44      protected WssMUTube(WssMUTube that, TubeCloner cloner) {
45          super(that, cloner);
46          soapVersion = that.soapVersion;
47      }
48  
49      public WssMUTube copy(TubeCloner cloner) {
50          return new WssMUTube(this, cloner);
51      }
52  
53      @Override
54      public NextAction processResponse(Packet response) {
55          if (response.getMessage() == null) {
56              return super.processResponse(response);
57          }
58  
59          HeaderList headers = response.getMessage().getHeaders();
60  
61          for (int i = 0; i < headers.size(); i++) {
62              if (!headers.isUnderstood(i)) {
63                  Header header = headers.get(i);
64                  if (!header.isIgnorable(soapVersion, soapVersion.implicitRoleSet)) {
65                      QName qName = new QName(header.getNamespaceURI(), header.getLocalPart());
66                      if (WSSE.equals(qName)) {
67                          checkSecurityHeader(header);
68                      } else {
69                          throw new CmisConnectionException("MustUnderstand header is not understood: " + qName);
70                      }
71                  }
72              }
73          }
74  
75          return super.processResponse(response);
76      }
77  
78      private void checkSecurityHeader(Header header) {
79          // TODO
80      }
81  }