77 parent::__construct(
$config, $reserved);
79 if (array_key_exists(
'includeValues',
$config)) {
80 if (!is_bool(
$config[
'includeValues'])) {
82 'Consent: includeValues must be boolean. '.
83 var_export(
$config[
'includeValues'],
true).
' given.' 86 $this->_includeValues =
$config[
'includeValues'];
89 if (array_key_exists(
'checked',
$config)) {
90 if (!is_bool(
$config[
'checked'])) {
92 'Consent: checked must be boolean. '.
93 var_export(
$config[
'checked'],
true).
' given.' 96 $this->_checked =
$config[
'checked'];
99 if (array_key_exists(
'focus',
$config)) {
100 if (!in_array(
$config[
'focus'], array(
'yes',
'no'),
true)) {
102 'Consent: focus must be a string with values `yes` or `no`. '.
103 var_export(
$config[
'focus'],
true).
' given.' 106 $this->_focus =
$config[
'focus'];
109 if (array_key_exists(
'hiddenAttributes',
$config)) {
110 if (!is_array(
$config[
'hiddenAttributes'])) {
112 'Consent: hiddenAttributes must be an array. '.
113 var_export(
$config[
'hiddenAttributes'],
true).
' given.' 116 $this->_hiddenAttributes =
$config[
'hiddenAttributes'];
119 if (array_key_exists(
'attributes.exclude',
$config)) {
120 if (!is_array(
$config[
'attributes.exclude'])) {
122 'Consent: attributes.exclude must be an array. '.
123 var_export(
$config[
'attributes.exclude'],
true).
' given.' 126 $this->_noconsentattributes =
$config[
'attributes.exclude'];
127 } elseif (array_key_exists(
'noconsentattributes',
$config)) {
129 if (!is_array(
$config[
'noconsentattributes'])) {
131 'Consent: noconsentattributes must be an array. '.
132 var_export(
$config[
'noconsentattributes'],
true).
' given.' 135 $this->_noconsentattributes =
$config[
'noconsentattributes'];
138 if (array_key_exists(
'store',
$config)) {
143 'Consent: Could not create consent storage: '.
149 if (array_key_exists(
'showNoConsentAboutService',
$config)) {
150 if (!is_bool(
$config[
'showNoConsentAboutService'])) {
153 $this->_showNoConsentAboutService =
$config[
'showNoConsentAboutService'];
168 if (is_array($option)) {
170 if (count($option) === count($option, COUNT_RECURSIVE)) {
172 return in_array(
$entityId, $option,
true);
176 if (in_array(
$entityId, $option,
true)) {
181 foreach ($option as $optionToTest) {
182 if (!is_array($optionToTest)) {
186 if (!array_key_exists(
'type', $optionToTest)) {
191 if ($optionToTest[
'type'] ===
'regex') {
194 if (!array_key_exists(
'pattern', $optionToTest)) {
198 if (preg_match($optionToTest[
'pattern'],
$entityId) === 1) {
210 return (
boolean) $option;
230 assert(array_key_exists(
'UserID',
$state));
231 assert(array_key_exists(
'Destination',
$state));
232 assert(array_key_exists(
'entityid',
$state[
'Destination']));
233 assert(array_key_exists(
'metadata-set',
$state[
'Destination']));
234 assert(array_key_exists(
'entityid',
$state[
'Source']));
235 assert(array_key_exists(
'metadata-set',
$state[
'Source']));
248 if (isset(
$state[
'saml:sp:IdP'])) {
257 if (isset(
$state[
'Source'][
'consent.disable']) &&
264 if (isset(
$state[
'Destination'][
'consent.disable']) &&
272 if ($this->_store !== null) {
279 if (in_array($attrkey, $this->_noconsentattributes,
true)) {
290 $attributeSet = self::getAttributeHash(
$attributes, $this->_includeValues);
293 'Consent: hasConsent() ['.$userId.
'|'.$targetedId.
'|'.
298 if ($this->_store->hasConsent($userId, $targetedId, $attributeSet)) {
309 $state[
'consent:store.userId'] = $userId;
310 $state[
'consent:store.destination'] = $targetedId;
311 $state[
'consent:store.attributeSet'] = $attributeSet;
329 if (isset(
$state[
'isPassive']) &&
$state[
'isPassive'] ===
true) {
332 \
SAML2\Constants::STATUS_REQUESTER,
333 'Unable to give consent on passive request.' 386 if ($includeValues) {
395 $hashBase = implode(
'|', $names);
397 return hash(
'sha1', $hashBase);
static getTargetedID($userid, $source, $destination)
Generate a unique targeted identifier.
__construct($config, $reserved)
Initialize consent filter.
static getHashedUserID($userid, $source)
Generate a unique identifier of the user.
if(empty($userids)) $userid
if(!array_key_exists('StateId', $_REQUEST)) $id
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
$metadata['__DYNAMIC:1__']
static getModuleURL($resource, array $parameters=array())
Get absolute URL to a specified module resource.
process(&$state)
Process a authentication response.
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Attribute-related utility methods.
static getAttributeHash($attributes, $includeValues=false)
Generate unique identifier for attributes.
if(array_key_exists('yes', $_REQUEST)) $attributes
$_showNoConsentAboutService
static parseStoreConfig($config)
Parse consent storage configuration.
hash(StreamInterface $stream, $algo, $rawOutput=false)
Calculate a hash of a Stream.
static checkDisable($option, $entityId)
Helper function to check whether consent is disabled.
static saveState(&$state, $stage, $rawId=false)
Save the state.
static log($event, array $data=array())
Notify about an event.