Skip to content

Commit

Permalink
SHIBUI-2614
Browse files Browse the repository at this point in the history
Fixng a large number of places where the return lists included a number of null objects
  • Loading branch information
chasegawa committed Sep 28, 2023
1 parent 8a447a8 commit 3ac7ea2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public List<XMLObject> getUnknownXMLObjects() {
@Nonnull
@Override
public List<XMLObject> getUnknownXMLObjects(@Nonnull QName qName) {
return this.unknownXMLObjects.stream().filter(p -> p.getElementQName().equals(qName)).collect(Collectors.toList());
return this.unknownXMLObjects.stream().filter(p -> p != null && p.getElementQName().equals(qName)).collect(Collectors.toList());
}

public void addUnknownXMLObject(AbstractXMLObject xmlObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,9 +322,7 @@ public EntityDescriptorRepresentation createRepresentationFromDescriptor(org.ope

if (ed.getSPSSODescriptor("") != null && ed.getSPSSODescriptor("").getNameIDFormats().size() > 0) {
ServiceProviderSsoDescriptorRepresentation serviceProviderSsoDescriptorRepresentation = representation.getServiceProviderSsoDescriptor(true);
serviceProviderSsoDescriptorRepresentation.setNameIdFormats(
ed.getSPSSODescriptor("").getNameIDFormats().stream().map(p -> p.getURI()).collect(Collectors.toList())
);
serviceProviderSsoDescriptorRepresentation.setNameIdFormats(ed.getSPSSODescriptor("").getNameIDFormats().stream().filter(str -> str != null).map(p -> p.getURI()).collect(Collectors.toList()));
}

if (ed.isOidcProtocol()) {
Expand Down Expand Up @@ -391,11 +389,11 @@ public EntityDescriptorRepresentation createRepresentationFromDescriptor(org.ope
setupSecurityRepresentationFromEntityDescriptor(ed, representation);

// set up ACSs
if (ed.getSPSSODescriptor("") != null && ed.getSPSSODescriptor("").getAssertionConsumerServices().size() > 0) {
if (ed.getSPSSODescriptor("") != null && ed.getSPSSODescriptor("").getAssertionConsumerServices().stream().filter(val -> val != null).toList().size() > 0) {
if (representation.getAssertionConsumerServices() == null) {
representation.setAssertionConsumerServices(new ArrayList<>());
}
for (org.opensaml.saml.saml2.metadata.AssertionConsumerService assertionConsumerService : ed.getSPSSODescriptor("").getAssertionConsumerServices()) {
for (org.opensaml.saml.saml2.metadata.AssertionConsumerService assertionConsumerService : ed.getSPSSODescriptor("").getAssertionConsumerServices().stream().filter(val -> val != null).toList()) {
AssertionConsumerServiceRepresentation assertionConsumerServiceRepresentation = new AssertionConsumerServiceRepresentation();

Boolean isDefault = assertionConsumerService.isDefault();
Expand All @@ -408,8 +406,8 @@ public EntityDescriptorRepresentation createRepresentationFromDescriptor(org.ope
}

// set up logout endpoints
if (ed.getSPSSODescriptor("") != null && !ed.getSPSSODescriptor("").getSingleLogoutServices().isEmpty()) {
for (org.opensaml.saml.saml2.metadata.SingleLogoutService singleLogoutService : ed.getSPSSODescriptor("").getSingleLogoutServices()) {
if (ed.getSPSSODescriptor("") != null && !ed.getSPSSODescriptor("").getSingleLogoutServices().stream().filter(val -> val != null).toList().isEmpty()) {
for (org.opensaml.saml.saml2.metadata.SingleLogoutService singleLogoutService : ed.getSPSSODescriptor("").getSingleLogoutServices().stream().filter(val -> val != null).toList()) {
LogoutEndpointRepresentation logoutEndpointRepresentation = new LogoutEndpointRepresentation();
logoutEndpointRepresentation.setBindingType(singleLogoutService.getBinding());
logoutEndpointRepresentation.setUrl(singleLogoutService.getLocation());
Expand All @@ -422,7 +420,7 @@ public EntityDescriptorRepresentation createRepresentationFromDescriptor(org.ope
// we have entity attributes (hopefully), so should have overrides
Map<String, Object> relyingPartyOverrides = new HashMap<>();

for (org.opensaml.saml.saml2.core.Attribute attribute : ((EntityAttributes) ed.getExtensions().getUnknownXMLObjects(EntityAttributes.DEFAULT_ELEMENT_NAME).get(0)).getAttributes()) {
for (org.opensaml.saml.saml2.core.Attribute attribute : ((EntityAttributes) ed.getExtensions().getUnknownXMLObjects(EntityAttributes.DEFAULT_ELEMENT_NAME).get(0)).getAttributes().stream().filter(val -> val != null).toList()) {
Attribute jpaAttribute = (Attribute) attribute;

if (jpaAttribute.getName().equals(MDDCConstants.RELEASE_ATTRIBUTES)) {
Expand Down Expand Up @@ -609,7 +607,7 @@ private void setupSecurityRepresentationFromEntityDescriptor(EntityDescriptor ed
representation.setSecurityInfo(securityInfoRepresentation);
}

for (org.opensaml.saml.saml2.metadata.KeyDescriptor keyDescriptor : ed.getSPSSODescriptor("").getKeyDescriptors()) {
for (org.opensaml.saml.saml2.metadata.KeyDescriptor keyDescriptor : ed.getSPSSODescriptor("").getKeyDescriptors().stream().filter(val -> val != null).toList()) {
KeyDescriptorRepresentation keyDescriptorRep = new KeyDescriptorRepresentation();
String name = keyDescriptor.getKeyInfo().getKeyNames().size() > 0 ? keyDescriptor.getKeyInfo().getKeyNames().get(0).getValue() : null;
name = name == null ? ((KeyDescriptor)keyDescriptor).getName() : name;
Expand Down

0 comments on commit 3ac7ea2

Please sign in to comment.