// // Invoke Method, used to modify user's password // void UserAuthProvider::invokeMethod( const OperationContext & context, const CIMObjectPath & ref, const CIMName & methodName, const Array<CIMParamValue> & inParams, MethodResultResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::invokeMethod"); // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } #ifndef PEGASUS_NO_PASSWORDFILE String userName; String password; String newPassword; Array<CIMKeyBinding> kbArray; // Begin processing the request handler.processing(); // Check if the class name is PG_USER if (!ref.getClassName().equal (CLASS_NAME_PG_USER)) { handler.complete(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, ref.getClassName().getString()); } // Check if the method name is correct if (!methodName.equal (METHOD_NAME_MODIFY_PASSWORD)) { handler.complete(); PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION ( //CIM_ERR_FAILED, //"Unsupported method name, " + methodName.getString()); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNSUPPORTED_METHOD_NAME", "Unsupported method name, $0", methodName.getString()); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_FAILED,parms); } // Check if all the input parameters are passed. if ( inParams.size() < 2 ) { handler.complete(); PEG_METHOD_EXIT(); //l10n // throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, // "Input parameters are not valid."); MessageLoaderParms parms("ControlProviders.UserAuthProvider.INPUT_PARAMETERS_NOT_VALID", "Input parameters are not valid."); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER, parms); } try { kbArray = ref.getKeyBindings(); if ( !kbArray.size() ) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, // "Unable to find Key Property Username"); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNABLE_TO_FIND_KEY_PROPERTY_USERNAME", "Unable to find Key Property Username"); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER,parms); } // // Get the user name // if ( kbArray[0].getName() == PROPERTY_NAME_USERNAME ) { userName = kbArray[0].getValue(); } else { PEG_METHOD_EXIT(); MessageLoaderParms parms( "ControlProviders.UserAuthProvider.UNEXPECTED_KEY_PROPERTY", "Unexpected key property"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER, parms); } // // Get the old and the new password params // for ( Uint32 i=0; i < 2; i++) { // // check the param name // if ( inParams[i].getParameterName() == OLD_PASSWORD ) { inParams[i].getValue().get(password); } if ( inParams[i].getParameterName() == NEW_PASSWORD ) { inParams[i].getValue().get(newPassword); } } // Modify the user's password in User Manager _userManager->modifyUser( userName, password, newPassword); } catch ( const CIMException& ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch (const Exception& e) { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } // Return zero as there is no error Uint32 retCode = 0; handler.deliver(CIMValue(retCode)); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; #else PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, ref.getClassName().getString()); #endif }
// // Enumerates instances. // void UserAuthProvider::enumerateInstances( const OperationContext & context, const CIMObjectPath & ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::enumerateInstances"); Array<CIMInstance> instanceArray; Array<CIMInstance> namedInstances; // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } // // check if the class name requested is PG_Authorization // if (!ref.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, ref.getClassName().getString()); } // begin processing the request handler.processing(); try { // // call enumerateInstances of the repository // namedInstances = _repository->enumerateInstances( ref.getNameSpace(), ref.getClassName()); } catch(Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } for(Uint32 i = 0, n = namedInstances.size(); i < n; i++) { handler.deliver(namedInstances[i]); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
// // Enumerates all the user names. // void UserAuthProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::enumerateInstanceNames"); Array<CIMObjectPath> instanceRefs; Array<String> userNames; Array<CIMKeyBinding> keyBindings; CIMKeyBinding kb; String hostName; // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } const CIMName& className = classReference.getClassName(); const CIMNamespaceName& nameSpace = classReference.getNameSpace(); // begin processing the request handler.processing(); #ifndef PEGASUS_NO_PASSWORDFILE // // check if the class name requested is PG_User // if (className.equal (CLASS_NAME_PG_USER)) { try { hostName.assign(System::getHostName()); _userManager->getAllUserNames(userNames); Uint32 size = userNames.size(); for (Uint32 i = 0; i < size; i++) { keyBindings.append(CIMKeyBinding(PROPERTY_NAME_USERNAME, userNames[i], CIMKeyBinding::STRING)); // // Convert instance names to References // CIMObjectPath ref(hostName, nameSpace, className, keyBindings); handler.deliver(ref); keyBindings.clear(); } } catch( const CIMException& ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch(const Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } // // check if the class name requested is PG_Authorization // else if (className.equal (CLASS_NAME_PG_AUTHORIZATION)) #else if (className.equal (CLASS_NAME_PG_AUTHORIZATION)) #endif { try { // // call enumerateInstanceNames of the repository // instanceRefs = _repository->enumerateInstanceNames( nameSpace, className); handler.deliver(instanceRefs); } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } else { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION (CIM_ERR_NOT_SUPPORTED, className.getString()); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
// // Deletes the specified instance. // void UserAuthProvider::deleteInstance( const OperationContext & context, const CIMObjectPath& myInstance, ResponseHandler & handler) { CIMValue userName ; String userNameStr; String namespaceStr; Array<CIMKeyBinding> kbArray; PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::deleteInstance"); // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } // begin processing the request handler.processing(); #ifndef PEGASUS_NO_PASSWORDFILE // // check if the class name requested is PG_User // if (myInstance.getClassName().equal (CLASS_NAME_PG_USER)) { // // Get the user name from the instance // try { kbArray = myInstance.getKeyBindings(); if ( ! kbArray.size() ) { //l10n //throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, //"Unable to find Key Property Username"); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNABLE_TO_FIND_KEY_PROPERTY_USERNAME", "Unable to find Key Property Username"); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER,parms); } if ( kbArray[0].getName() == PROPERTY_NAME_USERNAME ) { userNameStr = kbArray[0].getValue(); } else { //l10n //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_INVALID_PARAMETER, //"Unexpected Key property"); MessageLoaderParms parms("ControlProviders.UserAuthProvider.UNEXPECTED_KEY_PROPERTY", "Unexpected Key property"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,parms); } // // Remove the user from User Manager // _userManager->removeUser(userNameStr); } catch ( const CIMException & ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch ( const Exception &e ) { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } // // check if the class name requested is PG_Authorization // else if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #else if (myInstance.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #endif { try { // // Get the user name and namespace from the instance // kbArray = myInstance.getKeyBindings(); for (Uint32 i = 0; i < kbArray.size(); i++) { if ( kbArray[i].getName() == PROPERTY_NAME_USERNAME ) { userNameStr = kbArray[i].getValue(); } else if ( kbArray[i].getName() == PROPERTY_NAME_NAMESPACE ) { namespaceStr = kbArray[i].getValue(); } } } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } if ( !userNameStr.size() ) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION ( //CIM_ERR_INVALID_PARAMETER, //"Username property can not be empty.") ; MessageLoaderParms parms("ControlProviders.UserAuthProvider.USERNAME_PROPERTY_CANNOT_BE_EMPTY", "Username property can not be empty."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,parms); } else if ( !namespaceStr.size() ) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION ( //CIM_ERR_INVALID_PARAMETER, //"Namespace property can not be empty.") ; MessageLoaderParms parms("ControlProviders.UserAuthProvider.NAMESPACE_PROPERTY_CANNOT_BE_EMPTY", "Namespace property can not be empty."); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,parms); } try { // // ATTN: Note that the following is a hack, because // deleteInstance() in repository does not like // the hostname and namespace included in the CIMObjectPath // passed to it as a parameter. // CIMObjectPath ref("", CIMNamespaceName (), myInstance.getClassName(), myInstance.getKeyBindings()); _repository->deleteInstance( myInstance.getNameSpace(), ref); // // remove authorization in the UserManager // _userManager->removeAuthorization( userNameStr, namespaceStr ); } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } else { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_NOT_FOUND, myInstance.getClassName().getString()); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
// // Modify instance based on modifiedInstance. // void UserAuthProvider::modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance& modifiedIns, const Boolean includeQualifiers, const CIMPropertyList & propertyList, ResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::modifyInstance"); // // get userName // String user; try { IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } // // check if the class name requested is PG_Authorization // if (!instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION ( CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString()); } CIMInstance newInstance = modifiedIns; // begin processing the request handler.processing(); try { // // Get the user name from the instance // String userNameStr; String namespaceStr; String authorizationStr; Uint32 pos = modifiedIns.findProperty ( PROPERTY_NAME_USERNAME ); CIMProperty prop = (CIMProperty)newInstance.getProperty(pos); prop.getValue().get(userNameStr); // // Get the namespace from the instance // pos = modifiedIns.findProperty ( PROPERTY_NAME_NAMESPACE ); prop = (CIMProperty)newInstance.getProperty(pos); prop.getValue().get(namespaceStr); // // Get the authorization from the instance // pos = modifiedIns.findProperty ( PROPERTY_NAME_AUTHORIZATION ); prop = (CIMProperty)newInstance.getProperty(pos); prop.getValue().get(authorizationStr); // // ATTN: Note that the following is a hack, because // modifyInstance() in repository does not like // the hostname and namespace included in the CIMObjectPath // passed to it as a parameter. // CIMObjectPath ref("", CIMNamespaceName (), modifiedIns.getClassName(), instanceReference.getKeyBindings()); CIMInstance newModifiedIns = modifiedIns.clone (); newModifiedIns.setPath (ref); // // call modifyInstances of the repository // _repository->modifyInstance( instanceReference.getNameSpace(), newModifiedIns); // // set authorization in the UserManager // _userManager->setAuthorization( userNameStr, namespaceStr, authorizationStr ); } catch(Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
void NamespaceProvider::enumerateInstanceNames( const OperationContext & context, const CIMObjectPath & classReference, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::enumerateInstanceNames()"); // Verify that ClassName == __Namespace if (!classReference.getClassName().equal(NAMESPACE_CLASSNAME)) { PEG_METHOD_EXIT(); //l10n //throw CIMNotSupportedException //(classReference.getClassName().getString() + //" not supported by Namespace Provider"); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER", "$0 not supported by Namespace Provider", classReference.getClassName().getString())); } //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } CIMNamespaceName parentNamespaceName = classReference.getNameSpace(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "parentNamespaceName = " + parentNamespaceName.getString()); Array<CIMObjectPath> instanceRefs; try { Array<CIMNamespaceName> namespaceNames = _repository->enumerateNameSpaces(); Array<CIMKeyBinding> keyBindings; // Build the instances. For now simply build the __Namespace instances // Note that for the moment, the only property is name. for (Uint32 i = 0; i < namespaceNames.size(); i++) { if (_isChild(parentNamespaceName, namespaceNames[i])) { keyBindings.clear(); keyBindings.append(CIMKeyBinding(NAMESPACE_PROPERTYNAME, namespaceNames[i].getString().subString (parentNamespaceName.getString().size()+1, namespaceNames[i].getString().size()- parentNamespaceName.getString().size()-1), CIMKeyBinding::STRING)); CIMObjectPath ref(String::EMPTY, parentNamespaceName, NAMESPACE_CLASSNAME, keyBindings); instanceRefs.append(ref); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "childNamespace = " + namespaceNames[i].getString()); } } } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } handler.deliver(instanceRefs); handler.complete(); PEG_METHOD_EXIT(); }
// // Creates a new instance. // void UserAuthProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance & myInstance, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_USER_MANAGER,"UserAuthProvider::createInstance"); CIMValue userName; CIMValue password; String userNameStr; String passwordStr; String namespaceStr; String authorizationStr; // // get userName // String user; try { const IdentityContainer container = context.get(IdentityContainer::NAME); user= container.getUserName(); } catch (...) { user= String::EMPTY; } // // verify user authorizations // if ( user != String::EMPTY || user != "" ) { _verifyAuthorization(user); } CIMInstance modifiedInst = myInstance; // begin processing the request handler.processing(); #ifndef PEGASUS_NO_PASSWORDFILE // // check if the class name requested is PG_User // if (CLASS_NAME_PG_USER.equal (instanceReference.getClassName())) { try { // // Get the user name from the instance // Uint32 pos = myInstance.findProperty ( PROPERTY_NAME_USERNAME ); CIMProperty prop = (CIMProperty)modifiedInst.getProperty(pos); userName = prop.getValue(); userName.get(userNameStr); // // Get the password from the instance // pos = myInstance.findProperty ( PROPERTY_NAME_PASSWORD ); prop = (CIMProperty) modifiedInst.getProperty(pos); password = prop.getValue(); password.get(passwordStr); // // Add the user to the User Manager // _userManager->addUser( userNameStr, passwordStr); } catch ( const CIMException & ) { handler.complete(); PEG_METHOD_EXIT(); throw; } catch ( const Exception &e ) { handler.complete(); PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } // // check if the class name requested is PG_Authorization // else if (instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #else if (instanceReference.getClassName().equal (CLASS_NAME_PG_AUTHORIZATION)) #endif { try { // // Get the user name from the instance // Uint32 pos = myInstance.findProperty ( PROPERTY_NAME_USERNAME ); CIMProperty prop = (CIMProperty)modifiedInst.getProperty(pos); prop.getValue().get(userNameStr); // // Get the namespace from the instance // pos = myInstance.findProperty ( PROPERTY_NAME_NAMESPACE ); prop = (CIMProperty)modifiedInst.getProperty(pos); prop.getValue().get(namespaceStr); // // Get the authorization from the instance // pos = myInstance.findProperty ( PROPERTY_NAME_AUTHORIZATION ); prop = (CIMProperty)modifiedInst.getProperty(pos); prop.getValue().get(authorizationStr); // // Check if the user is a valid system user // if ( !System::isSystemUser( userNameStr.getCString() ) ) { InvalidSystemUser isu(userNameStr); throw isu; } #ifndef PEGASUS_NO_PASSWORDFILE // // check if the user is a valid CIM user // if ( !_userManager->verifyCIMUser( userNameStr ) ) { InvalidUser iu(userNameStr); throw iu; } #endif _repository->createInstance( instanceReference.getNameSpace(), myInstance); // // set authorization in the UserManager // _userManager->setAuthorization( userNameStr, namespaceStr, authorizationStr ); } catch ( InvalidUser &iu ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, iu.getMessage()); } catch ( InvalidSystemUser &isu ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, isu.getMessage()); } catch ( InvalidNamespace &ins ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_INVALID_PARAMETER, ins.getMessage()); } catch ( CIMException &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } catch ( Exception &e ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } else { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION ( CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString()); } handler.deliver(instanceReference); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
void NamespaceProvider::enumerateInstances( const OperationContext & context, const CIMObjectPath & ref, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList& propertyList, InstanceResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::enumerateInstances()"); // Verify that ClassName == __Namespace if (!ref.getClassName().equal(NAMESPACE_CLASSNAME)) { PEG_METHOD_EXIT(); //l10n //throw CIMNotSupportedException(ref.getClassName().getString() + // " not supported by Namespace Provider"); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER", "$0 not supported by Namespace Provider", ref.getClassName().getString())); } //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } CIMNamespaceName parentNamespaceName = ref.getNameSpace(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "parentNamespaceName = " + parentNamespaceName.getString()); // begin processing the request handler.processing(); Array<CIMInstance> instanceArray; try { Array<CIMNamespaceName> namespaceNames = _repository->enumerateNameSpaces(); // Build the instances. For now simply build the __Namespace instances // Note that for the moment, the only property is name. for (Uint32 i = 0; i < namespaceNames.size(); i++) { if (_isChild(parentNamespaceName, namespaceNames[i])) { CIMInstance instance(NAMESPACE_CLASSNAME); instance.addProperty( (CIMProperty(NAMESPACE_PROPERTYNAME, namespaceNames[i].getString().subString (parentNamespaceName.getString().size()+1, namespaceNames[i].getString().size()- parentNamespaceName.getString().size()-1)))); instanceArray.append(instance); //instance.setPath(instanceName); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "childNamespace = " + namespaceNames[i].getString()); } } } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } handler.deliver(instanceArray); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); }
void NamespaceProvider::getInstance( const OperationContext & context, const CIMObjectPath & instanceName, const Boolean includeQualifiers, const Boolean includeClassOrigin, const CIMPropertyList & properatyList, InstanceResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::getInstance"); CIMNamespaceName childNamespaceName; CIMNamespaceName getNamespaceName; Boolean isRelativeName; // Verify that the className = __namespace if (!instanceName.getClassName().equal(NAMESPACE_CLASSNAME)) { PEG_METHOD_EXIT(); //l10n //throw CIMNotSupportedException(instanceName.getClassName().getString() //+ " not supported by Namespace Provider"); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER", "$0 not supported by Namespace Provider", instanceName.getClassName().getString())); } //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } _getKeyValue(instanceName, childNamespaceName, isRelativeName); CIMNamespaceName parentNamespaceName = instanceName.getNameSpace(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "childNamespaceName = " + childNamespaceName.getString() + (isRelativeName?String("true"):String("false")) + ", parentNamespaceName = " + parentNamespaceName.getString()); // begin processing the request handler.processing(); try { Array<CIMNamespaceName> namespaceNames; namespaceNames = _repository->enumerateNameSpaces(); _generateFullNamespaceName(namespaceNames, parentNamespaceName, childNamespaceName, isRelativeName, getNamespaceName); if (!Contains(namespaceNames, getNamespaceName)) { //l10n //throw CIMObjectNotFoundException("Namespace deos not exist: " //+ getNamespaceName.getString()); throw CIMObjectNotFoundException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NAMESPACE_DOES_NOT_EXIST", "Namespace does not exist: $0", getNamespaceName.getString())); } PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "Namespace = " + getNamespaceName.getString() + " successfully found."); } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } //Set name of class CIMInstance instance(NAMESPACE_CLASSNAME); // // construct the instance // instance.addProperty(CIMProperty(NAMESPACE_PROPERTYNAME, isRelativeName?childNamespaceName.getString(): parentNamespaceName.getString())); //instance.setPath(instanceName); handler.deliver(instance); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return ; }
void NamespaceProvider::deleteInstance( const OperationContext & context, const CIMObjectPath & instanceName, ResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::deleteInstance"); CIMNamespaceName childNamespaceName; CIMNamespaceName deleteNamespaceName; Boolean isRelativeName; // Verify that the className = __namespace if (!instanceName.getClassName().equal(NAMESPACE_CLASSNAME)) { PEG_METHOD_EXIT(); //l10n //throw CIMNotSupportedException(instanceName.getClassName().getString() //+ " not supported by Namespace Provider"); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER", "$0 not supported by Namespace Provider", instanceName.getClassName().getString())); } //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } _getKeyValue(instanceName, childNamespaceName, isRelativeName); CIMNamespaceName parentNamespaceName = instanceName.getNameSpace(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "childNamespaceName = " + childNamespaceName.getString() + (isRelativeName?String("true"):String("false")) + ", parentNamespaceName = " + parentNamespaceName.getString()); // begin processing the request handler.processing(); try { Array<CIMNamespaceName> namespaceNames; namespaceNames = _repository->enumerateNameSpaces(); _generateFullNamespaceName(namespaceNames, parentNamespaceName, childNamespaceName, isRelativeName, deleteNamespaceName); if (deleteNamespaceName.equal (ROOTNS)) { //l10n //throw CIMNotSupportedException("root namespace may be deleted."); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.ROOT_NAMESPACE_CANNOT_BE_DELETED", "root namespace may be deleted.")); } _repository->deleteNameSpace(deleteNamespaceName); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "Namespace = " + deleteNamespaceName.getString() + " successfully deleted."); } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return ; }
void NamespaceProvider::createInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance& myInstance, ObjectPathResponseHandler & handler) { PEG_METHOD_ENTER(TRC_CONTROLPROVIDER, "NamespaceProvider::createInstance()"); CIMNamespaceName childNamespaceName; CIMNamespaceName newNamespaceName; Boolean isRelativeName; // Verify that the className = __namespace if (!myInstance.getClassName().equal(NAMESPACE_CLASSNAME)) { PEG_METHOD_EXIT(); //l10n //throw CIMNotSupportedException(myInstance.getClassName().getString() //+ " not supported by Namespace Provider"); throw CIMNotSupportedException(MessageLoaderParms( "ControlProviders.NamespaceProvider.NamespaceProvider.NOT_SUPPORTED_BY_NAMESPACEPROVIDER", "$0 not supported by Namespace Provider", myInstance.getClassName().getString())); } //ATTN-DME-P3-20020522: ADD AUTHORIZATION CHECK TO __NAMESPACE PROVIDER String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } _getKeyValue(myInstance, childNamespaceName, isRelativeName); CIMNamespaceName parentNamespaceName = instanceReference.getNameSpace(); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "childNamespaceName = " + childNamespaceName.getString() + ", isRelativeName = " + (isRelativeName?String("true"):String("false")) + ", parentNamespaceName = " + parentNamespaceName.getString()); // begin processing the request handler.processing(); try { Array<CIMNamespaceName> namespaceNames; namespaceNames = _repository->enumerateNameSpaces(); _generateFullNamespaceName(namespaceNames, parentNamespaceName, childNamespaceName, isRelativeName, newNamespaceName); _repository->createNameSpace(newNamespaceName); PEG_TRACE_STRING(TRC_CONTROLPROVIDER, Tracer::LEVEL4, "Namespace = " + newNamespaceName.getString() + " successfully created."); } catch(const CIMException&) { PEG_METHOD_EXIT(); throw; } catch(const Exception&) { PEG_METHOD_EXIT(); throw; } // return key (i.e., CIMObjectPath) for newly created namespace Array<CIMKeyBinding> keyBindings; keyBindings.append(CIMKeyBinding(NAMESPACE_PROPERTYNAME, isRelativeName?childNamespaceName.getString(): parentNamespaceName.getString(), CIMKeyBinding::STRING)); CIMObjectPath newInstanceReference (String::EMPTY, parentNamespaceName, NAMESPACE_CLASSNAME, keyBindings); handler.deliver(newInstanceReference); // complete processing the request handler.complete(); PEG_METHOD_EXIT(); return; }
void ConfigSettingProvider::_modifyInstance( const OperationContext & context, const CIMObjectPath & instanceReference, const CIMInstance& modifiedIns, const CIMPropertyList& propertyList, Uint32 timeoutSeconds) { PEG_METHOD_ENTER(TRC_CONFIG, "ConfigSettingProvider::_modifyInstance()"); // // get userName // String userName; try { IdentityContainer container = context.get(IdentityContainer::NAME); userName = container.getUserName(); } catch (...) { userName = String::EMPTY; } // // verify user authorizations // z/OS: authorization check is done in CIMOpReqAuth already // #ifndef PEGASUS_OS_ZOS if (userName != String::EMPTY) { _verifyAuthorization(userName); } #endif // NOTE: Qualifiers are not processed by this provider, so the // IncludeQualifiers flag is ignored. // // check if the class name requested is PG_ConfigSetting // if (!instanceReference.getClassName().equal (PG_CONFIG_SETTING)) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, instanceReference.getClassName().getString()); } // // validate key bindings // Array<CIMKeyBinding> kbArray = instanceReference.getKeyBindings(); if ( (kbArray.size() != 1) || (!kbArray[0].getName().equal (PROPERTY_NAME))) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_INVALID_PARAMETER, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "INVALID_INSTANCE_NAME", "Invalid instance name")); } String configPropertyName = kbArray[0].getValue(); // Modification of the entire instance is not supported by this provider if (propertyList.isNull()) { PEG_METHOD_EXIT(); //l10n //throw PEGASUS_CIM_EXCEPTION(CIM_ERR_NOT_SUPPORTED, //"Modification of entire instance"); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "MODIFICATION_OF_ENTIRE_INSTANCE", "Modification of entire instance")); } Boolean currentValueModified = false; Boolean plannedValueModified = false; for (Uint32 i = 0; i < propertyList.size(); ++i) { CIMName propertyName = propertyList[i]; if (propertyName.equal (CURRENT_VALUE)) { currentValueModified = true; } else if (propertyName.equal (PLANNED_VALUE)) { plannedValueModified = true; } else { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_NOT_SUPPORTED, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "MODIFICATION_NOT_SUPPORTED", "Modification of property \"$0\"", propertyName.getString())); } } String preValue; String currentValue; String plannedValue; Boolean currentValueIsNull = false; Boolean plannedValueIsNull = false; // // Get the current value from the instance // Uint32 pos = modifiedIns.findProperty(CURRENT_VALUE); if (pos == PEG_NOT_FOUND) { currentValueIsNull = true; } else { CIMConstProperty prop = modifiedIns.getProperty(pos); try { prop.getValue().get(currentValue); } catch (Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } // // Get the planned value from the instance // pos = modifiedIns.findProperty(PLANNED_VALUE); if (pos == PEG_NOT_FOUND) { plannedValueIsNull = true; } else { CIMConstProperty prop = modifiedIns.getProperty(pos); try { prop.getValue().get(plannedValue); } catch (Exception& e) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage()); } } try { // // Update the current value, if requested // if (currentValueModified) { preValue = _configManager->getCurrentValue(configPropertyName); if ( !_configManager->updateCurrentValue( configPropertyName, currentValue, userName, timeoutSeconds, currentValueIsNull)) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_FAILED, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "UPDATE_CURRENT_VALUE_FAILED", "Failed to update the current value.")); } // It is unset, get current value which is default if (currentValueIsNull) { currentValue = _configManager->getCurrentValue( configPropertyName); } // send notify config change message to Handler Service if(String::equal(configPropertyName, "maxIndicationDeliveryRetryAttempts")|| String::equal(configPropertyName, "minIndicationDeliveryRetryInterval")) { _sendNotifyConfigChangeMessage( configPropertyName, currentValue, userName, PEGASUS_QUEUENAME_INDHANDLERMANAGER, true); } // send notify config change message to ProviderManager Service _sendNotifyConfigChangeMessage( configPropertyName, currentValue, userName, PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP, true); PEG_AUDIT_LOG(logSetConfigProperty(userName, configPropertyName, preValue, currentValue, false)); } // // Update the planned value, if requested // if (plannedValueModified) { preValue = _configManager->getPlannedValue(configPropertyName); if ( !_configManager->updatePlannedValue( configPropertyName, plannedValue, plannedValueIsNull) ) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_FAILED, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "UPDATE_PLANNED_VALUE_FAILED", "Failed to update the planned value.")); } // It is unset, get planned value which is default if (plannedValueIsNull) { plannedValue = _configManager->getPlannedValue( configPropertyName); if (String::equal(configPropertyName, "maxIndicationDeliveryRetryAttempts") || String::equal(configPropertyName, "minIndicationDeliveryRetryInterval")) { _sendNotifyConfigChangeMessage( configPropertyName, plannedValue, userName, PEGASUS_QUEUENAME_INDHANDLERMANAGER, false); } } // send notify config change message to ProviderManager Service _sendNotifyConfigChangeMessage( configPropertyName, plannedValue, userName, PEGASUS_QUEUENAME_PROVIDERMANAGER_CPP, false); PEG_AUDIT_LOG(logSetConfigProperty(userName, configPropertyName, preValue, plannedValue, true)); } } catch (const NonDynamicConfigProperty& ndcp) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_NOT_SUPPORTED, ndcp.getMessage()); } catch (const InvalidPropertyValue& ipv) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION( CIM_ERR_FAILED, ipv.getMessage()); } catch (const UnrecognizedConfigProperty&) { PEG_METHOD_EXIT(); throw PEGASUS_CIM_EXCEPTION_L( CIM_ERR_NOT_FOUND, MessageLoaderParms( "ControlProviders.ConfigSettingProvider." "ConfigSettingProvider." "CONFIG_PROPERTY_NOT_FOUND", "Configuration property \"$0\"", configPropertyName)); } PEG_METHOD_EXIT(); return; }