Skip to content

Commit

Permalink
SHIBUI-2567: Fixes to work with OpenSaml when generating SP metadata …
Browse files Browse the repository at this point in the history
…via Pac4J (commit 1)
  • Loading branch information
chasegawa authored and credman committed Apr 23, 2023
1 parent 675c26d commit d0a1145
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public List<KeyInfoReference> getKeyInfoReferences() {
@Nonnull
@Override
public List<X509Data> getX509Datas() {
return Arrays.asList(this.xmlObjects.stream().filter(i -> i instanceof X509Data).toArray(X509Data[]::new));
return new X509ArrayList(this, Arrays.asList(this.xmlObjects.stream().filter(i -> i instanceof X509Data).toArray(X509Data[]::new)));
}

public void addX509Data(edu.internet2.tier.shibboleth.admin.ui.domain.X509Data x509Data) {
Expand Down Expand Up @@ -155,4 +155,19 @@ public List<XMLObject> getOrderedChildren() {

return children;
}
}

class X509ArrayList extends ArrayList<X509Data> {
private KeyInfo parentRef;

public X509ArrayList(KeyInfo ref, List<X509Data> addlist) {
super(addlist);
this.parentRef = ref;
}

@Override
public boolean add(X509Data data) {
parentRef.addX509Data((edu.internet2.tier.shibboleth.admin.ui.domain.X509Data) data);
return super.add(data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public List<X509SubjectName> getX509SubjectNames() {
@Nonnull
@Override
public List<X509Certificate> getX509Certificates() {
return new ArrayList<>(Arrays.asList(this.xmlObjects.stream().filter(i -> i instanceof org.opensaml.xmlsec.signature.X509Certificate).toArray(org.opensaml.xmlsec.signature.X509Certificate[]::new)));
return new X509CertificateArrayList(xmlObjects, Arrays.asList(this.xmlObjects.stream().filter(i -> i instanceof org.opensaml.xmlsec.signature.X509Certificate).toArray(org.opensaml.xmlsec.signature.X509Certificate[]::new)));
}

public void addX509Certificate(edu.internet2.tier.shibboleth.admin.ui.domain.X509Certificate x509Certificate) {
Expand Down Expand Up @@ -97,4 +97,18 @@ public List<XMLObject> getOrderedChildren() {

return children;
}
}

class X509CertificateArrayList extends ArrayList<X509Certificate> {
private final List<AbstractXMLObject> xmlObjects;

public X509CertificateArrayList(List<AbstractXMLObject> xmlObjects, List<X509Certificate> addList) {
super(addList);
this.xmlObjects = xmlObjects;
}

@Override
public boolean add(X509Certificate x509Certificate) {
return super.add(x509Certificate) && xmlObjects.add((AbstractXMLObject) x509Certificate);
}
}
36 changes: 0 additions & 36 deletions testbed/authentication/shibui/sp-metadata.xml

This file was deleted.

0 comments on commit d0a1145

Please sign in to comment.