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

  1 martin 1.24 //%LICENSE////////////////////////////////////////////////////////////////
  2 martin 1.25 //
  3 martin 1.24 // Licensed to The Open Group (TOG) under one or more contributor license
  4             // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
  5             // this work for additional information regarding copyright ownership.
  6             // Each contributor licenses this file to you under the OpenPegasus Open
  7             // Source License; you may not use this file except in compliance with the
  8             // License.
  9 martin 1.25 //
 10 martin 1.24 // Permission is hereby granted, free of charge, to any person obtaining a
 11             // copy of this software and associated documentation files (the "Software"),
 12             // to deal in the Software without restriction, including without limitation
 13             // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 14             // and/or sell copies of the Software, and to permit persons to whom the
 15             // Software is furnished to do so, subject to the following conditions:
 16 martin 1.25 //
 17 martin 1.24 // The above copyright notice and this permission notice shall be included
 18             // in all copies or substantial portions of the Software.
 19 martin 1.25 //
 20 martin 1.24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
 21 martin 1.25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 22 martin 1.24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 23             // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
 24             // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
 25             // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 26             // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 27 martin 1.25 //
 28 martin 1.24 //////////////////////////////////////////////////////////////////////////
 29 kumpf  1.1  //
 30             //%////////////////////////////////////////////////////////////////////////////
 31             
 32             
 33             ///////////////////////////////////////////////////////////////////////////////
 34             //  Shutdown Provider
 35             ///////////////////////////////////////////////////////////////////////////////
 36             
 37 mike   1.19 #include <Pegasus/Common/Signal.h>
 38 kumpf  1.1  #include <Pegasus/Common/Config.h>
 39 kumpf  1.23 #include <Pegasus/Common/CIMNameCast.h>
 40 kumpf  1.1  #include <Pegasus/Common/Tracer.h>
 41 kumpf  1.20 #include <Pegasus/Common/MessageLoader.h>
 42 kumpf  1.1  #include <Pegasus/Provider/CIMMethodProvider.h>
 43             #include <Pegasus/Server/ShutdownService.h>
 44 mike   1.19 #include "ShutdownProvider.h"
 45 kumpf  1.1  
 46             PEGASUS_USING_STD;
 47             
 48             PEGASUS_NAMESPACE_BEGIN
 49             
 50 mike   1.22 static const CIMName METHOD_NAME_SHUTDOWN = CIMNameCast("shutdown");
 51 kumpf  1.8  
 52 kumpf  1.1  //
 53             // Invoke method used to shutdown cimom.
 54             //
 55             void ShutdownProvider::invokeMethod(
 56 kumpf  1.20     const OperationContext& context,
 57                 const CIMObjectPath& objectReference,
 58                 const CIMName& methodName,
 59                 const Array<CIMParamValue>& inParameters,
 60                 MethodResultResponseHandler& handler)
 61 kumpf  1.1  {
 62                 PEG_METHOD_ENTER(TRC_SHUTDOWN, "ShutdownProvider::invokeMethod()");
 63 kumpf  1.8  
 64                 // Check to see if the method name is correct
 65 dl.meetei 1.26     // Only shutdown is supported
 66 kumpf     1.8      if (!methodName.equal(METHOD_NAME_SHUTDOWN))
 67                    {
 68                        PEG_METHOD_EXIT();
 69 kumpf     1.20         throw PEGASUS_CIM_EXCEPTION(
 70                            CIM_ERR_METHOD_NOT_AVAILABLE, String::EMPTY);
 71 kumpf     1.8      }
 72                
 73                    // Get user name
 74                    String userName;
 75 kumpf     1.20     if (context.contains(IdentityContainer::NAME))
 76 kumpf     1.8      {
 77                        IdentityContainer container = context.get(IdentityContainer::NAME);
 78                        userName = container.getUserName();
 79                    }
 80 a.dunfey  1.18     else
 81 kumpf     1.8      {
 82                        PEG_METHOD_EXIT();
 83                        throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, String::EMPTY);
 84                    }
 85 kumpf     1.20 
 86 marek     1.16 #ifndef PEGASUS_ZOS_SECURITY
 87 kumpf     1.8      // Only privileged user can execute this operation
 88 dl.meetei 1.27     if ( userName.size() && !System::isPrivilegedUser(userName))
 89 kumpf     1.8      {
 90                        MessageLoaderParms parms(
 91                            "ControlProviders.UserAuthProvider.MUST_BE_PRIVILEGED_USER",
 92 dl.meetei 1.27             "Superuser authority is required to run this CIM operation.");
 93 dl.meetei 1.26         PEG_METHOD_EXIT();
 94 kumpf     1.8          throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_ACCESS_DENIED, parms);
 95                    }
 96 marek     1.16 #endif
 97 kumpf     1.1  
 98                    // Begin processing the request
 99                    handler.processing();
100                
101                    // Check if the input parameters are passed.
102 kumpf     1.20     if (inParameters.size() < 2)
103 kumpf     1.1      {
104                        PEG_METHOD_EXIT();
105 kumpf     1.20         throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
106                            MessageLoaderParms(
107                                "Server.ShutdownProvider.INPUT_NOT_VALID",
108                                "Input parameters are not valid."));
109 kumpf     1.1      }
110                
111                    Boolean force = false;
112                    Uint32 timeoutValue = 0;
113                
114                    // Get the input parameter values
115                    for (Uint32 i = 0; i < inParameters.size(); i++)
116                    {
117                        String parmName = inParameters[i].getParameterName();
118                        if (String::equalNoCase(parmName, "force"))
119                        {
120                            //
121                            // get the force parameter
122                            //
123                            inParameters[i].getValue().get(force);
124                        }
125                        else
126                        {
127                            if (String::equalNoCase(parmName, "timeout"))
128                            {
129                                //
130 kumpf     1.1                  // get the timeout value
131                                //
132                                inParameters[i].getValue().get(timeoutValue);
133                            }
134                            else
135                            {
136                                PEG_METHOD_EXIT();
137 kumpf     1.20                 throw PEGASUS_CIM_EXCEPTION_L(CIM_ERR_INVALID_PARAMETER,
138                                    MessageLoaderParms(
139                                        "Server.ShutdownProvider.INPUT_NOT_VALID",
140                                        "Input parameters are not valid."));
141 kumpf     1.1              }
142                        }
143                    }
144                
145                    try
146                    {
147 kumpf     1.6          _shutdownService->shutdown(force, timeoutValue, true);
148 kumpf     1.1      }
149                    catch (CIMException& e)
150                    {
151                        PEG_METHOD_EXIT();
152                        throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
153                    }
154                    catch (Exception& e)
155                    {
156                        PEG_METHOD_EXIT();
157                        throw PEGASUS_CIM_EXCEPTION(CIM_ERR_FAILED, e.getMessage());
158                    }
159                
160                    handler.deliver(CIMValue(0));
161                    handler.complete();
162                    PEG_METHOD_EXIT();
163                }
164                
165                PEGASUS_NAMESPACE_END

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2