1 yi.zhou 1.1 //%2006////////////////////////////////////////////////////////////////////////
2 //
3 // 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 // IBM Corp.; EMC Corporation, The Open Group.
7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
9 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
11 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
13 //
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 //
21 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 yi.zhou 1.1 // 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 //%/////////////////////////////////////////////////////////////////////////////
33
34 #ifndef Pegasus_AuditLogger_h
35 #define Pegasus_AuditLogger_h
36
37 #include <Pegasus/Common/Config.h>
38 #include <Pegasus/Common/System.h>
39 #include <Pegasus/Common/CIMInstance.h>
40 #include <Pegasus/Common/CIMName.h>
41
42 PEGASUS_NAMESPACE_BEGIN
43 yi.zhou 1.1
44
45 #ifndef PEGASUS_DISABLE_AUDIT_LOGGER
46
|
47 kumpf 1.8 /**
|
48 yi.zhou 1.1 This class provides the interfaces to construct a human readable audit
|
49 kumpf 1.8 text message and write the message to log files.
|
50 yi.zhou 1.1 */
51 class PEGASUS_COMMON_LINKAGE AuditLogger
52 {
53 public:
54
55 enum AuditType
56 {
|
57 yi.zhou 1.3 TYPE_AUTHENTICATION,
58 TYPE_AUTHORIZATION,
59 TYPE_CONFIGURATION,
|
60 kumpf 1.8 TYPE_CIMOPERATION
|
61 yi.zhou 1.1 };
62
63 enum AuditSubType
64 {
|
65 yi.zhou 1.3 SUBTYPE_LOCAL_AUTHENTICATION,
66 SUBTYPE_BASIC_AUTHENTICATION,
67 SUBTYPE_CERTIFICATE_BASED_AUTHENTICATION,
68 SUBTYPE_USER_GROUP_AUTHORIZATION,
69 SUBTYPE_NAMESPACE_AUTHORIZATION,
70 SUBTYPE_PRIVILEGED_USER_CHECK,
71 SUBTYPE_TRUSTSTORE_CHANGE,
72 SUBTYPE_CURRENT_CONFIGURATION,
73 SUBTYPE_CURRENT_PROVIDER_REGISTRATION,
74 SUBTYPE_CURRENT_ENVIRONMENT_VARIABLES,
75 SUBTYPE_CONFIGURATION_CHANGE,
76 SUBTYPE_PROVIDER_REGISTRATION_CHANGE,
|
77 yi.zhou 1.6 SUBTYPE_PROVIDER_MODULE_STATUS_CHANGE,
|
78 yi.zhou 1.3 SUBTYPE_SCHEMA_OPERATION,
79 SUBTYPE_INSTANCE_OPERATION,
80 SUBTYPE_INDICATION_OPERATION
|
81 yi.zhou 1.1 };
82
83 enum AuditEvent
84 {
|
85 yi.zhou 1.3 EVENT_START_UP,
86 EVENT_AUTH_SUCCESS,
87 EVENT_AUTH_FAILURE,
88 EVENT_CREATE,
89 EVENT_UPDATE,
|
90 kumpf 1.4 EVENT_DELETE,
91 EVENT_INVOKE
|
92 yi.zhou 1.1 };
93
94 /** Constructs and logs audit message of the current configurations
|
95 kumpf 1.8 @param propertyNames - All the current property names while the CIM
|
96 yi.zhou 1.1 Server is running
97 @param propertyValues - All the current property values while the CIM
98 Server is running
99 */
100 static void logCurrentConfig(
101 const Array<String>& propertyNames,
102 const Array<String>& propertyValues);
103
104 /** Constructs and logs audit message of the currently registered
105 providers while the CIM Server is running
106 @param instances - all currently registered provider module
107 instances while the CIM Server is running
108 */
109 static void logCurrentRegProvider(
110 const Array < CIMInstance > & instances);
111
112 /** Constructs and logs audit message of the current environment
113 variables while the CIM Server is running
114 */
115 static void logCurrentEnvironmentVar();
116
117 yi.zhou 1.1 /** Constructs and logs audit message of setting the specified
118 configuration property to the specified value
119 or unset the specified configuration property to the default value
120 @param userName - The user name for this operation
121 @param propertyName - The specified configuration property name
122 @param prePropertyValue - The previous value of the changed config
123 property
124 @param newPropertyValue - The new value of the changed config
125 property or default value if it is unset
126 @param isPlanned - True, sets planned value of the
127 specified configuration property;
128 Otherwise, sets current value of the
129 specified configuration property
130 */
131 static void logSetConfigProperty(
132 const String & userName,
133 const String & propertyName,
134 const String & prePropertyValue,
135 const String & newPropertyValue,
136 Boolean isPlanned);
137
|
138 kumpf 1.4 /**
139 Constructs and logs audit message of a CIM class update operation
140 @param cimMethodName - The name of the CIM operation performed
141 @param eventType - The AuditEvent associated with the CIM operation
142 @param userName - User name for this operation
|
143 kumpf 1.8 @param ipAddr - Client IP address for this operation
|
144 kumpf 1.4 @param nameSpace - The namespace for the operation
145 @param className - The name of the class
146 @param statusCode - The CIM status code for the operation
147 */
148 static void logUpdateClassOperation(
149 const char* cimMethodName,
150 AuditEvent eventType,
151 const String& userName,
152 const String& ipAddr,
153 const CIMNamespaceName& nameSpace,
154 const CIMName& className,
155 CIMStatusCode statusCode);
156
157 /**
158 Constructs and logs audit message of a CIM qualifier update operation
159 @param cimMethodName - The name of the CIM operation performed
160 @param eventType - The AuditEvent associated with the CIM operation
161 @param userName - User name for this operation
|
162 kumpf 1.8 @param ipAddr - Client IP address for this operation
|
163 kumpf 1.4 @param nameSpace - The namespace for the operation
|
164 kumpf 1.8 @param name - The name of the qualifier
|
165 kumpf 1.4 @param statusCode - The CIM status code for the operation
166 */
167 static void logUpdateQualifierOperation(
168 const char* cimMethodName,
169 AuditEvent eventType,
170 const String& userName,
171 const String& ipAddr,
172 const CIMNamespaceName& nameSpace,
173 const CIMName& name,
174 CIMStatusCode statusCode);
175
176 /**
177 Constructs and logs audit message of a CIM instance update operation
178 @param cimMethodName - The name of the CIM operation performed
179 @param eventType - The AuditEvent associated with the CIM operation
180 @param userName - The user name for this operation
|
181 kumpf 1.8 @param ipAddr - Client IP address for this operation
|
182 kumpf 1.4 @param nameSpace - The namespace for the operation
|
183 kumpf 1.5 @param instanceName - The name of the affected instance
|
184 kumpf 1.4 @param moduleName - The provider module name that serves the request
185 @param providerName - The provider name that serves the request
186 @param statusCode - The CIM status code for the operation
187 */
188 static void logUpdateInstanceOperation(
189 const char* cimMethodName,
190 AuditEvent eventType,
191 const String& userName,
192 const String& ipAddr,
193 const CIMNamespaceName& nameSpace,
|
194 kumpf 1.5 const CIMObjectPath& instanceName,
|
195 kumpf 1.4 const String& moduleName,
196 const String& providerName,
197 CIMStatusCode statusCode);
198
199 /**
200 Constructs and logs audit message of a CIM InvokeMethod operation
201 @param userName - The user name for this operation
|
202 kumpf 1.8 @param ipAddr - Client IP address for this operation
|
203 kumpf 1.4 @param nameSpace - The namespace for the operation
|
204 kumpf 1.5 @param objectName - The name of the object on which the method is
205 invoked
|
206 kumpf 1.8 @param methodName - The name of the method to be executed
|
207 kumpf 1.4 @param moduleName - The provider module name that serves the request
208 @param providerName - The provider name that serves the request
209 @param statusCode - The CIM status code for the operation
210 */
211 static void logInvokeMethodOperation(
212 const String& userName,
213 const String& ipAddr,
214 const CIMNamespaceName& nameSpace,
|
215 kumpf 1.5 const CIMObjectPath& objectName,
|
216 kumpf 1.4 const CIMName& methodName,
217 const String& moduleName,
218 const String& providerName,
219 CIMStatusCode statusCode);
220
|
221 kumpf 1.8 /** Constructs and logs audit message of a provider module status change
|
222 yi.zhou 1.6 @param moduleName - The name of the provider module
223 @param currentModuleStatus - The current status of the provider module
224 @param newModuleStatus - The new status of the provider module
225 */
226 static void logUpdateProvModuleStatus(
227 const String & moduleName,
228 const Array<Uint16> currentModuleStatus,
229 const Array<Uint16> newModuleStatus);
230
|
231 sushma.fernandes 1.7 /** Constructs and logs audit message of local authentication
232 @param userName - The user name for this operation
233 @param successful - True on successful basic authentication,
234 false otherwise
235 */
236 static void logLocalAuthentication(
237 const String& userName,
238 Boolean successful);
239
240 /** Constructs and logs audit message of basic authentication
241 @param userName - The user name for this operation
242 @param ipAddr - Client IP address for this operation
243 @param successful - True on successful basic authentication,
244 false otherwise
245 */
246 static void logBasicAuthentication(
247 const String& userName,
248 const String& ipAddr,
249 Boolean successful);
|
250 yi.zhou 1.6
|
251 yi.zhou 1.1 typedef void (*PEGASUS_AUDITLOGINITIALIZE_CALLBACK_T)();
252
|
253 kumpf 1.8 typedef void (*PEGASUS_AUDITLOG_CALLBACK_T) (AuditType,
254 AuditSubType, AuditEvent, Uint32, MessageLoaderParms &);
|
255 yi.zhou 1.1
256 /**
257 Registers an audit log initialize callback
|
258 kumpf 1.8 If a non-null initialize callback function is registered,
|
259 yi.zhou 1.1 it will be called when the audit log is enabled.
|
260 kumpf 1.8 @param auditLogInitializeCallback - The audit log initialize
|
261 yi.zhou 1.1 callback function
262 */
263 static void setInitializeCallback(
264 PEGASUS_AUDITLOGINITIALIZE_CALLBACK_T auditLogInitializeCallback);
265
|
266 kumpf 1.8 /** If the enabled is true, the audit log initialize callback function
|
267 yi.zhou 1.1 is called to communicate that the audit log is enabled.
|
268 kumpf 1.8 @param enabled - True on config property "enableAuditLog" is
|
269 yi.zhou 1.1 enabled, false otherwise
|
270 kumpf 1.8 */
|
271 yi.zhou 1.1 static void setEnabled(Boolean enabled);
272
273 static Boolean isEnabled();
274
275 /**
276 Registers writing audit messages to a file callback
277 @param writeAuditMessageCallback - The callback function to write
278 audit message
279 */
280 static void writeAuditLogToFileCallback(
281 PEGASUS_AUDITLOG_CALLBACK_T writeAuditMessageCallback);
282
283 private:
|
284 kumpf 1.8
|
285 yi.zhou 1.1 static Boolean _auditLogFlag;
286
|
287 kumpf 1.8 /**
288 Callback function to be called when the audit log is enabled
|
289 yi.zhou 1.1 */
290 static PEGASUS_AUDITLOGINITIALIZE_CALLBACK_T _auditLogInitializeCallback;
291
292 /**
293 The function to write audit messages
294 */
295 static PEGASUS_AUDITLOG_CALLBACK_T _writeAuditMessageToFile;
296
297 /** Default function to write a auditMessage to a file
298 @param AuditType - Type of audit record (Authentication etc)
299 @param AuditSubType - Sub type of audit record(Local_Authentication etc)
300 @param AuditEvent - Event of audit record (Start_Up etc)
|
301 kumpf 1.8 @param logLevel - Pegasus Severity (WARNING etc)
302 All the audit messages are passed with pegasus severity
|
303 yi.zhou 1.1 "INFORMATION", except authentication attempts failed messages or
|
304 kumpf 1.8 authorization failed messages are passed with pegasus severity
|
305 yi.zhou 1.1 "WARNING"
306 @param msgParms - The message loader parameters
307 */
308 static void _writeAuditMessage(
309 AuditType auditType,
|
310 kumpf 1.8 AuditSubType auditSubType,
|
311 yi.zhou 1.1 AuditEvent auditEvent,
312 Uint32 logLevel,
313 MessageLoaderParms & msgParms);
314
315 /**
316 gets module status value
317 @param moduleStatus - The module status
318 */
319 static String _getModuleStatusValue(const Array<Uint16> moduleStatus);
320
321 };
322
323 inline Boolean AuditLogger::isEnabled()
324 {
|
325 kumpf 1.8 return _auditLogFlag;
|
326 yi.zhou 1.1 }
327
328 # define PEG_AUDIT_LOG(T) \
329 do \
330 { \
331 if (AuditLogger::isEnabled()) \
332 { \
333 AuditLogger::T; \
334 } \
335 } \
336 while (0)
337
338 #else
339
340 # define PEG_AUDIT_LOG(T)
341
342 #endif
343
344 PEGASUS_NAMESPACE_END
345
346 #endif /* Pegasus_AuditLogger_h */
|