1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-11 05:17:41 +03:00

feature #203: Conforming new protocol spec

This commit is contained in:
Ruben S. Montero 2010-07-08 15:45:00 +02:00
parent 11b39a6a34
commit 3388563a9d
7 changed files with 70 additions and 38 deletions

View File

@ -145,12 +145,12 @@ private:
/**
* Default timeout for Auth requests
*/
static time_t _time_out;
static time_t _time_out;
/**
* Timer for the Manager (periocally triggers timer action)
*/
time_t timer_period;
time_t timer_period;
/**
* Returns a pointer to a Auth Manager driver.
@ -292,9 +292,13 @@ public:
* Sets the challenge to authenticate an user
* @param challenge a driver specific authentication challenge
*/
void set_challenge(const string &ch)
void add_authenticate(const string &_username,
const string &_password,
const string &_session)
{
challenge = ch;
username = _username;
password = _password;
session = _session;
}
/**
@ -407,9 +411,19 @@ private:
time_t time_out;
/**
* Authentication challenge, as sent in the XML-RPC call
* Username to authenticate the user
*/
string challenge;
string username;
/**
* User password to authenticate the user
*/
string password;
/**
* Authentication token as sent in the XML-RPC call
*/
string session;
/**
* A list of authorization requests

View File

@ -77,12 +77,18 @@ private:
/**
* Sends an authorization request to the MAD:
* "AUTHENTICATE OPERATION_ID USER_ID CHALLENGE"
* "AUTHENTICATE REQUEST_ID USER_ID USER_NAME PASSWORD XMLRPC_TOKEN"
* @param oid an id to identify the request.
* @param uid the user id.
* @param challenge to authenticate the user
* @param username
* @param password
* @param session token from the xml-rpc parameter
*/
void authenticate(int oid, int uid, const string& ch) const;
void authenticate(int oid,
int uid,
const string& username,
const string& password,
const string& session) const;
};
/* -------------------------------------------------------------------------- */

View File

@ -161,10 +161,14 @@ void AuthManager::authenticate_action(AuthRequest * ar)
// ------------------------------------------------------------------------
// Make the request to the driver
// ------------------------------------------------------------------------
// ---- --------------------------------------------------------------------
authm_md->authenticate(ar->id,ar->uid,ar->challenge);
authm_md->authenticate(ar->id,
ar->uid,
ar->username,
ar->password,
ar->session);
return;
error_driver:

View File

@ -34,11 +34,19 @@ void AuthManagerDriver::authorize(int oid, int uid, const string& reqs) const
write(os);
}
void AuthManagerDriver::authenticate(int oid, int uid, const string& ch) const
void AuthManagerDriver::authenticate(int oid,
int uid,
const string& username,
const string& password,
const string& session) const
{
ostringstream os;
os << "AUTHENTICATE " << oid << " " << uid << " " << ch << endl;
os << "AUTHENTICATE " << oid << " "
<< uid << " "
<< username << " "
<< password << " "
<< session << endl;
write(os);
}

View File

@ -113,9 +113,10 @@ public:
am->load_mads(0);
ar.add_authenticate("the_user","the_pass","the_secret");
am->trigger(AuthManager::AUTHENTICATE,&ar);
ar.set_challenge("the_secret");
ar.wait();
CPPUNIT_ASSERT(ar.result==false);
@ -141,7 +142,7 @@ public:
am->load_mads(0);
ar.set_challenge("the_secret");
ar.add_authenticate("the_user","the_pass","the_secret");
am->trigger(AuthManager::AUTHENTICATE,&ar);
ar.wait();

View File

@ -1,24 +1,24 @@
#!/bin/bash
# --------------------------------------------------------------------------
# Copyright 2002-2006 GridWay Team, Distributed Systems Architecture
# Group, Universidad Complutense de Madrid
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# --------------------------------------------------------------------------
# --------------------------------------------------------------------------
# Copyright 2002-2006 GridWay Team, Distributed Systems Architecture
# Group, Universidad Complutense de Madrid
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# --------------------------------------------------------------------------
echo "MAD started" >> mad.log
echo "MAD started" > mad.log
while read COMMAND ARG1 ARG2 ARG3
do
@ -30,10 +30,9 @@ do
"FINALIZE")
echo "FINALIZE SUCCESS"
exit 0
;;
;;
"AUTHORIZE")
sleep 1
echo "AUTHORIZE FAILURE $ARG1 $ARG3"
echo "AUTHORIZE FAILURE $ARG1 $ARG3"
;;
"AUTHENTICATE")
echo "AUTHENTICATE SUCCESS $ARG1"

View File

@ -332,9 +332,9 @@ public:
}
// Discover the enabled hosts
rc = hp->discover(&dh);
rc = hp->discover(&dh,5);
CPPUNIT_ASSERT(rc == 0);
CPPUNIT_ASSERT(dh.size() == 8);
CPPUNIT_ASSERT(dh.size() == 5);
for(i=0,it=dh.begin(),oss.str("");it!=dh.end();it++,i++,oss.str(""))
{