Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
3cc613e9
Unverified
Commit
3cc613e9
authored
7 years ago
by
Tim van Dijen
Committed by
GitHub
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
PSR-2
/ whitespace
parent
86aa37ba
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/metarefresh/lib/ARP.php
+124
-74
124 additions, 74 deletions
modules/metarefresh/lib/ARP.php
with
124 additions
and
74 deletions
modules/metarefresh/lib/ARP.php
+
124
−
74
View file @
3cc613e9
...
@@ -3,97 +3,147 @@
...
@@ -3,97 +3,147 @@
* @author Andreas Åkre Solberg <andreas.solberg@uninett.no>
* @author Andreas Åkre Solberg <andreas.solberg@uninett.no>
* @package SimpleSAMLphp
* @package SimpleSAMLphp
*/
*/
class
sspmod_metarefresh_ARP
{
class
sspmod_metarefresh_ARP
{
/**
* @var array
*/
private
$metadata
;
private
$metadata
;
/**
private
$attributes
;
* @var array
private
$prefix
;
*/
private
$suffix
;
private
$attributes
;
/**
* @var string
*/
private
$prefix
;
/**
* @var
*/
private
$suffix
;
/**
/**
* Constructor
* Constructor
*
*
* @param
* @param array $metadata
* @param string $attributemap
* @param string $prefix
* @param string $suffix
*/
*/
public
function
__construct
(
$metadata
,
$attributemap
,
$prefix
,
$suffix
)
{
public
function
__construct
(
$metadata
,
$attributemap
,
$prefix
,
$suffix
)
$this
->
metadata
=
$metadata
;
{
$this
->
metadata
=
$metadata
;
$this
->
prefix
=
$prefix
;
$this
->
prefix
=
$prefix
;
$this
->
suffix
=
$suffix
;
$this
->
suffix
=
$suffix
;
if
(
isset
(
$attributemap
))
$this
->
loadAttributeMap
(
$attributemap
);
if
(
isset
(
$attributemap
))
{
}
$this
->
loadAttributeMap
(
$attributemap
);
}
}
private
function
loadAttributeMap
(
$attributemap
)
{
/**
$config
=
SimpleSAML_Configuration
::
getInstance
();
* @param string $attributemap
include
(
$config
->
getPathValue
(
'attributemap'
,
'attributemap/'
)
.
$attributemap
.
'.php'
);
*
$this
->
attributes
=
$attributemap
;
* @return void
*/
private
function
loadAttributeMap
(
$attributemap
)
{
$config
=
SimpleSAML_Configuration
::
getInstance
();
include
(
$config
->
getPathValue
(
'attributemap'
,
'attributemap/'
)
.
$attributemap
.
'.php'
);
// Note that $attributemap was a string before the call to include() and is now an array!
$this
->
attributes
=
$attributemap
;
}
}
private
function
surround
(
$name
)
{
/**
$ret
=
''
;
* @param string $name
if
(
!
empty
(
$this
->
prefix
))
$ret
.
=
$this
->
prefix
;
*
$ret
.
=
$name
;
* @return string
if
(
!
empty
(
$this
->
suffix
))
$ret
.
=
$this
->
suffix
;
*/
return
$ret
;
private
function
surround
(
$name
)
}
{
$ret
=
''
;
if
(
!
empty
(
$this
->
prefix
))
{
$ret
.
=
$this
->
prefix
;
}
$ret
.
=
$name
;
if
(
!
empty
(
$this
->
suffix
))
{
$ret
.
=
$this
->
suffix
;
}
return
$ret
;
}
private
function
getAttributeID
(
$name
)
{
/**
if
(
empty
(
$this
->
attributes
))
{
* @param string $name
return
$this
->
surround
(
$name
);
*
}
* @return string
if
(
array_key_exists
(
$name
,
$this
->
attributes
))
{
*/
return
$this
->
surround
(
$this
->
attributes
[
$name
]);
private
function
getAttributeID
(
$name
)
}
{
return
$this
->
surround
(
$name
);
if
(
empty
(
$this
->
attributes
))
{
}
return
$this
->
surround
(
$name
);
}
if
(
array_key_exists
(
$name
,
$this
->
attributes
))
{
return
$this
->
surround
(
$this
->
attributes
[
$name
]);
}
return
$this
->
surround
(
$name
);
}
public
function
getXML
()
{
/**
* @return string
$xml
=
'<?xml version="1.0" encoding="UTF-8"?>
*/
<AttributeFilterPolicyGroup id="urn:mace:funet.fi:haka:kalmar" xmlns="urn:mace:shibboleth:2.0:afp"
public
function
getXML
()
{
$xml
=
<<<MSG
<?xml version="1.0" encoding="UTF-8"?>
<AttributeFilterPolicyGroup id="urn:mace:funet.fi:haka:kalmar" xmlns="urn:mace:shibboleth:2.0:afp"
xmlns:basic="urn:mace:shibboleth:2.0:afp:mf:basic" xmlns:saml="urn:mace:shibboleth:2.0:afp:mf:saml"
xmlns:basic="urn:mace:shibboleth:2.0:afp:mf:basic" xmlns:saml="urn:mace:shibboleth:2.0:afp:mf:saml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="urn:mace:shibboleth:2.0:afp classpath:/schema/shibboleth-2.0-afp.xsd
xsi:schemaLocation="urn:mace:shibboleth:2.0:afp classpath:/schema/shibboleth-2.0-afp.xsd
urn:mace:shibboleth:2.0:afp:mf:basic classpath:/schema/shibboleth-2.0-afp-mf-basic.xsd
urn:mace:shibboleth:2.0:afp:mf:basic classpath:/schema/shibboleth-2.0-afp-mf-basic.xsd
urn:mace:shibboleth:2.0:afp:mf:saml classpath:/schema/shibboleth-2.0-afp-mf-saml.xsd">
urn:mace:shibboleth:2.0:afp:mf:saml classpath:/schema/shibboleth-2.0-afp-mf-saml.xsd">
'
;
MSG;
foreach
(
$this
->
metadata
AS
$metadata
)
{
$xml
.
=
$this
->
getEntryXML
(
$metadata
[
'metadata'
]);
}
$xml
.
=
'</AttributeFilterPolicyGroup>'
;
return
$xml
;
}
private
function
getEntryXML
(
$entry
)
{
foreach
(
$this
->
metadata
as
$metadata
)
{
$entityid
=
$entry
[
'entityid'
];
$xml
.
=
$this
->
getEntryXML
(
$metadata
[
'metadata'
]);
return
' <AttributeFilterPolicy id="'
.
$entityid
.
'">
}
<PolicyRequirementRule xsi:type="basic:AttributeRequesterString" value="'
.
$entityid
.
'" />
'
.
$this
->
getEntryXMLcontent
(
$entry
)
.
'
</AttributeFilterPolicy>
'
;
}
private
function
getEntryXMLcontent
(
$entry
)
{
$ids
=
array
();
if
(
!
array_key_exists
(
'attributes'
,
$entry
))
return
''
;
$ret
=
''
;
foreach
(
$entry
[
'attributes'
]
AS
$a
)
{
$ret
.
=
' <AttributeRule attributeID="'
.
$this
->
getAttributeID
(
$a
)
.
'">
<PermitValueRule xsi:type="basic:ANY" />
</AttributeRule>
'
;
}
return
$ret
;
}
}
$xml
.
=
'</AttributeFilterPolicyGroup>'
;
return
$xml
;
}
/**
* @param array $entry
*
* @return string
*/
private
function
getEntryXML
(
$entry
)
{
$entityid
=
$entry
[
'entityid'
];
return
' <AttributeFilterPolicy id="'
.
$entityid
.
'"><PolicyRequirementRule xsi:type="basic:AttributeRequesterString" value="'
.
$entityid
.
'" />'
.
$this
->
getEntryXMLcontent
(
$entry
)
.
'</AttributeFilterPolicy>'
;
}
/**
* @param array $entry
*
* @return string
*/
private
function
getEntryXMLcontent
(
$entry
)
{
if
(
!
array_key_exists
(
'attributes'
,
$entry
))
{
return
''
;
}
$ret
=
''
;
foreach
(
$entry
[
'attributes'
]
as
$a
)
{
$ret
.
=
' <AttributeRule attributeID="'
.
$this
->
getAttributeID
(
$a
)
.
'"><PermitValueRule xsi:type="basic:ANY" /></AttributeRule>'
;
}
return
$ret
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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