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