001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one or more
003     * contributor license agreements.  See the NOTICE file distributed with
004     * this work for additional information regarding copyright ownership.
005     * The ASF licenses this file to You under the Apache License, Version 2.0
006     * (the "License"); you may not use this file except in compliance with
007     * the License.  You may obtain a copy of the License at
008     *
009     *      http://www.apache.org/licenses/LICENSE-2.0
010     *
011     * Unless required by applicable law or agreed to in writing, software
012     * distributed under the License is distributed on an "AS IS" BASIS,
013     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014     * See the License for the specific language governing permissions and
015     * limitations under the License.
016     */
017    package org.apache.activemq.transport.https;
018    
019    import java.io.IOException;
020    import java.net.HttpURLConnection;
021    import java.net.MalformedURLException;
022    import java.net.URI;
023    
024    import javax.net.ssl.HttpsURLConnection;
025    
026    import org.apache.activemq.transport.http.HttpTransport;
027    import org.apache.activemq.transport.util.TextWireFormat;
028    
029    public class HttpsTransport extends HttpTransport {
030    
031        public HttpsTransport(TextWireFormat wireFormat, URI remoteUrl) throws MalformedURLException {
032            super(wireFormat, remoteUrl);
033        }
034    
035        protected synchronized HttpURLConnection createSendConnection() throws IOException {
036            HttpsURLConnection conn = (HttpsURLConnection) getRemoteURL().openConnection();
037            conn.setDoOutput(true);
038            conn.setRequestMethod("POST");
039            configureConnection(conn);
040            conn.connect();
041            return conn;
042        }
043    
044        protected synchronized HttpURLConnection createReceiveConnection() throws IOException {
045            HttpsURLConnection conn = (HttpsURLConnection) getRemoteURL().openConnection();
046            conn.setDoOutput(false);
047            conn.setDoInput(true);
048            conn.setRequestMethod("GET");
049            configureConnection(conn);
050            conn.connect();
051            return conn;
052        }
053    
054    }