mirror of
				https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
				synced 2025-11-04 04:28:10 +00:00 
			
		
		
		
	removing old trunk files
This commit is contained in:
		@@ -1,215 +0,0 @@
 | 
			
		||||
//
 | 
			
		||||
// HTTPSClientSession.cpp
 | 
			
		||||
//
 | 
			
		||||
// $Id: //poco/Main/NetSSL_OpenSSL/src/HTTPSClientSession.cpp#13 $
 | 
			
		||||
//
 | 
			
		||||
// Library: NetSSL_OpenSSL
 | 
			
		||||
// Package: HTTPSClient
 | 
			
		||||
// Module:  HTTPSClientSession
 | 
			
		||||
//
 | 
			
		||||
// Copyright (c) 2006-2010, Applied Informatics Software Engineering GmbH.
 | 
			
		||||
// and Contributors.
 | 
			
		||||
//
 | 
			
		||||
// Permission is hereby granted, free of charge, to any person or organization
 | 
			
		||||
// obtaining a copy of the software and accompanying documentation covered by
 | 
			
		||||
// this license (the "Software") to use, reproduce, display, distribute,
 | 
			
		||||
// execute, and transmit the Software, and to prepare derivative works of the
 | 
			
		||||
// Software, and to permit third-parties to whom the Software is furnished to
 | 
			
		||||
// do so, all subject to the following:
 | 
			
		||||
// 
 | 
			
		||||
// The copyright notices in the Software and this entire statement, including
 | 
			
		||||
// the above license grant, this restriction and the following disclaimer,
 | 
			
		||||
// must be included in all copies of the Software, in whole or in part, and
 | 
			
		||||
// all derivative works of the Software, unless such copies or derivative
 | 
			
		||||
// works are solely in the form of machine-executable object code generated by
 | 
			
		||||
// a source language processor.
 | 
			
		||||
// 
 | 
			
		||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
			
		||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
			
		||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 | 
			
		||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 | 
			
		||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 | 
			
		||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 | 
			
		||||
// DEALINGS IN THE SOFTWARE.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#include "Poco/Net/HTTPSClientSession.h"
 | 
			
		||||
#include "Poco/Net/SecureStreamSocket.h"
 | 
			
		||||
#include "Poco/Net/SecureStreamSocketImpl.h"
 | 
			
		||||
#include "Poco/Net/SSLManager.h"
 | 
			
		||||
#include "Poco/Net/HTTPRequest.h"
 | 
			
		||||
#include "Poco/Net/HTTPResponse.h"
 | 
			
		||||
#include "Poco/Net/NetException.h"
 | 
			
		||||
#include "Poco/NumberFormatter.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
using Poco::NumberFormatter;
 | 
			
		||||
using Poco::IllegalStateException;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
namespace Poco {
 | 
			
		||||
namespace Net {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HTTPSClientSession::HTTPSClientSession():
 | 
			
		||||
	HTTPClientSession(SecureStreamSocket()),
 | 
			
		||||
	_pContext(SSLManager::instance().defaultClientContext())
 | 
			
