Пример #1
0
//
// Check if a given namespace exists
//
Boolean AuthorizationHandler::verifyNamespace(
    const CIMNamespaceName& nameSpace)
{
    PEG_METHOD_ENTER(
        TRC_AUTHORIZATION, "AuthorizationHandler::verifyNamespace()");

    try
    {
        //
        // call enumerateNameSpaces to get all the namespaces
        // in the repository
        //
        Array<CIMNamespaceName> namespaceNames =
            _repository->enumerateNameSpaces();

        //
        // check for the given namespace
        //
        Uint32 size = namespaceNames.size();

        for (Uint32 i = 0; i < size; i++)
        {
             if (nameSpace.equal (namespaceNames[i]))
             {
                 PEG_METHOD_EXIT();
                 return true;
             }
        }
    }
    catch (Exception& e)
    {
        PEG_METHOD_EXIT();
        throw InvalidNamespace(nameSpace.getString() + e.getMessage());
    }

    PEG_METHOD_EXIT();

    return false;
}
Пример #2
0
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 ;
}