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

Diff for /pegasus/src/Pegasus/Common/AuditLogger.cpp between version 1.1 and 1.1.2.1

version 1.1, 2006/10/17 21:24:41 version 1.1.2.1, 2006/11/16 13:30:37
Line 37 
Line 37 
 #include <Pegasus/Common/Formatter.h> #include <Pegasus/Common/Formatter.h>
 #include <Pegasus/Common/CIMPropertyList.h> #include <Pegasus/Common/CIMPropertyList.h>
 #include <Pegasus/Common/InternalException.h> #include <Pegasus/Common/InternalException.h>
   #include <Pegasus/Common/AuditLogger.h>
   
   #ifdef PEGASUS_OS_DARWIN
   # include <crt_externs.h>
   #endif
   
   #ifndef PEGASUS_OS_TYPE_WINDOWS
 #include <unistd.h> #include <unistd.h>
   #endif
   
   #ifdef PEGASUS_OS_VMS
   # include <unixlib.h>
   #endif
   
 #include <stdlib.h> #include <stdlib.h>
  
 #ifndef PEGASUS_DISABLE_AUDIT_LOGGER #ifndef PEGASUS_DISABLE_AUDIT_LOGGER
  
 #include <Pegasus/Common/AuditLogger.h>  
   
 PEGASUS_USING_STD; PEGASUS_USING_STD;
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
 static const String providerModuleStatus [] = {"Unknown", "Other", "OK", "Degraded",  static const String providerModuleStatus [] = {
       "Unknown", "Other", "OK", "Degraded",
     "Stressed", "Predictive Failure", "Error", "Non-Recoverable Error",     "Stressed", "Predictive Failure", "Error", "Non-Recoverable Error",
     "Starting", "Stopping", "Stopped", "In Service", "No Contact",     "Starting", "Stopping", "Stopped", "In Service", "No Contact",
     "Lost Communication"};     "Lost Communication"};
  
 Boolean AuditLogger::_auditLogFlag = false; Boolean AuditLogger::_auditLogFlag = false;
  
 AuditLogger::PEGASUS_AUDITLOGINITIALIZE_CALLBACK_T AuditLogger::_auditLogInitializeCallback;  AuditLogger::PEGASUS_AUDITLOGINITIALIZE_CALLBACK_T
       AuditLogger::_auditLogInitializeCallback = 0;
  
 AuditLogger::PEGASUS_AUDITLOG_CALLBACK_T AuditLogger::_writeAuditMessageToFile = AuditLogger::PEGASUS_AUDITLOG_CALLBACK_T AuditLogger::_writeAuditMessageToFile =
     AuditLogger::_writeAuditMessage;     AuditLogger::_writeAuditMessage;
