Application Delivery Management
Application Modernization & Connectivity
CyberRes by OpenText
IT Operations Management
# TODO:
# Decide on a good way to implement:
# - findRoleByExampleWithOperator
# - findSodByExample
# - findSodByExampleWithOperator
# Current challenge is the sheer amount of different valid options, where all
# of them can be used simultaneously. Barring some sort of common usage pattern
# the best way might be to use getopts and use parameter names, not only positions.
#
# Figure how modifyRole works
### Function: createRole
# Usage:
# createRole $username $password $rbpm_url $output_file $rolename $description $rolelevel $category $correlation_id
# if the $correlation_id is omitted, will call createRoleRequest, otherwise will call createRoleAidRequest
# if the category is omitted with use the value "default"
# Order of parameters is important, it is not possible to use the correlation_id and skip category
#
createRole()
{
USAGE="Function Usage:
createRole username password rbpm_url output_file rolename description rolelevel category correlation_id
if the correlation_id is omitted, will call createRoleRequest, otherwise will call createRoleAidRequest
if the category is omitted with use the value "default"
Order of parameters is important, it is not possible to provide a correlation_id and skip category at the same time
rbpm_url should be in the format:
protocol://server:port/servicename
for example:
https://rbpm.lab.novell.com:8543/IDMProv";
if "X$_RBPM_SOAP_ROLE_DEBUG" = "Xtrue"
then
dbgparams=$#
dbgparam=1
while [ "$dbgparam" -le "$dbgparams" ]
do
echo -n "Parameter "
echo -n \$$dbgparam
echo -n " = "
eval echo \$$dbgparam
(( dbgparam ))
done
fi
# Initial Parameters check
if | -z "$2" || -z "$3" || -z "$4" || -z "$5" || -z "$6" || -z "$7"
then
echo "$USAGE"
return 1
fi
if -z "$8"
then
CAT=default
else
CAT="$8"
fi
if -z "$9"
then
NOCID=true
else
NOCID=false
CID="$9"
fi
if "X$2" = "X-W"
then
read -sp "Please enter the password for user $1: " SENHA
echo
else
SENHA=$2
fi
# Setup for the SOAP call
URL="${3}/role/service"
if "$NOCID" = "true"
then
ACTION="SOAPAction: 'http://www.novell.com/role/service/createRole'"
SOAPCALL=createRoleRequest
else
ACTION="SOAPAction: 'http://www.novell.com/role/service/createRoleAid'"
SOAPCALL=createRoleAidRequest
fi
CTYPE='Content-Type: text/xml;charset=UTF-8'
# Build SOAP XML envelope and call to be issued
POST="<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://www.novell.com/role/service'>\
<soapenv:Header/>\
<soapenv:Body>\
<ser:${SOAPCALL}>\
<ser:role>\
<ser:approvers/>\
<ser:container/>\
<ser:description>${6}</ser:description>\
<ser:entityKey/>\
<ser:name>${5}</ser:name>\
<ser:owners/>\
<ser:quorum/>\
<ser:requestDef/>\
<ser:revokeRequestDef/>\
<ser:roleCategoryKeys>\
<ser:categorykey>\
<ser:categoryKey>${CAT}</ser:categoryKey>\
</ser:categorykey>\
</ser:roleCategoryKeys>\
<ser:roleLevel>${7}</ser:roleLevel>\
<ser:systemRole>false</ser:systemRole>\
</ser:role>"
if "$NOCID" = "false"
then
POST="${POST}<ser:correlationId>${CID}</ser:correlationId>"
fi
POST="${POST}</ser:${SOAPCALL}>\
</soapenv:Body>\
</soapenv:Envelope>"
if "X$_RBPM_SOAP_ROLE_DEBUG" = "Xtrue"
then
echo
echo POST data:
echo $POST
echo
fi
# Issue the request
curl $_CURL_OPTIONS -k -u "$1:$SENHA" -H "$CTYPE" -H "$ACTION" -d "$POST" "$URL" -o "$4"
}
The issue that I see is in the section where the POST variable is set, the XML for the SOAP call is being built as a string, and some of the possible nodes are left empty. Like:
<ser:approvers/>
<ser:container/>
<ser:entityKey/>
<ser:owners/>
<ser:quorum/>
<ser:requestDef/>
<ser:revokeRequestDef/>
<ser:owners>
<!--Zero or more repetitions:-->
<ser:dnstring>
<ser:dn>?</ser:dn>
</ser:dnstring>
</ser:owners>
if "X$8 = "X$_NULL"
then
POST="${POST}<ser:owners/>"
else
POST="${POST}<ser:owners>\
<ser:dnstring>\
<ser:dn>${8}</ser:dn>\
</ser:dnstring>\
</ser:owners>"
fi
<ser:approvers>
<!--Zero or more repetitions:-->
<ser:approver>
<ser:approverDN>?</ser:approverDN>
<ser:sequence>?</ser:sequence>
</ser:approver>
</ser:approvers>
if "X$9 = "X$_NULL"
then
POST="${POST}<ser:approvers/>"
else
POST="${POST}<ser:approvers>
<ser:approver>\
<ser:approverDN>${9}</ser:approverDN>\
<ser:sequence>0</ser:sequence>\
</ser:approver>\
</ser:approvers>\
fi
<ser:container/>
<ser:entityKey/>
<ser:quorum/>
<ser:requestDef/>
<ser:revokeRequestDef/>
if "X$10 = "X$_NULL"
then
POST="${POST}<ser:container/>"
else
POST="${POST}<ser:container>${10}</ser:container>"
fi
For quorum, which I do not understand the allowed values, add it as:
if "X$11 = "X$_NULL"
then
POST="${POST}<ser:quorum/>"
else
POST="${POST}<ser:quorum>${11}</ser:quorum>"
fi
For requestDef it is just an LDAP DN of the PRD, so that is an easy one. A long value, but an easy value to obtain.
if "X$12 = "X$_NULL"
then
POST="${POST}<ser:requestDef/>"
else
POST="${POST}<ser:requestDef>${12}</ser:requestDef>"
fi
if "X$13 = "X$_NULL"
then
POST="${POST}<ser:revokeRequestDef/>"
else
POST="${POST}<ser:revokeRequestDef>${13}</ser:revokeRequestDef>"
fi
if "X$14 = "X$_NULL"
then
POST="${POST}<ser:entityKey/>"
else
POST="${POST}<ser:entityKey>${14}</ser:entityKey>"
fi
### Function: createRole2
# Usage:
# createRole username password rbpm_url output_file rolename description rolelevel ownerDN approverDN container quorum requestDefDN
# revokeReqDefDN category correlation_id
# if the $correlation_id is omitted, will call createRoleRequest, otherwise will call createRoleAidRequest
# if the category is omitted with use the value "default"
# Order of parameters is important, it is not possible to use the correlation_id and skip category
# If you have no value for a field other than category and correlationId, use the value of the NULL variable, default is 'null'
createRole2()
{
USAGE="Function Usage:
createRole username password rbpm_url output_file rolename description rolelevel ownerDN approverDN container quorum requestDefDN revokeReqDefDN category correlation_id
if the correlation_id is omitted, will call createRoleRequest, otherwise will call createRoleAidRequest
if the category is omitted with use the value "default"
Order of parameters is important, it is not possible to provide a correlation_id and skip category at the same time
If you have no value for a field other than category and correlationId, use the value of the NULL variable, default is 'null'
rbpm_url should be in the format:
protocol://server:port/servicename
for example:
https://rbpm.lab.novell.com:8543/IDMProv";
if "X$_RBPM_SOAP_ROLE_DEBUG" = "Xtrue"
then
dbgparams=$#
dbgparam=1
while [ "$dbgparam" -le "$dbgparams" ]
do
echo -n "Parameter "
echo -n \$$dbgparam
echo -n " = "
eval echo \$$dbgparam
(( dbgparam ))
done
fi
# Initial Parameters check
if | -z "$2" || -z "$3" || -z "$4" || -z "$5" || -z "$6" || -z "$7" || -z "$8" || -z "$9" || -z "$10" || -z "$11" || -z "$12" || -z "$13" || -z "$14"
then
echo "$USAGE"
return 1
fi
if -z "$15"
then
CAT=default
else
CAT="$8"
fi
if -z "$16"
then
NOCID=true
else
NOCID=false
CID="$9"
fi
if "X$2" = "X-W"
then
read -sp "Please enter the password for user $1: " SENHA
echo
else
SENHA=$2
fi
# Setup for the SOAP call
URL="${3}/role/service"
if "$NOCID" = "true"
then
ACTION="SOAPAction: 'http://www.novell.com/role/service/createRole'"
SOAPCALL=createRoleRequest
else
ACTION="SOAPAction: 'http://www.novell.com/role/service/createRoleAid'"
SOAPCALL=createRoleAidRequest
fi
CTYPE='Content-Type: text/xml;charset=UTF-8'
# Build SOAP XML envelope and call to be issued
POST="<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://www.novell.com/role/service'>\
<soapenv:Header/>\
<soapenv:Body>\
<ser:${SOAPCALL}>\
<ser:role>\
<ser:description>${6}</ser:description>\
<ser:entityKey/>\
<ser:name>${5}</ser:name>\
<ser:roleCategoryKeys>\
<ser:categorykey>\
<ser:categoryKey>${CAT}</ser:categoryKey>\
</ser:categorykey>\
</ser:roleCategoryKeys>\
<ser:roleLevel>${7}</ser:roleLevel>\
<ser:systemRole>false</ser:systemRole>"
if "X$8 = "X$_NULL"
then
POST="${POST}<ser:owners/>"
else
POST="${POST}<ser:owners>\
<ser:dnstring>\
<ser:dn>${8}</ser:dn>\
</ser:dnstring>\
</ser:owners>"
fi
if "X$9 = "X$_NULL"
then
POST="${POST}<ser:approvers/>"
else
POST="${POST}<ser:approvers>
<ser:approver>\
<ser:approverDN>${9}</ser:approverDN>\
<ser:sequence>0</ser:sequence>\
</ser:approver>\
</ser:approvers>\
fi
if "X$10 = "X$_NULL"
then
POST="${POST}<ser:container/>"
else
POST="${POST}<ser:container>${10}</ser:container>"
fi
if "X$11 = "X$_NULL"
then
POST="${POST}<ser:quorum/>"
else
POST="${POST}<ser:quorum>${11}</ser:quorum>"
fi
if "X$12 = "X$_NULL"
then
POST="${POST}<ser:requestDef/>"
else
POST="${POST}<ser:requestDef>${12}</ser:requestDef>"
fi
if "X$13 = "X$_NULL"
then
POST="${POST}<ser:revokeRequestDef/>"
else
POST="${POST}<ser:revokeRequestDef>${13}</ser:revokeRequestDef>"
fi
if "X$14 = "X$_NULL"
then
POST="${POST}<ser:entityKey/>"
else
POST="${POST}<ser:entityKey>${14}</ser:entityKey>"
fi
POST="${POST}</ser:role>"
if "$NOCID" = "false"
then
POST="${POST}<ser:correlationId>${CID}</ser:correlationId>"
fi
POST="${POST}</ser:${SOAPCALL}>\
</soapenv:Body>\
</soapenv:Envelope>"
if "X$_RBPM_SOAP_ROLE_DEBUG" = "Xtrue"
then
echo
echo POST data:
echo $POST
echo
fi
# Issue the request
curl $_CURL_OPTIONS -k -u "$1:$SENHA" -H "$CTYPE" -H "$ACTION" -d "$POST" "$URL" -o "$4"
}