View Javadoc
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.syncope.client.lib.batch;
20  
21  import java.io.ByteArrayOutputStream;
22  import java.io.IOException;
23  import java.io.OutputStream;
24  import org.apache.cxf.Bus;
25  import org.apache.cxf.configuration.security.ProxyAuthorizationPolicy;
26  import org.apache.cxf.message.Message;
27  import org.apache.cxf.service.model.EndpointInfo;
28  import org.apache.cxf.transport.http.Address;
29  import org.apache.cxf.transport.http.HTTPConduit;
30  import org.apache.cxf.transport.http.auth.DefaultBasicAuthSupplier;
31  import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
32  import org.apache.cxf.ws.addressing.EndpointReferenceType;
33  
34  public class BatchOfflineHTTPConduit extends HTTPConduit {
35  
36      private ByteArrayOutputStream baos;
37  
38      public BatchOfflineHTTPConduit(final Bus bus, final EndpointInfo ei) throws IOException {
39          this(bus, ei, null);
40      }
41  
42      public BatchOfflineHTTPConduit(
43              final Bus bus,
44              final EndpointInfo ei,
45              final EndpointReferenceType t) throws IOException {
46  
47          super(bus, ei, t);
48          this.proxyAuthSupplier = new DefaultBasicAuthSupplier();
49          this.proxyAuthorizationPolicy = new ProxyAuthorizationPolicy();
50      }
51  
52      @Override
53      protected void setupConnection(
54              final Message message, final Address address,
55              final HTTPClientPolicy csPolicy) throws IOException {
56      }
57  
58      @Override
59      public HTTPClientPolicy getClient(final Message message) {
60          return new HTTPClientPolicy();
61      }
62  
63      @Override
64      protected OutputStream createOutputStream(
65              final Message message,
66              final boolean needToCacheRequest,
67              final boolean isChunking,
68              final int chunkThreshold) throws IOException {
69  
70          baos = new ByteArrayOutputStream();
71          return baos;
72      }
73  
74      public ByteArrayOutputStream getOutputStream() {
75          return baos;
76      }
77  }