Line 64 
Line 77 
     const Array<String> & propertyNames,     const Array<String> & propertyNames,
     const Array<String> & propertyValues)     const Array<String> & propertyValues)
 { {
     String properties;  
   
     for (Uint32 i = 0; i < propertyNames.size(); i++)     for (Uint32 i = 0; i < propertyNames.size(); i++)
     {     {
         properties.append(propertyNames[i]);          String propertyStr = propertyNames[i] + "=" + propertyValues[i];
         properties.append("=");  
         properties.append(propertyValues[i]);  
         properties.append("\n");  
     }  
  
     MessageLoaderParms msgParms("Common.AuditLogger.CURRENT_CONFIG",     MessageLoaderParms msgParms("Common.AuditLogger.CURRENT_CONFIG",
        "The current configuration properties are:\n$0", properties);              "cimserver configuration $0", propertyStr);
   
     _writeAuditMessageToFile(CONFIGURATION, CURRENT_CONFIGURATION,  
         START_UP, Logger::INFORMATION, msgParms);  
  
           _writeAuditMessageToFile(TYPE_CONFIGURATION,
               SUBTYPE_CURRENT_CONFIGURATION,
               EVENT_START_UP, Logger::INFORMATION, msgParms);
       }
 } }
  
 void AuditLogger::logCurrentRegProvider( void AuditLogger::logCurrentRegProvider(
     const Array < CIMInstance > & instances)     const Array < CIMInstance > & instances)
 { {
     String moduleName, registeredModules;      String moduleName;
     Array<Uint16> moduleStatus;     Array<Uint16> moduleStatus;
     String statusValue;     String statusValue;
     Uint32 pos;     Uint32 pos;
Line 96 
Line 104 
         instances[i].getProperty(instances[i].findProperty(         instances[i].getProperty(instances[i].findProperty(
             _PROPERTY_PROVIDERMODULE_NAME)).getValue().get(moduleName);             _PROPERTY_PROVIDERMODULE_NAME)).getValue().get(moduleName);
  
         registeredModules.append(moduleName);  
         registeredModules.append("=");  
   
         pos = instances[i].findProperty(_PROPERTY_OPERATIONALSTATUS);         pos = instances[i].findProperty(_PROPERTY_OPERATIONALSTATUS);
  
         if (pos == PEG_NOT_FOUND)         if (pos == PEG_NOT_FOUND)
Line 121 
Line 126 
  
         statusValue = _getModuleStatusValue(moduleStatus);         statusValue = _getModuleStatusValue(moduleStatus);
  
         registeredModules.append(statusValue);  
         registeredModules.append("\n");  
     }  
   
     MessageLoaderParms msgParms(     MessageLoaderParms msgParms(
         "Common.AuditLogger.CURRENT_PROVIDER_REGISTRATION",         "Common.AuditLogger.CURRENT_PROVIDER_REGISTRATION",
         "The current registered provider modules are:\n$0", registeredModules);              "Provider module \"$0\" has status \"$1\".",
               moduleName, statusValue);
  
     _writeAuditMessageToFile(CONFIGURATION, CURRENT_PROVIDER_REGISTRATION,          _writeAuditMessageToFile(TYPE_CONFIGURATION,
         START_UP, Logger::INFORMATION, msgParms);              SUBTYPE_CURRENT_PROVIDER_REGISTRATION,
               EVENT_START_UP, Logger::INFORMATION, msgParms);
       }
 } }
  
 void AuditLogger::logCurrentEnvironmentVar() void AuditLogger::logCurrentEnvironmentVar()
 { {
   #ifdef PEGASUS_OS_DARWIN
     String envList;      char** envp = *_NSGetEnviron();
   #else
     char ** envp = environ;     char ** envp = environ;
   #endif
  
     Uint32 i = 0;     Uint32 i = 0;
  
     while (envp[i])     while (envp[i])
     {     {
         envList.append(envp[i]);          MessageLoaderParms msgParms("Common.AuditLogger.CURRENT_ENV",
         envList.append("\n");             "cimserver environment variable: $0", envp[i]);
   
           _writeAuditMessageToFile(TYPE_CONFIGURATION,
               SUBTYPE_CURRENT_ENVIRONMENT_VARIABLES,
               EVENT_START_UP, Logger::INFORMATION, msgParms);
  
         i++;         i++;
     }     }
   
     MessageLoaderParms msgParms("Common.AuditLogger.CURRENT_ENV",  
        "The current environment variables are:\n$0", envList);  
   
     _writeAuditMessageToFile(CONFIGURATION, CURRENT_ENVIRONMENT_VARIABLES,  
         START_UP, Logger::INFORMATION, msgParms);  
 } }
  
 void AuditLogger::logSetConfigProperty( void AuditLogger::logSetConfigProperty(
Line 167 
Line 171 
     {     {
         MessageLoaderParms msgParms(         MessageLoaderParms msgParms(
             "Common.AuditLogger.SET_PLANNED_CONFIG_PROPERTY",             "Common.AuditLogger.SET_PLANNED_CONFIG_PROPERTY",
             "The planned value of property \"$0\" is modified from value \"$1\""                 " to value \"$2\" by user \"$3\".\n",              "The planned value of property \"$0\" is modified from "
                   "value \"$1\" to value \"$2\" by user \"$3\".",
            propertyName, prePropertyValue, newPropertyValue, userName);            propertyName, prePropertyValue, newPropertyValue, userName);
  
         _writeAuditMessageToFile(CONFIGURATION, CONFIGURATION_CHANGE,          _writeAuditMessageToFile(TYPE_CONFIGURATION,
             UPDATE, Logger::INFORMATION, msgParms);              SUBTYPE_CONFIGURATION_CHANGE,
               EVENT_UPDATE, Logger::INFORMATION, msgParms);
     }     }
     else     else
     {     {
         MessageLoaderParms msgParms(         MessageLoaderParms msgParms(
             "Common.AuditLogger.SET_CURRENT_CONFIG_PROPERTY",             "Common.AuditLogger.SET_CURRENT_CONFIG_PROPERTY",
             "The current value of property \"$0\" is modified from value "              "The current value of property \"$0\" is modified from "
             "\"$1\" to value \"$2\" by user \"$3\".\n",                  "value \"$1\" to value \"$2\" by user \"$3\".",
            propertyName, prePropertyValue, newPropertyValue, userName);            propertyName, prePropertyValue, newPropertyValue, userName);
  
         _writeAuditMessageToFile(CONFIGURATION, CONFIGURATION_CHANGE,          _writeAuditMessageToFile(TYPE_CONFIGURATION,
             UPDATE, Logger::INFORMATION, msgParms);              SUBTYPE_CONFIGURATION_CHANGE,
               EVENT_UPDATE, Logger::INFORMATION, msgParms);
       }
   }
   
   void AuditLogger::logUpdateClassOperation(
       const char* cimMethodName,
       AuditEvent eventType,
       const String& userName,
       const String& ipAddr,
       const CIMNamespaceName& nameSpace,
       const CIMName& className,
       CIMStatusCode statusCode)
   {
       MessageLoaderParms msgParms(
           "Common.AuditLogger.OPERATION_UPDATE_CLASS",
           "A CIM $0 operation on class \"$1\" in namespace \"$2\" by user "
               "\"$3\" connected from system \"$4\" resulted in status \"$5\".",
           cimMethodName,
           className.getString(),
           nameSpace.getString(),
           userName,
           ipAddr,
           cimStatusCodeToString(statusCode));
   
       _writeAuditMessageToFile(TYPE_CIMOPERATION, SUBTYPE_SCHEMA_OPERATION,
           eventType, Logger::INFORMATION, msgParms);
   }
   
   void AuditLogger::logUpdateQualifierOperation(
       const char* cimMethodName,
       AuditEvent eventType,
       const String& userName,
       const String& ipAddr,
       const CIMNamespaceName& nameSpace,
       const CIMName& className,
       CIMStatusCode statusCode)
   {
       MessageLoaderParms msgParms(
           "Common.AuditLogger.OPERATION_UPDATE_QUALIFIER",
           "A CIM $0 operation on qualifier \"$1\" in namespace \"$2\" by user "
               "\"$3\" connected from system \"$4\" resulted in status \"$5\".",
           cimMethodName,
           className.getString(),
           nameSpace.getString(),
           userName,
           ipAddr,
           cimStatusCodeToString(statusCode));
   
       _writeAuditMessageToFile(TYPE_CIMOPERATION, SUBTYPE_SCHEMA_OPERATION,
           eventType, Logger::INFORMATION, msgParms);
   }
   
   void AuditLogger::logUpdateInstanceOperation(
       const char* cimMethodName,
       AuditEvent eventType,
       const String& userName,
       const String& ipAddr,
       const CIMNamespaceName& nameSpace,
       const CIMObjectPath& instanceName,
       const String& moduleName,
       const String& providerName,
       CIMStatusCode statusCode)
   {
       if (providerName != String::EMPTY)
       {
           MessageLoaderParms msgParms(
               "Common.AuditLogger.OPERATION_UPDATE_INSTANCE_WITH_PROVIDER",
               "A CIM $0 operation on instance \"$1\" in namespace \"$2\" by "
                   "user \"$3\" connected from system \"$4\" resulted in "
                   "status \"$5\".  "
                   "The provider for this operation is \"$6\" in module \"$7\".",
               cimMethodName,
               CIMObjectPath("", CIMNamespaceName(), instanceName.getClassName(),
                   instanceName.getKeyBindings()).toString(),
               nameSpace.getString(),
               userName,
               ipAddr,
               cimStatusCodeToString(statusCode),
               providerName,
               moduleName);
   
           _writeAuditMessageToFile(TYPE_CIMOPERATION, SUBTYPE_INSTANCE_OPERATION,
               eventType, Logger::INFORMATION, msgParms);
       }
       else
       {
           MessageLoaderParms msgParms(
               "Common.AuditLogger.OPERATION_UPDATE_INSTANCE",
               "A CIM $0 operation on instance \"$1\" in namespace \"$2\" by "
                   "user \"$3\" connected from system \"$4\" resulted in "
                   "status \"$5\".  ",
               cimMethodName,
               CIMObjectPath("", CIMNamespaceName(), instanceName.getClassName(),
                   instanceName.getKeyBindings()).toString(),
               nameSpace.getString(),
               userName,
               ipAddr,
               cimStatusCodeToString(statusCode));
   
           _writeAuditMessageToFile(TYPE_CIMOPERATION, SUBTYPE_INSTANCE_OPERATION,
               eventType, Logger::INFORMATION, msgParms);
       }
   }
   
   void AuditLogger::logInvokeMethodOperation(
       const String& userName,
       const String& ipAddr,
       const CIMNamespaceName& nameSpace,
       const CIMObjectPath& objectName,
       const CIMName& methodName,
       const String& moduleName,
       const String& providerName,
       CIMStatusCode statusCode)
   {
       if (providerName != String::EMPTY)
       {
           MessageLoaderParms msgParms(
               "Common.AuditLogger.OPERATION_INVOKE_METHOD_WITH_PROVIDER",
               "A CIM InvokeMethod operation on method \"$0\" of object \"$1\" "
                   "in namespace \"$2\" by user \"$3\" connected from system "
                   "\"$4\" resulted in status \"$5\".  The provider for this "
                   "operation is \"$6\" in module \"$7\".",
               methodName.getString(),
               CIMObjectPath("", CIMNamespaceName(), objectName.getClassName(),
                   objectName.getKeyBindings()).toString(),
               nameSpace.getString(),
               userName,
               ipAddr,
               cimStatusCodeToString(statusCode),
               providerName,
               moduleName);
   
           _writeAuditMessageToFile(TYPE_CIMOPERATION, SUBTYPE_INSTANCE_OPERATION,
               EVENT_INVOKE, Logger::INFORMATION, msgParms);
       }
       else
       {
           MessageLoaderParms msgParms(
               "Common.AuditLogger.OPERATION_INVOKE_METHOD",
               "A CIM InvokeMethod operation on method \"$0\" of object \"$1\" "
                   "in namespace \"$2\" by user \"$3\" connected from system "
                   "\"$4\" resulted in status \"$5\".",
               methodName.getString(),
               CIMObjectPath("", CIMNamespaceName(), objectName.getClassName(),
                   objectName.getKeyBindings()).toString(),
               nameSpace.getString(),
               userName,
               ipAddr,
               cimStatusCodeToString(statusCode));
   
           _writeAuditMessageToFile(TYPE_CIMOPERATION, SUBTYPE_INSTANCE_OPERATION,
               EVENT_INVOKE, Logger::INFORMATION, msgParms);
       }
   }
   
   void AuditLogger::logUpdateProvModuleStatus(
       const String & moduleName,
       const Array<Uint16> currentModuleStatus,
       const Array<Uint16> newModuleStatus)
   {
       String currentModuleStatusValue =
           _getModuleStatusValue(currentModuleStatus);
   
       String newModuleStatusValue = _getModuleStatusValue(newModuleStatus);
   
       MessageLoaderParms msgParms(
           "Common.AuditLogger.UPDATE_PROVIDER_MODULE_STATUS",
           "The operational status of module \"$0\" has changed from \"$1\""
           " to \"$2\".",
           moduleName, currentModuleStatusValue, newModuleStatusValue);
   
       _writeAuditMessageToFile(TYPE_CONFIGURATION,
           SUBTYPE_PROVIDER_MODULE_STATUS_CHANGE,
           EVENT_UPDATE, Logger::INFORMATION, msgParms);
   }
   
   void AuditLogger::logLocalAuthentication(
           const String& userName,
           Boolean successful)
   {
       CIMValue result(successful);
   
       MessageLoaderParms msgParms(
          "Common.AuditLogger.LOCAL_AUTHENTICATION",
          "Local authentication attempt: "
          "successful = $0, user = $1. ",
          result.toString(),
          userName);
   
       _writeAuditMessageToFile(
           TYPE_AUTHENTICATION,
           SUBTYPE_LOCAL_AUTHENTICATION,
           successful ? EVENT_AUTH_SUCCESS : EVENT_AUTH_FAILURE,
           successful ? Logger::INFORMATION : Logger::WARNING,
           msgParms);
     }     }
   
   void AuditLogger::logBasicAuthentication(
           const String& userName,
           const String& ipAddr,
           Boolean successful)
   {
       CIMValue result(successful);
   
       MessageLoaderParms msgParms(
          "Common.AuditLogger.BASIC_AUTHENTICATION",
          "Basic authentication attempt: "
          "successful = $0, user = $1, IP address = $2.",
          result.toString(),
          userName,
          ipAddr);
   
       _writeAuditMessageToFile( TYPE_AUTHENTICATION,
           SUBTYPE_BASIC_AUTHENTICATION,
           successful ? EVENT_AUTH_SUCCESS : EVENT_AUTH_FAILURE,
           successful ? Logger::INFORMATION: Logger::WARNING,
           msgParms);
 } }
  
 void AuditLogger::setInitializeCallback( void AuditLogger::setInitializeCallback(
Line 194 
Line 416 
  
 void AuditLogger::setEnabled(Boolean enabled) void AuditLogger::setEnabled(Boolean enabled)
 { {
       // Only write the enable/disable messages if we are set up to handle them
       if (_auditLogInitializeCallback != 0)
       {
     if (enabled)     if (enabled)
     {     {
         if (!_auditLogFlag)         if (!_auditLogFlag)
         {         {
             _auditLogInitializeCallback();             _auditLogInitializeCallback();
   
                   MessageLoaderParms msgParms(
                       "Common.AuditLogger.ENABLE_AUDIT_LOG",
                       "Audit logging is enabled.");
   
                   _writeAuditMessageToFile(TYPE_CONFIGURATION,
                       SUBTYPE_CONFIGURATION_CHANGE,
                       EVENT_UPDATE, Logger::INFORMATION, msgParms);
         }         }
     }     }
     else     else
Line 207 
Line 440 
         {         {
             MessageLoaderParms msgParms(             MessageLoaderParms msgParms(
                 "Common.AuditLogger.DISABLE_AUDIT_LOG",                 "Common.AuditLogger.DISABLE_AUDIT_LOG",
                 "Audit logging is disabled.\n");                      "Audit logging is disabled.");
  
             _writeAuditMessageToFile(CONFIGURATION, CONFIGURATION_CHANGE,                  _writeAuditMessageToFile(TYPE_CONFIGURATION,
                 UPDATE, Logger::INFORMATION, msgParms);                      SUBTYPE_CONFIGURATION_CHANGE,
                       EVENT_UPDATE, Logger::INFORMATION, msgParms);
               }
         }         }
     }     }
  
Line 232 
Line 467 
 { {
     String localizedMsg = MessageLoader::getMessage(msgParms);     String localizedMsg = MessageLoader::getMessage(msgParms);
  
     String identifier = "CIM Server Audit";      String identifier = "cimserver audit";
  
     Logger::put(Logger::AUDIT_LOG, identifier, logLevel, localizedMsg);     Logger::put(Logger::AUDIT_LOG, identifier, logLevel, localizedMsg);
 } }
Line 254 
Line 489 
         }         }
     }     }
  
     return (moduleStatusValue);      return moduleStatusValue;
 } }
  
 PEGASUS_NAMESPACE_END PEGASUS_NAMESPACE_END


Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2