How to parse the xml file without going to admin/metadata-converter.php page

2,227 views
Skip to first unread message

Banothu Ramesh Naik

unread,
Feb 27, 2018, 12:06:21 PM2/27/18
to SimpleSAMLphp
I am using simplesamlphp to connect with my IDP from SP. But for every new integration I need to login to admin and parse the xml and set configurations.

So is there any way to parse the xml file as per our requirement array without going to admin/metadata-converter.php page.

I want to parse xml file from SP by uploading xml file and get parsed output.

Please help me is  it possible??

Peter Schober

unread,
Feb 28, 2018, 8:14:15 AM2/28/18
to SimpleSAMLphp
* Banothu Ramesh Naik <rames...@darwinbox.io> [2018-02-27 18:06]:
> I want to parse xml file from SP by uploading xml file and get
> parsed output.

SimpleSAMLphp itself only processes its own "PHP arrays metadata".
If you need to process SAML 2.0 Metadata (XML) there's the metarefresh
module for that.
If that doesn't suit your needs then you'd probably have to roll your
own. Or use some other tools to aggregate and persist metadata.
-peter

Banothu Ramesh Naik

unread,
Feb 28, 2018, 8:18:56 AM2/28/18
to SimpleSAMLphp
Hi Peter,

Thanks for responding 
Module metadata refresh won't resolve my problem. Okay, I will explore on own if another tool to do this.

Peter Schober

unread,
Feb 28, 2018, 8:54:10 AM2/28/18
to SimpleSAMLphp
* Banothu Ramesh Naik <rames...@darwinbox.io> [2018-02-28 14:19]:
> Module metadata refresh won't resolve my problem. Okay, I will explore on
> own if another tool to do this.

If you could share details about what you're trying to achieve maybe
someone can suggest a modified workflow that *is* covered by the
available tools.

> I want to parse xml file from SP by uploading xml file and get
> parsed output.

That's literally what the provided converter in SSP does.
Are you saying you want that to be done within your own application?
IIRC there's also a dev list for SSP so if you wanted to make use of
the API for your own purposes maybe that's a better place to ask,
then.

-peter

Banothu Ramesh Naik

unread,
Feb 28, 2018, 9:04:28 AM2/28/18
to SimpleSAMLphp
Yes that need to be done in my application. 

My task flow is like this
1. Take the XML file from the client and then upload it to admin/metadata-converter.php page and get the parsed metadata value.
2. Take the parsed metadata value and configure according to it.

For the first step, I have to go to the page and upload XML and then parse it to get parsed metadata array (Manual). 
I want to automate this step by giving an option to upload client XML file in my application and then parse that XML file as like metadata array and do the second step. I can automate the second step but not able to get the first step.

Anyone, please help me!

Jaime Perez Crespo

unread,
Feb 28, 2018, 9:49:26 AM2/28/18
to simple...@googlegroups.com
Hi Banothu,
You can always look at the metadata-converter.php script and replicate its behaviour by using SimpleSAMLphp’s internal API:

https://github.com/simplesamlphp/simplesamlphp/blob/simplesamlphp-1.15/www/admin/metadata-converter.php#L16-L48


Jaime Pérez
UNINETT / Feide

jaime...@uninett.no
jaime...@protonmail.com
9A08 EA20 E062 70B4 616B 43E3 562A FE3A 6293 62C2

"Two roads diverged in a wood, and I, I took the one less traveled by, and that has made all the difference."
- Robert Frost

Patrick Henry

unread,
Nov 22, 2023, 9:06:46 AM11/22/23
to SimpleSAMLphp
I am having the same problem as Banothu.

We're using Simple SAML 2.0.

Since we implemented SAML2.0, Microsoft has updated the https://login.microsoftonline.com/8f9bd40b-986b-4d06-ad29-9c0800ce5047/federationmetadata/2007-06/federationmetadata.xml at least 4 times.

This means, we have had to manually parse the updated  federationmetadata.xml via https://itrack.buckeyemountain.com/sml/admin/metadata-converter.php to generate the new saml20-idp-remote file.

Is there a way to automate this? It seems silly that Microsoft keeps changing the federationmetadata.xml. And we have to scramble early in the AM to generate a new parsed  saml20-idp-remote.

Thank you

Kevin Sandy

unread,
Nov 22, 2023, 10:21:15 AM11/22/23
to simple...@googlegroups.com
I imagine what you want is the metarefresh module.


Alternatively, if you really just want to avoid manually converting the file, you can use an XML file directly by adding an item to your metadata.sources with type of xml.


-- kevin

--
This is a mailing list for users of SimpleSAMLphp, not a support service. If you are willing to buy commercial support, please take a look here:
 
https://simplesamlphp.org/support
 
Before sending your question, make sure it is related to SimpleSAMLphp, and not your web server's configuration or any other third-party software. This mailing list cannot help with software that uses SimpleSAMLphp, only regarding SimpleSAMLphp itself.
 
Make sure to read the documentation:
 
https://simplesamlphp.org/docs/stable/
 
If you have an issue with SimpleSAMLphp that you cannot resolve and reading the documentation doesn't help, you are more than welcome to ask here for help. Subscribe to the list and send an email with your question. However, you will be expected to comply with some minimum, common sense standards in your questions. Please read this carefully:
 
http://catb.org/~esr/faqs/smart-questions.html
---
You received this message because you are subscribed to the Google Groups "SimpleSAMLphp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to simplesamlph...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/simplesamlphp/1810149f-6242-400f-8eb5-1225b8aa9fben%40googlegroups.com.

Slawek Naczynski

unread,
Dec 6, 2023, 10:48:27 AM12/6/23
to SimpleSAMLphp
That should get you started:

<?php
require_once(__DIR__ . '/simplesamlphp/_include.php');

$xmldata = trim($_POST['xml_metadata']);
if (!empty($xmldata)) {
$xmlUtils = new \SimpleSAML\Utils\XML();
$xmlUtils->checkSAMLMessage($xmldata, 'saml-meta');
$entities = \SimpleSAML\Metadata\SAMLParser::parseDescriptorsString($xmldata);

// get all metadata for the entities
foreach ($entities as &$entity) {
$entity = [
'saml20-idp-remote' => $entity->getMetadata20IdP(),
];
}

// transpose from $entities[entityid][type] to $output[type][entityid]
$arrayUtils = new \SimpleSAML\Utils\Arrays();
$output = $arrayUtils->transpose($entities);

if(isset($output['saml20-idp-remote']) && count($output['saml20-idp-remote']) === 1){
$finalOutput = '';
foreach($output['saml20-idp-remote'] as $oneMetadata){
// If there is entityDescriptor then uset it
if(isset($oneMetadata['entityDescriptor'])){
unset($oneMetadata['entityDescriptor']);
}

// If there is "expire" in the metadata remove it as we can forget to remove it and it can expire in the future causing issues
if(isset($oneMetadata['expire'])){
unset($oneMetadata['expire']);
}

$finalOutput = $oneMetadata;
}

print_r($finalOutput);
Reply all
Reply to author
Forward
0 new messages