mirror of
https://github.com/OpenNebula/one.git
synced 2026-11-09 22:14:13 +09:00
Feature #687: Change the way the rule string representation is built
This commit is contained in:
1 parent
773f5f0881
commit
85fa48e604
2 files changed
+19
-11
No files matched your search
+14
-3
@@ -37,7 +37,9 @@ public:
|
||||
|
||||
AclRule(long long _user, long long _resource, long long _rights):
|
||||
user(_user), resource(_resource), rights(_rights)
|
||||
{};
|
||||
{
|
||||
build_str();
|
||||
};
|
||||
|
||||
bool operator ==(const AclRule& other) const
|
||||
{
|
||||
@@ -51,8 +53,10 @@ public:
|
||||
*
|
||||
* @return a human readable string for this rule
|
||||
*/
|
||||
string to_str() const;
|
||||
|
||||
const string& to_str() const
|
||||
{
|
||||
return str;
|
||||
};
|
||||
|
||||
/**
|
||||
* Function to print the object into a string in XML format
|
||||
@@ -124,6 +128,13 @@ private:
|
||||
* 64 bit integer containing the rights flags
|
||||
*/
|
||||
long long rights;
|
||||
|
||||
/**
|
||||
* Human readable representation
|
||||
*/
|
||||
string str;
|
||||
|
||||
void build_str();
|
||||
};
|
||||
|
||||
#endif /*ACL_RULE_H*/
|
||||
|
||||
+5
-8
@@ -27,11 +27,10 @@ const long long AclRule::ALL_ID = 0x400000000LL;
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string AclRule::to_str() const
|
||||
void AclRule::build_str()
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "USER:";
|
||||
if ( (user & GROUP_ID) != 0 )
|
||||
{
|
||||
oss << "@" << user_id();
|
||||
@@ -45,7 +44,7 @@ string AclRule::to_str() const
|
||||
oss << "*";
|
||||
}
|
||||
|
||||
oss << " RESOURCE:";
|
||||
oss << " ";
|
||||
|
||||
AuthRequest::Object objects[] = {
|
||||
AuthRequest::VM,
|
||||
@@ -89,7 +88,7 @@ string AclRule::to_str() const
|
||||
oss << "*";
|
||||
}
|
||||
|
||||
oss << " OPERATION:";
|
||||
oss << " ";
|
||||
|
||||
|
||||
AuthRequest::Operation operations[] = {
|
||||
@@ -120,7 +119,7 @@ string AclRule::to_str() const
|
||||
}
|
||||
}
|
||||
|
||||
return oss.str();
|
||||
str = oss.str();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@@ -135,9 +134,7 @@ string& AclRule::to_xml(string& xml) const
|
||||
"<USER>" << hex << user << "</USER>" <<
|
||||
"<RESOURCE>" << hex << resource << "</RESOURCE>" <<
|
||||
"<RIGHTS>" << hex << rights << "</RIGHTS>" <<
|
||||
|
||||
// TODO: Element DEBUG contains a human friendly string
|
||||
"<DEBUG>" << to_str() << "</DEBUG>" <<
|
||||
"<STRING>" << str << "</STRING>" <<
|
||||
"</RULE>";
|
||||
|
||||
xml = oss.str();
|
||||
|
||||
Reference in new issue
Block a user