		||||
{
 | 
			
		||||
	setPort(HTTPS_PORT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HTTPSClientSession::HTTPSClientSession(const SecureStreamSocket& socket):
 | 
			
		||||
	HTTPClientSession(socket),
 | 
			
		||||
	_pContext(socket.context())
 | 
			
		||||
{
 | 
			
		||||
	setPort(HTTPS_PORT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HTTPSClientSession::HTTPSClientSession(const SecureStreamSocket& socket, Session::Ptr pSession):
 | 
			
		||||
        HTTPClientSession(socket),
 | 
			
		||||
        _pContext(socket.context()),
 | 
			
		||||
        _pSession(pSession)
 | 
			
		||||
{
 | 
			
		||||
        setPort(HTTPS_PORT);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HTTPSClientSession::HTTPSClientSession(const std::string& host, Poco::UInt16 port):
 | 
			
		||||
        HTTPClientSession(SecureStreamSocket()),
 | 
			
		||||
        _pContext(SSLManager::instance().defaultClientContext())
 | 
			
		||||
{
 | 
			
		||||
	setHost(host);
 | 
			
		||||
	setPort(port);
 | 
			
		||||
	SecureStreamSocket sss(socket());
 | 
			
		||||
	sss.setPeerHostName(host);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HTTPSClientSession::HTTPSClientSession(Context::Ptr pContext):
 | 
			
		||||
	HTTPClientSession(SecureStreamSocket(pContext)),
 | 
			
		||||
	_pContext(pContext)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HTTPSClientSession::HTTPSClientSession(Context::Ptr pContext, Session::Ptr pSession):
 | 
			
		||||
        HTTPClientSession(SecureStreamSocket(pContext, pSession)),
 | 
			
		||||
        _pContext(pContext),
 | 
			
		||||
        _pSession(pSession)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HTTPSClientSession::HTTPSClientSession(const std::string& host, Poco::UInt16 port, Context::Ptr pContext):
 | 
			
		||||
        HTTPClientSession(SecureStreamSocket(pContext)),
 | 
			
		||||
        _pContext(pContext)
 | 
			
		||||
{
 | 
			
		||||
	setHost(host);
 | 
			
		||||
	setPort(port);
 | 
			
		||||
	SecureStreamSocket sss(socket());
 | 
			
		||||
	sss.setPeerHostName(host);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HTTPSClientSession::HTTPSClientSession(const std::string& host, Poco::UInt16 port, Context::Ptr pContext, Session::Ptr pSession):
 | 
			
		||||
        HTTPClientSession(SecureStreamSocket(pContext, pSession)),
 | 
			
		||||
        _pContext(pContext),
 | 
			
		||||
        _pSession(pSession)
 | 
			
		||||
{
 | 
			
		||||
        setHost(host);
 | 
			
		||||
        setPort(port);
 | 
			
		||||
        SecureStreamSocket sss(socket());
 | 
			
		||||
        sss.setPeerHostName(host);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
HTTPSClientSession::~HTTPSClientSession()
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
bool HTTPSClientSession::secure() const
 | 
			
		||||
{
 | 
			
		||||
        return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void HTTPSClientSession::abort()
 | 
			
		||||
{
 | 
			
		||||
        SecureStreamSocket sss(socket());
 | 
			
		||||
        sss.abort();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
X509Certificate HTTPSClientSession::serverCertificate()
 | 
			
		||||
{
 | 
			
		||||
        SecureStreamSocket sss(socket());
 | 
			
		||||
	return sss.peerCertificate();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
std::string HTTPSClientSession::proxyRequestPrefix() const
 | 
			
		||||
{
 | 
			
		||||
	return std::string();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void HTTPSClientSession::proxyAuthenticate(HTTPRequest& request)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void HTTPSClientSession::connect(const SocketAddress& address)
 | 
			
		||||
{
 | 
			
		||||
        if (getProxyHost().empty())
 | 
			
		||||
        {
 | 
			
		||||
                SecureStreamSocket sss(socket());
 | 
			
		||||
                if (_pContext->sessionCacheEnabled())
 | 
			
		||||
                {
 | 
			
		||||
                        sss.useSession(_pSession);
 | 
			
		||||
                }
 | 
			
		||||
                HTTPSession::connect(address);
 | 
			
		||||
                if (_pContext->sessionCacheEnabled())
 | 
			
		||||
                {
 | 
			
		||||
                        _pSession = sss.currentSession();
 | 
			
		||||
                }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
                HTTPClientSession proxySession(address);
 | 
			
		||||
                proxySession.setHost(getProxyHost());
 | 
			
		||||
                proxySession.setPort(getProxyPort());
 | 
			
		||||
                proxySession.setTimeout(getTimeout());
 | 
			
		||||
                SocketAddress targetAddress(getHost(), getPort());
 | 
			
		||||
                HTTPRequest proxyRequest(HTTPRequest::HTTP_CONNECT, targetAddress.toString(), HTTPMessage::HTTP_1_1);
 | 
			
		||||
                HTTPResponse proxyResponse;
 | 
			
		||||
                proxyRequest.set("Proxy-Connection", "keep-alive");
 | 
			
		||||
                proxyRequest.set("Host", getHost());
 | 
			
		||||
                proxyAuthenticateImpl(proxyRequest);
 | 
			
		||||
                proxySession.setKeepAlive(true);
 | 
			
		||||
                proxySession.sendRequest(proxyRequest);
 | 
			
		||||
                proxySession.receiveResponse(proxyResponse);
 | 
			
		||||
		if (proxyResponse.getStatus() != HTTPResponse::HTTP_OK)
 | 
			
		||||
                        throw HTTPException("Cannot establish proxy connection", proxyResponse.getReason());
 | 
			
		||||
                
 | 
			
		||||
                StreamSocket proxySocket(proxySession.detachSocket());
 | 
			
		||||
                SecureStreamSocket secureSocket = SecureStreamSocket::attach(proxySocket, getHost(), _pContext, _pSession);
 | 
			
		||||
                attachSocket(secureSocket);
 | 
			
		||||
                if (_pContext->sessionCacheEnabled())
 | 
			
		||||
                {
 | 
			
		||||
                        _pSession = secureSocket.currentSession();
 | 
			
		||||
                }
 | 
			
		||||
        }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Session::Ptr HTTPSClientSession::sslSession()
 | 
			
		||||
{
 | 
			
		||||
        return _pSession;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
} } // namespace Poco::Net
 | 
			
		||||
		Reference in New Issue
	
	Block a user