(file) Return to CIMDefaultClientConnectionManager.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / ManagedClient

  1 karl  1.6 //%2006////////////////////////////////////////////////////////////////////////
  2 a.arora 1.2 //
  3 karl    1.4 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
  4             // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
  5             // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
  6 a.arora 1.2 // IBM Corp.; EMC Corporation, The Open Group.
  7 karl    1.4 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
  8             // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
  9 karl    1.5 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 10             // EMC Corporation; VERITAS Software Corporation; The Open Group.
 11 karl    1.6 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
 12             // EMC Corporation; Symantec Corporation; The Open Group.
 13 a.arora 1.2 //
 14             // Permission is hereby granted, free of charge, to any person obtaining a copy
 15             // of this software and associated documentation files (the "Software"), to
 16             // deal in the Software without restriction, including without limitation the
 17             // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 18             // sell copies of the Software, and to permit persons to whom the Software is
 19             // furnished to do so, subject to the following conditions:
 20 karl    1.4 // 
 21 a.arora 1.2 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
 22             // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
 23             // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
 24             // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 25             // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 26             // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 27             // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 28             // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 29             //
 30             //==============================================================================
 31             //
 32             // Author: Marek Szermutzky (MSzermutzky@de.ibm.com) PEP#139 Stage2
 33             //
 34 r.kieninger 1.3 // Modified by: Robert Kieninger, IBM (kieningr@de.ibm.com) Bug#667
 35                 //
 36 a.arora     1.2 //%/////////////////////////////////////////////////////////////////////////////
 37                 
 38                 #include "CIMDefaultClientConnectionManager.h"
 39                 
 40                 PEGASUS_NAMESPACE_BEGIN
 41                 
 42                 // class constructor
 43                 CIMDefaultClientConnectionManager::CIMDefaultClientConnectionManager()
 44                 {
 45                 	
 46                 }
 47                 	
 48                 // virtual class destructor has to be implemented by specific implementation
 49                 CIMDefaultClientConnectionManager::~CIMDefaultClientConnectionManager()
 50                 {
 51                 	CIMClientConnection		*remvPointer;
 52                 	for (Uint32 i=0;i<_cccm_container.size();i++)
 53                 	{																						
 54                 		remvPointer = (CIMClientConnection*) _cccm_container[i];
 55                 		delete remvPointer;
 56                 	}
 57 a.arora     1.2 	_cccm_container.clear();
 58                 }
 59                 
 60                 // this function returns the specified connection
 61                 CIMClientRep* CIMDefaultClientConnectionManager::getConnection(
 62                 								const String& host,
 63                 								const String& port,
 64                 								const CIMNamespaceName& nameSpace)
 65                 
 66                 {
 67                 	Uint32 requestedIP;
 68                 	Uint32 requestedPort;
 69                 
 70                 	// build a single host unique integer representation
 71 r.kieninger 1.3 	requestedIP = System::_acquireIP((const char*) host.getCString());
 72 a.arora     1.2 
 73                 	if (requestedIP == 0x7F000001)
 74                 	{
 75                 		// localhost or ip address of 127.0.0.1
 76                 		// still for compare we need the real ip address
 77 r.kieninger 1.3 		requestedIP = System::_acquireIP((const char *) System::getHostName().getCString());
 78 a.arora     1.2 	}
 79                 	if (requestedIP == 0xFFFFFFFF)
 80                 	{
 81                 		// bad formatted ip address or not resolveable
 82                 /*		typeMismatchMessage = MessageLoaderParms("Client.CIMClientRep.TYPEMISMATCH_OBJECTPATH_IP_UNRESOLVEABLE",
 83                 												 "Failed validation of CIM object path: failed to resolve IP address($0) from object path",
 84                 												 ObjHost);
 85                 		throw TypeMismatchException(typeMismatchMessage);
 86                 */		
 87                 	}
 88                 		
 89                 	requestedPort = strtoul((const char*) port.getCString(), NULL, 0);
 90                 
 91                 	CIMClientConnection		*ccc;
 92                 	CIMClientRep			*returnedConnectionHandle;
 93                 
 94                 	// rotate through list to find correct connection
 95                 	for (Uint32 i=0;i<_cccm_container.size();i++)
 96                 	{
 97                 		ccc = _cccm_container[i];
 98                 		if (ccc->equals(requestedIP, port))
 99 a.arora     1.2 		{
100                 			// okay, we found the correct connection
101                 			// in case it isn't already connected, lets connect and return the connection to caller
102                 			returnedConnectionHandle = ccc->getConnectionHandle();
103                 			if (returnedConnectionHandle != 0)
104                 			{
105                 				// connecting in case we aren't already connected
106                 				if (!returnedConnectionHandle->isConnected())
107                 				{
108                 					// is this a ssl connection ?
109                 					if (ccc->getSSLContext() == 0)
110                 					{
111                 						// no, we connect without ssl
112                 						returnedConnectionHandle->connect(host, requestedPort, ccc->getUser(), ccc->getPass());
113                 					} else
114                 					{
115                 						// yes, ssl is enabled
116                 						returnedConnectionHandle->connect(host, requestedPort, *ccc->getSSLContext(), ccc->getUser(), ccc->getPass());
117                 					}
118                 				}			
119                 			} else {
120 a.arora     1.2 				// in case no fitting connection could be found a return of NULL shall be returned
121                 				return 0;
122                 			}
123                 			// at this stage we found an applicable connection and also connected already
124                 			// thus we return the connection handle CIMClientRep
125                 			return returnedConnectionHandle;
126                 		}
127                 	}
128                 	return 0;
129                 }
130                 
131                 void CIMDefaultClientConnectionManager::addConnection(const String& host,
132                 													  const String& port,
133                 													  const String& userid,
134                 													  const String& passwd)
135                 {
136                 	CIMClientConnection		*newConnPointer;
137                 	newConnPointer = new CIMClientConnection(host, port, userid, passwd);
138                 	_cccm_container.append(newConnPointer);
139                 }
140                 
141 a.arora     1.2 void CIMDefaultClientConnectionManager::addConnection(const String& host,
142                 													  const String& port,
143                 													  const String& userid,
144                 													  const String& passwd,
145                 													  const SSLContext& sslcontext)
146                 {
147                 	CIMClientConnection		*newConnPointer;
148                 	newConnPointer = new CIMClientConnection(host, port, userid, passwd, sslcontext);
149                 	_cccm_container.append(newConnPointer);
150                 }
151                 
152                 
153                 PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2