Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing the mdUI Info #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions samlmetajs/mdreader.js
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,6 @@ isHTTPS = function(string) {

parseFromString = function(xmlstring) {

var doc = null;
var result = {};
var entitydescriptor = null;

Expand Down Expand Up @@ -1317,7 +1316,6 @@ parseFromString = function(xmlstring) {
if (xmlstring) {
try {
validateXML(xmlstring);
doc = getDoc(xmlstring);
entitydescriptor = parseEntityDescriptor(getDoc(xmlstring));
} catch (e) {
console.log(e.message);
Expand All @@ -1328,24 +1326,30 @@ parseFromString = function(xmlstring) {
entitydescriptor = parseEntityDescriptor(getNewDoc());
}


if (entitydescriptor.name) {
// Everthing is OK with the name. No need to override.
} else if (entitydescriptor.saml2sp && entitydescriptor.saml2sp.mdui && entitydescriptor.saml2sp.mdui.name) {
entitydescriptor.name = entitydescriptor.saml2sp.mdui.name;
} else if (entitydescriptor.saml2sp && entitydescriptor.saml2sp.acs && entitydescriptor.saml2sp.acs.name) {
entitydescriptor.name = entitydescriptor.saml2sp.acs.name;
if (!entitydescriptor.name) {
if (entitydescriptor.hasMDUIProperty('name')) {
mduiAux = entitydescriptor.getProperty('mdui');
entitydescriptor.name = mduiAux.name;
} else if (entitydescriptor.hasProperty('acs')) {
mduiAux = entitydescriptor.getProperty('acs');
if (hasProp(mduiAux, 'name')) {
entitydescriptor.name = mduiAux.name;
}
}
}

if (entitydescriptor.descr) {
// Everthing is OK with the name. No need to override.
} else if (entitydescriptor.saml2sp && entitydescriptor.saml2sp.mdui && entitydescriptor.saml2sp.mdui.descr) {
entitydescriptor.descr = entitydescriptor.saml2sp.mdui.descr;
} else if (entitydescriptor.saml2sp && entitydescriptor.saml2sp.acs && entitydescriptor.saml2sp.acs.descr) {
entitydescriptor.descr = entitydescriptor.saml2sp.acs.descr;
if (!entitydescriptor.descr) {
if (entitydescriptor.hasMDUIProperty('descr')) {
mduiAux = entitydescriptor.getProperty('mdui');
entitydescriptor.descr = mduiAux.descr;
} else if (entitydescriptor.hasProperty('acs')) {
mduiAux = entitydescriptor.getProperty('acs');
if (hasProp(mduiAux, 'descr')) {
entitydescriptor.descr = mduiAux.descr;
}
}
}


if (!entitydescriptor.name) {
processTest(new TestResult('noentityname', 'The entity did not include a name', 0, 1));
}
Expand Down
31 changes: 18 additions & 13 deletions samlmetajs/samlmeta.plugin.info.js
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,12 @@
},

fromXML: function (entitydescriptor) {
var l;
var entityNode = entitydescriptor.saml2sp,
l;

if (entityNode === undefined) {
entityNode = entitydescriptor.saml2idp;
}

UI.clearInfoname();
if (entitydescriptor.name) {
Expand All @@ -346,36 +351,36 @@

UI.clearInfologo();
if (entitydescriptor.hasLogo()) {
for (l in entitydescriptor.saml2sp.mdui.logo) {
if (entitydescriptor.saml2sp.mdui.logo.hasOwnProperty(l)) {
UI.addInfologo(l, entitydescriptor.saml2sp.mdui.logo[l]);
for (l in entityNode.mdui.logo) {
if (entityNode.mdui.logo.hasOwnProperty(l)) {
UI.addInfologo(l, entityNode.mdui.logo[l]);
}
}
}

UI.clearInfokeywords();
if (entitydescriptor.hasKeywords()) {
for (l in entitydescriptor.saml2sp.mdui.keywords) {
if (entitydescriptor.saml2sp.mdui.keywords.hasOwnProperty(l)) {
UI.addInfokeywords(l, entitydescriptor.saml2sp.mdui.keywords[l]);
for (l in entityNode.mdui.keywords) {
if (entityNode.mdui.keywords.hasOwnProperty(l)) {
UI.addInfokeywords(l, entityNode.mdui.keywords[l]);
}
}
}

UI.clearInformationURL();
if (entitydescriptor.hasInformationURL()) {
for (l in entitydescriptor.saml2sp.mdui.informationURL) {
if (entitydescriptor.saml2sp.mdui.informationURL.hasOwnProperty(l)) {
UI.addInformationURL(l, entitydescriptor.saml2sp.mdui.informationURL[l]);
for (l in entityNode.mdui.informationURL) {
if (entityNode.mdui.informationURL.hasOwnProperty(l)) {
UI.addInformationURL(l, entityNode.mdui.informationURL[l]);
}
}
}

UI.clearPrivacyStatementURL();
if (entitydescriptor.hasPrivacyStatementURL()) {
for (l in entitydescriptor.saml2sp.mdui.privacyStatementURL) {
if (entitydescriptor.saml2sp.mdui.privacyStatementURL.hasOwnProperty(l)) {
UI.addPrivacyStatementURL(l, entitydescriptor.saml2sp.mdui.privacyStatementURL[l]);
for (l in entityNode.mdui.privacyStatementURL) {
if (entityNode.mdui.privacyStatementURL.hasOwnProperty(l)) {
UI.addPrivacyStatementURL(l, entityNode.mdui.privacyStatementURL[l]);
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion samlmetajs/samlmeta.plugin.location.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,20 @@

if (entitydescriptor.hasLocation()) {
location = entitydescriptor.getLocation();
UI.setLocation(location);
spl = location.split(',');
if (spl.length !== 2) {
spl = location.split('/');
if (spl.length !== 2) {
// Bad location data
return;
}
}
latLng = new google.maps.LatLng(spl[0], spl[1]);

location = latLng.toString();
location = location.substring(1, location.length - 1);

UI.setLocation(location);
map.panTo(latLng);
mapmarker.setPosition(latLng);
UI.geocodePosition(latLng);
Expand Down