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
55a1030c
Commit
55a1030c
authored
9 years ago
by
Jaime Perez Crespo
Browse files
Options
Downloads
Patches
Plain Diff
Reformat and enhance the metadata converter page.
parent
10ce0acf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
templates/metadata-converter.php
+48
-36
48 additions, 36 deletions
templates/metadata-converter.php
www/admin/metadata-converter.php
+42
-54
42 additions, 54 deletions
www/admin/metadata-converter.php
with
90 additions
and
90 deletions
templates/metadata-converter.php
+
48
−
36
View file @
55a1030c
...
...
@@ -2,45 +2,57 @@
$this
->
data
[
'header'
]
=
$this
->
t
(
'metaconv_title'
);
$this
->
includeAtTemplateBase
(
'includes/header.php'
);
?>
<h2>
<?php
echo
$this
->
t
(
'metaconv_title'
);
?>
</h2>
<form
action=
"?"
method=
"post"
enctype=
"multipart/form-data"
>
<p>
<?php
echo
(
$this
->
t
(
'{admin:metaconv_xmlmetadata}'
));
?>
</p>
<p>
<textarea
rows=
"20"
cols=
"120"
name=
"xmldata"
>
<?php
echo
htmlspecialchars
(
$this
->
data
[
'xmldata'
]);
?>
</textarea>
</p>
<p>
<?php
echo
$this
->
t
(
'metaconv_selectfile'
);
?>
<input
type=
"file"
name=
"xmlfile"
/></p>
<p>
<input
type=
"submit"
value=
"
<?php
echo
$this
->
t
(
'metaconv_parse'
);
?>
"
/>
</p>
</form>
<h2>
<?php
echo
$this
->
t
(
'metaconv_title'
);
?>
</h2>
<form
action=
"?"
method=
"post"
enctype=
"multipart/form-data"
>
<p>
<?php
echo
(
$this
->
t
(
'{admin:metaconv_xmlmetadata}'
));
?>
</p>
<p>
<textarea
rows=
"20"
style=
"width: 100%"
name=
"xmldata"
>
<?php
echo
htmlspecialchars
(
$this
->
data
[
'xmldata'
]);
?>
</textarea>
</p>
<p>
<?php
echo
$this
->
t
(
'metaconv_selectfile'
);
?>
<input
type=
"file"
name=
"xmlfile"
/></p>
<p>
<input
type=
"submit"
value=
"
<?php
echo
$this
->
t
(
'metaconv_parse'
);
?>
"
class=
"btn"
/>
</p>
</form>
<?php
$output
=
$this
->
data
[
'output'
];
if
(
$output
!==
NULL
)
{
echo
(
'<h2>'
.
$this
->
t
(
'metaconv_converted'
)
.
'</h2>'
.
"
\n
"
);
foreach
(
$output
as
$type
=>
$text
)
{
if
(
$text
===
''
)
{
continue
;
}
echo
(
'<h3>'
.
htmlspecialchars
(
$type
)
.
'</h3>'
.
"
\n
"
);
echo
(
'<pre class="metadatabox">'
.
htmlspecialchars
(
$text
)
.
'</pre>'
.
"
\n
"
);
}
}
if
(
!
empty
(
$output
))
{
?>
<h2>
<?php
echo
$this
->
t
(
'metaconv_converted'
);
?>
</h2>
<?php
$i
=
1
;
foreach
(
$output
as
$type
=>
$text
)
{
if
(
$text
===
''
)
{
continue
;
}
?>
<h3>
<?php
echo
htmlspecialchars
(
$type
);
?>
</h3>
<div
class=
"metadatabox"
>
<button
data-clipboard-target=
"#metadata
<?php
echo
$i
;
?>
"
id=
"btn
<?php
echo
$i
;
?>
"
class=
"btn topright"
style=
"margin-right: 0.5em;"
>
<img
src=
"
<?php
echo
$this
->
data
[
'baseurlpath'
]
.
'/resources/icons/clipboard.svg'
;
?>
"
alt=
"Copy to clipboard"
>
</button>
<pre
id=
"metadata
<?php
echo
$i
;
?>
"
>
<?php
echo
htmlspecialchars
(
$text
);
?>
</pre>
</div>
<?php
$i
++
;
}
?>
<script
type=
"text/javascript"
>
<?php
for
(
$j
=
1
;
$j
<=
$i
;
$j
++
)
{
?>
var
clipboard
<?php
echo
$j
;
?>
=
new
Clipboard
(
'
#btn
<?php
echo
$j
;
?>
'
);
<?php
}
?>
</script>
<?php
}
$this
->
includeAtTemplateBase
(
'includes/footer.php'
);
This diff is collapsed.
Click to expand it.
www/admin/metadata-converter.php
+
42
−
54
View file @
55a1030c
<?php
require_once
(
'../_include.php'
);
/
* M
ake sure that the user has admin access rights
. */
/
/ m
ake sure that the user has admin access rights
SimpleSAML\Utils\Auth
::
requireAdmin
();
$config
=
SimpleSAML_Configuration
::
getInstance
();
if
(
!
empty
(
$_FILES
[
'xmlfile'
][
'tmp_name'
])
)
{
$xmldata
=
file_get_contents
(
$_FILES
[
'xmlfile'
][
'tmp_name'
]);
}
elseif
(
array_key_exists
(
'xmldata'
,
$_POST
)
)
{
$xmldata
=
$_POST
[
'xmldata'
];
if
(
!
empty
(
$_FILES
[
'xmlfile'
][
'tmp_name'
]))
{
$xmldata
=
file_get_contents
(
$_FILES
[
'xmlfile'
][
'tmp_name'
]);
}
elseif
(
array_key_exists
(
'xmldata'
,
$_POST
))
{
$xmldata
=
$_POST
[
'xmldata'
];
}
if
(
!
empty
(
$xmldata
)
)
{
\SimpleSAML\Utils\XML
::
checkSAMLMessage
(
$xmldata
,
'saml-meta'
);
$entities
=
SimpleSAML_Metadata_SAMLParser
::
parseDescriptorsString
(
$xmldata
);
/* Get all metadata for the entities. */
foreach
(
$entities
as
&
$entity
)
{
$entity
=
array
(
'shib13-sp-remote'
=>
$entity
->
getMetadata1xSP
(),
'shib13-idp-remote'
=>
$entity
->
getMetadata1xIdP
(),
'saml20-sp-remote'
=>
$entity
->
getMetadata20SP
(),
'saml20-idp-remote'
=>
$entity
->
getMetadata20IdP
(),
);
}
/* Transpose from $entities[entityid][type] to $output[type][entityid]. */
$output
=
SimpleSAML\Utils\Arrays
::
transpose
(
$entities
);
/* Merge all metadata of each type to a single string which should be
* added to the corresponding file.
*/
foreach
(
$output
as
$type
=>
&
$entities
)
{
$text
=
''
;
foreach
(
$entities
as
$entityId
=>
$entityMetadata
)
{
if
(
$entityMetadata
===
NULL
)
{
continue
;
}
/* Remove the entityDescriptor element because it is unused, and only
* makes the output harder to read.
*/
unset
(
$entityMetadata
[
'entityDescriptor'
]);
$text
.
=
'$metadata['
.
var_export
(
$entityId
,
TRUE
)
.
'] = '
.
var_export
(
$entityMetadata
,
TRUE
)
.
";
\n
"
;
}
$entities
=
$text
;
}
if
(
!
empty
(
$xmldata
))
{
\SimpleSAML\Utils\XML
::
checkSAMLMessage
(
$xmldata
,
'saml-meta'
);
$entities
=
SimpleSAML_Metadata_SAMLParser
::
parseDescriptorsString
(
$xmldata
);
// get all metadata for the entities
foreach
(
$entities
as
&
$entity
)
{
$entity
=
array
(
'shib13-sp-remote'
=>
$entity
->
getMetadata1xSP
(),
'shib13-idp-remote'
=>
$entity
->
getMetadata1xIdP
(),
'saml20-sp-remote'
=>
$entity
->
getMetadata20SP
(),
'saml20-idp-remote'
=>
$entity
->
getMetadata20IdP
(),
);
}
// transpose from $entities[entityid][type] to $output[type][entityid]
$output
=
SimpleSAML\Utils\Arrays
::
transpose
(
$entities
);
// merge all metadata of each type to a single string which should be added to the corresponding file
foreach
(
$output
as
$type
=>
&
$entities
)
{
$text
=
''
;
foreach
(
$entities
as
$entityId
=>
$entityMetadata
)
{
if
(
$entityMetadata
===
null
)
{
continue
;
}
// remove the entityDescriptor element because it is unused, and only makes the output harder to read
unset
(
$entityMetadata
[
'entityDescriptor'
]);
$text
.
=
'$metadata['
.
var_export
(
$entityId
,
true
)
.
'] = '
.
var_export
(
$entityMetadata
,
true
)
.
";
\n
"
;
}
$entities
=
$text
;
}
}
else
{
$xmldata
=
''
;
$output
=
array
();
$xmldata
=
''
;
$output
=
array
();
}
$template
=
new
SimpleSAML_XHTML_Template
(
$config
,
'metadata-converter.php'
,
'admin'
);
$template
->
data
[
'clipboard.js'
]
=
true
;
$template
->
data
[
'xmldata'
]
=
$xmldata
;
$template
->
data
[
'output'
]
=
$output
;
$template
->
show
();
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