230 lines
6.8 KiB
XML
230 lines
6.8 KiB
XML
<?xml version="1.0"?>
|
|
<component>
|
|
<?component error="true" debug="true"?>
|
|
<registration
|
|
description="scimusers"
|
|
progid="flexwhere.WSC"
|
|
version="1.00"
|
|
classid="{6D817B6F-9D08-4636-AAD9-8BD7C5EFF56A}"
|
|
>
|
|
</registration>
|
|
|
|
<public>
|
|
|
|
<!-- properties -->
|
|
|
|
<!-- methods -->
|
|
<method name="initialize">
|
|
<PARAMETER name="params"/>
|
|
</method>
|
|
<method name="transform_filter">
|
|
<PARAMETER name="filter"/>
|
|
</method>
|
|
<method name="transform_outgoing">
|
|
<PARAMETER name="params"/>
|
|
<PARAMETER name="data"/>
|
|
</method>
|
|
<method name="transform_incoming">
|
|
<PARAMETER name="params"/>
|
|
<PARAMETER name="data"/>
|
|
</method>
|
|
<method name="get_eTag">
|
|
<PARAMETER name="params"/>
|
|
<PARAMETER name="data"/>
|
|
</method>
|
|
</public>
|
|
|
|
<script language="javascript">
|
|
<![CDATA[
|
|
|
|
/* properties */
|
|
|
|
|
|
/* methods */
|
|
/*
|
|
/*
|
|
$Id$
|
|
|
|
File: scimusers.wsc
|
|
*/
|
|
/* Globals */
|
|
var FCLT;
|
|
|
|
// De omschrijving van de objecten in FACILITOR moet FW1, FW2 etc. zijn
|
|
var scimusers_srtdeel_key = 258418;
|
|
|
|
function initialize(params)
|
|
{
|
|
FCLT = params;
|
|
}
|
|
|
|
function transform_filter(filter)
|
|
{
|
|
if ("count" in filter)
|
|
filter.limit = filter.count;
|
|
return filter;
|
|
}
|
|
|
|
function get_eTag(params, data)
|
|
{
|
|
if (data && typeof data == "object" && "meta" in data)
|
|
return data.meta.version;
|
|
return null;
|
|
}
|
|
|
|
// We krijgen bijvoorbeeld: {"RMS":[1,-10,-11,-12,-13,-14,-15,-16,-17,2,3,-4,-5,-6,-7,-8,-9]}
|
|
// Als het object aan staat wordt de id opgeleverd, anders -id
|
|
function transform_incoming(params, data)
|
|
{
|
|
FCLT.DEZE.__DoLog(data);
|
|
var extension = data["urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"];
|
|
|
|
var person =
|
|
{
|
|
login : data["userName"],
|
|
externallogin: data["userName"],
|
|
externalid : data["externalId"],
|
|
// name : data["name"]["displayName"],
|
|
initials : data["userFacilitor"]["initials"],
|
|
lastname : data["name"]["familyName"],
|
|
middlename : data["name"]["middleName"],
|
|
firstname : data["name"]["givenName"],
|
|
deactivated : data["active"]?null:new Date(),
|
|
employeenumber : extension["employeeNumber"]
|
|
};
|
|
|
|
if (data["userName"] == undefined) person.login = "";
|
|
if (data["userFacilitor"]["initials"] == undefined) person.initials = "";
|
|
if (data["name"]["middleName"] == undefined) person.middlename = "";
|
|
if (data["name"]["givenName"] == undefined) person.firstname = "";
|
|
if (extension["employeeNumber"] == undefined) person.employeenumber = "";
|
|
|
|
|
|
var dep_id = data["orgUnit"]["id"].replace (FCLT.DEZE.customerId + "_department_", "");
|
|
|
|
person["department"] = { id: dep_id };
|
|
person["function"] = { name: data["title"] } // id mag achterwege blijven omdat desc_is_unique
|
|
|
|
if (data["emails"])
|
|
{
|
|
person.email = data["emails"][0].value; // type:work/primary:true opzoeken ?
|
|
}
|
|
if (data["phoneNumbers"])
|
|
{
|
|
person.mobile = data["phoneNumbers"][0].value; // type:mobile/primary:true opzoeken ?
|
|
}
|
|
// TODO groepen negeren we nog
|
|
|
|
//FCLT.DEZE.__DoLog(person);
|
|
|
|
return { person: person };
|
|
}
|
|
|
|
function transform_one_person(params, person)
|
|
{
|
|
FCLT.DEZE.__Log(person);
|
|
var unique = FCLT.DEZE.customerId + "_person_" + String(person.id);
|
|
var oneuser = {
|
|
"userName":person.externallogin || person.login,
|
|
"externalId":person.externalid,
|
|
"id":unique,
|
|
"userFacilitor":{
|
|
"initials":person.initials
|
|
},
|
|
"name":{
|
|
"formatted":person.name,
|
|
"familyName":person.lastname,
|
|
"givenName":person.firstname,
|
|
"middleName":person.middlename
|
|
},
|
|
"schemas":[
|
|
"urn:ietf:params:scim:schemas:core:2.0:User",
|
|
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User"
|
|
],
|
|
"displayName":person.name,
|
|
"active": !person.deactivated,
|
|
"meta":{
|
|
"created":person.created,
|
|
"lastModified":person.lastchange,
|
|
"location":FCLT.DEZE.HTTP.urlzelf() + "/appl/SCIM/Users/" + unique,
|
|
"resourceType":"User"
|
|
},
|
|
"Title":person["function"].name,
|
|
"emails":[
|
|
{
|
|
"value":person.email,
|
|
"type":"work",
|
|
"primary":true
|
|
}
|
|
],
|
|
"phoneNumbers":[
|
|
{
|
|
"value":person.mobile,
|
|
"type":"mobile",
|
|
"primary":true
|
|
}
|
|
],
|
|
"orgunit":
|
|
{
|
|
"id":FCLT.DEZE.customerId + "_department_" + String(person.department.id),
|
|
"$ref":FCLT.DEZE.HTTP.urlzelf() + "/appl/SCIM/OrgUnits/" + FCLT.DEZE.customerId + "_department_" + String(person.department.id)
|
|
}
|
|
,
|
|
"groups":[],
|
|
"urn:ietf:params:scim:schemas:extension:enterprise:2.0:User" :
|
|
{
|
|
"employeeNumber":person.employeenumber
|
|
}
|
|
}
|
|
var allgroups = [];
|
|
for (var j = 0; j < person.authorization.length; j++)
|
|
{
|
|
var group = person.authorization[j];
|
|
var unique = FCLT.DEZE.customerId + "_authorizationgroup_" + String(group.authorizationgroup.id);
|
|
oneuser.groups.push({
|
|
"value":unique,
|
|
"$ref":FCLT.DEZE.HTTP.urlzelf() + "/appl/SCIM/Groups/" + unique,
|
|
"display":group.authorizationgroup.name
|
|
})
|
|
}
|
|
var oCrypto = new ActiveXObject("SLNKDWF.Crypto");
|
|
var eTag = '"' + oCrypto.hex_sha1(FCLT.DEZE.JSON.stringify(oneuser)).toLowerCase() + '"';
|
|
oneuser.meta["version"] = "W/" + eTag; // Weak eTag?
|
|
return oneuser;
|
|
}
|
|
function transform_outgoing(params, data)
|
|
{
|
|
if ("person" in data)
|
|
{
|
|
var oneperson = transform_one_person(params, data.person);
|
|
return oneperson;
|
|
}
|
|
if ("persons" in data)
|
|
{
|
|
var allusers = [];
|
|
for (var i = 0; i < data.persons.length; i++)
|
|
{
|
|
if (params.limit && allusers.length > params.limit)
|
|
break;
|
|
var person = data.persons[i];
|
|
if (person.login && person.login.indexOf('_') != 0)
|
|
{
|
|
// _ users are not part of the interface.
|
|
allusers.push(transform_one_person(params, person));
|
|
}
|
|
}
|
|
|
|
return {
|
|
"totalResults": allusers.length,
|
|
"itemsPerPage": 10,
|
|
"startIndex": 1,
|
|
"schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
|
|
"Resources": allusers
|
|
};
|
|
}
|
|
}
|
|
|
|
]]>
|
|
</script>
|
|
</component>
|