Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
fusiondirectory-orchestrator
Commits
0807e972
Verified
Commit
0807e972
authored
7 months ago
by
dockx thibault
Browse files
Options
Download
Patches
Plain Diff
Feat(Orchestrator) - all attrs monitored
All attrs monitored.
parent
5ca9c13f
dev
61-orchestrator-lifecycle-array-supann-is-analyzed-with-static-numbering
63-orchestrator-mail-controller-format-of-mail-text-and-signature-are-not-utf8-usage-of-accents-is
70-create-unitests-for-orchestrator
73-orchestrator-create-a-librabry-in-core-orchestrator
78-redesign-audit-class
79-redesign-mail
80-redesign-notifications-class
81-redesign-reminders-class
82-redesign-lifecycle-class
main
revert-55863b23
1.1
2 merge requests
!72
Releasing Fusiondirectory Orchestrator 1.1
,
!60
Resolve "[Orchestrator] - Notifications must be updated to be aware of supannStatus values"
Pipeline
#29757
passed with stages
in 2 minutes and 53 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/tasks/Notifications.php
+64
-24
plugins/tasks/Notifications.php
with
64 additions
and
24 deletions
+64
-24
plugins/tasks/Notifications.php
+
64
−
24
View file @
0807e972
...
@@ -68,9 +68,17 @@ class Notifications implements EndpointInterface
...
@@ -68,9 +68,17 @@ class Notifications implements EndpointInterface
// Generate the mail form with all mail controller requirements
// Generate the mail form with all mail controller requirements
$mailTemplateForm
=
$this
->
generateMainTaskMailTemplate
(
$notificationsMainTask
);
$mailTemplateForm
=
$this
->
generateMainTaskMailTemplate
(
$notificationsMainTask
);
// Simply retrieve the list of audited attributes
$auditAttributes
=
$this
->
retrieveAuditedAttributes
(
$task
);
// Simply retrieve the list of audited attributes, it is a json format and require decoding.
$auditAttributesJson
=
$this
->
retrieveAuditedAttributes
(
$task
);
$auditAttributes
=
NULL
;
// To set the var and reset its value.
// Decoding the json_format into an associative array, implode allows to put all values of array together.(forming the json correctly).
foreach
(
$auditAttributesJson
as
$auditAttribute
)
{
$auditAttributes
[]
=
json_decode
(
implode
(
$auditAttribute
),
TRUE
);
}
// Recovering monitored attributes list from the defined notification task.
$monitoredAttrs
=
$notificationsMainTask
[
0
][
'fdtasksnotificationsattributes'
];
$monitoredAttrs
=
$notificationsMainTask
[
0
][
'fdtasksnotificationsattributes'
];
// Management of Supann Status
// Management of Supann Status
...
@@ -83,21 +91,25 @@ class Notifications implements EndpointInterface
...
@@ -83,21 +91,25 @@ class Notifications implements EndpointInterface
$this
->
gateway
->
unsetCountKeys
(
$monitoredAttrs
);
$this
->
gateway
->
unsetCountKeys
(
$monitoredAttrs
);
$this
->
gateway
->
unsetCountKeys
(
$monitoredSupannResource
);
$this
->
gateway
->
unsetCountKeys
(
$monitoredSupannResource
);
// Verification if supannRessourceEtatDate with criteria from main tasks are matched.
// Verify if there is a match between audited attributes and monitored attributes from main task. (values to values, not keys).
if
(
$monitoredSupannResource
[
'resource'
]
!==
'None'
)
{
$matchingAttrs
=
NULL
;
// Allows to define but reset variable as well.
if
(
$this
->
verifySupannState
(
$monitoredSupannResource
,
$task
[
'fdtasksgranulardn'
][
0
]))
{
if
(
!
empty
(
$auditAttributes
))
{
// Simply inject supannRessourceEtat within monitoredAttrs to be taken into account for below logic
foreach
(
$auditAttributes
as
$auditAttribute
=>
$attributeName
)
{
// NOTE: This is subject to change. This can always be a match if the state is present in the user but another
foreach
(
$monitoredAttrs
as
$monitoredAttr
)
{
// supannRessourceEtat is reached.
if
(
array_key_exists
(
$monitoredAttr
,
$attributeName
))
{
$matchingAttrs
[]
=
$monitoredAttr
;
array_push
(
$monitoredAttrs
,
'supannRessourceEtat'
);
}
}
}
// Verification if supannRessourceEtatDate with criteria from main tasks are matched.
if
(
$monitoredSupannResource
[
'resource'
][
0
]
!==
'NONE'
)
{
if
(
$this
->
verifySupannState
(
$monitoredSupannResource
,
$auditAttributes
))
{
// Simply create a match between audited and supannRessourceEtat, allowing further process below.
$matchingAttrs
[]
=
'supannRessourceEtat'
;
}
}
}
}
}
// Verify if there is a match between audited attributes and monitored attributes from main task.
$matchingAttrs
=
array_intersect
(
$auditAttributes
,
$monitoredAttrs
);
if
(
!
empty
(
$matchingAttrs
))
{
if
(
!
empty
(
$matchingAttrs
))
{
// Fill an array with UID of audited user and related matching attributes
// Fill an array with UID of audited user and related matching attributes
$notifications
[
$notificationsMainTaskName
][
'subTask'
][
$task
[
'cn'
][
0
]][
'attrs'
]
=
$matchingAttrs
;
$notifications
[
$notificationsMainTaskName
][
'subTask'
][
$task
[
'cn'
][
0
]][
'attrs'
]
=
$matchingAttrs
;
...
@@ -123,12 +135,15 @@ class Notifications implements EndpointInterface
...
@@ -123,12 +135,15 @@ class Notifications implements EndpointInterface
return
$result
;
return
$result
;
}
}
private
function
verifySupannState
(
array
$supannResource
,
string
$uid
):
bool
/**
* @param array $supannResource
* @param array $auditedAttrs
* @return bool
* Note : Create the supann format and check for a match.
*/
private
function
verifySupannState
(
array
$supannResource
,
array
$auditedAttrs
):
bool
{
{
$result
=
FALSE
;
$result
=
FALSE
;
// search the supannStates for the targeted uid by reusing getLdapTasks logic
$uidSupannStates
=
$this
->
gateway
->
getLdapTasks
(
'(objectClass=supannPerson)'
,
[
'supannRessourceEtat'
],
''
,
$uid
);
$this
->
gateway
->
unsetCountKeys
(
$uidSupannStates
);
//Construct Supann Resource State as string
//Construct Supann Resource State as string
if
(
!
empty
(
$supannResource
[
'subState'
][
0
]))
{
if
(
!
empty
(
$supannResource
[
'subState'
][
0
]))
{
...
@@ -137,15 +152,38 @@ class Notifications implements EndpointInterface
...
@@ -137,15 +152,38 @@ class Notifications implements EndpointInterface
$monitoredSupannState
=
'{'
.
$supannResource
[
'resource'
][
0
]
.
'}'
.
$supannResource
[
'state'
][
0
];
$monitoredSupannState
=
'{'
.
$supannResource
[
'resource'
][
0
]
.
'}'
.
$supannResource
[
'state'
][
0
];
}
}
foreach
(
$uidSupannStates
[
0
][
'supannressourceetat'
]
as
$supannResource
)
{
// Get all the values only of a multidimensional array.
if
(
$supannResource
===
$monitoredSupannState
)
{
$auditedValues
=
$this
->
getArrayValuesRecursive
(
$auditedAttrs
);
$result
=
TRUE
;
}
if
(
in_array
(
$monitoredSupannState
,
$auditedValues
))
{
$result
=
TRUE
;
}
else
{
$result
=
FALSE
;
}
}
return
$result
;
return
$result
;
}
}
/**
* @param $array
* @return array
* Note : simply return all values of a multi-dimensional array.
*/
public
function
getArrayValuesRecursive
(
$array
)
{
$values
=
[];
foreach
(
$array
as
$value
)
{
if
(
is_array
(
$value
))
{
// If value is an array, merge its values recursively
$values
=
array_merge
(
$values
,
$this
->
getArrayValuesRecursive
(
$value
));
}
else
{
// If value is not an array, add it to the result
$values
[]
=
$value
;
}
}
return
$values
;
}
/**
/**
* @param string $mainTaskDn
* @param string $mainTaskDn
* @return array
* @return array
...
@@ -193,7 +231,8 @@ class Notifications implements EndpointInterface
...
@@ -193,7 +231,8 @@ class Notifications implements EndpointInterface
*/
*/
protected
function
retrieveAuditedAttributes
(
array
$notificationTask
):
array
protected
function
retrieveAuditedAttributes
(
array
$notificationTask
):
array
{
{
$auditAttributes
=
[];
$auditAttributes
=
NULL
;
$auditInformation
=
NULL
;
// Retrieve audit data attributes from the list of references set in the sub-task
// Retrieve audit data attributes from the list of references set in the sub-task
if
(
!
empty
(
$notificationTask
[
'fdtasksgranularref'
]))
{
if
(
!
empty
(
$notificationTask
[
'fdtasksgranularref'
]))
{
...
@@ -204,13 +243,14 @@ class Notifications implements EndpointInterface
...
@@ -204,13 +243,14 @@ class Notifications implements EndpointInterface
$auditInformation
[]
=
$this
->
gateway
->
getLdapTasks
(
'(&(objectClass=fdAuditEvent))'
,
$auditInformation
[]
=
$this
->
gateway
->
getLdapTasks
(
'(&(objectClass=fdAuditEvent))'
,
[
'fdAuditAttributes'
],
''
,
$auditDN
);
[
'fdAuditAttributes'
],
''
,
$auditDN
);
}
}
// Again remove key: count retrieved from LDAP.
// Again remove key: count retrieved from LDAP.
$this
->
gateway
->
unsetCountKeys
(
$auditInformation
);
$this
->
gateway
->
unsetCountKeys
(
$auditInformation
);
// It is possible that an audit does not contain any attributes changes, condition is required.
// It is possible that an audit does not contain any attributes changes, condition is required.
foreach
(
$auditInformation
as
$attr
)
{
foreach
(
$auditInformation
as
$attr
)
{
if
(
!
empty
(
$attr
[
0
][
'fdauditattributes'
]))
{
if
(
!
empty
(
$attr
[
0
][
'fdauditattributes'
]))
{
// Clear and compact received results from above ldap search
// Clear and compact received results from above ldap search
$auditAttributes
=
$attr
[
0
][
'fdauditattributes'
];
$auditAttributes
[]
=
$attr
[
0
][
'fdauditattributes'
];
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets