Skip to content

Commit

Permalink
SHIBUI-2268
Browse files Browse the repository at this point in the history
intermediate checkin - tests not correct
  • Loading branch information
chasegawa committed Jul 12, 2022
1 parent fdb60d9 commit c7cd06f
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import edu.internet2.tier.shibboleth.admin.ui.domain.filters.NameIdFormatFilter
import edu.internet2.tier.shibboleth.admin.ui.domain.filters.RequiredValidUntilFilter
import edu.internet2.tier.shibboleth.admin.ui.domain.filters.SignatureValidationFilter
import edu.internet2.tier.shibboleth.admin.ui.domain.filters.algorithm.AlgorithmFilter
import edu.internet2.tier.shibboleth.admin.ui.domain.filters.algorithm.Entity
import edu.internet2.tier.shibboleth.admin.ui.domain.filters.opensaml.OpenSamlNameIdFormatFilter
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.DynamicHttpMetadataResolver
import edu.internet2.tier.shibboleth.admin.ui.domain.resolvers.FileBackedHttpMetadataResolver
Expand Down Expand Up @@ -90,11 +91,26 @@ class JPAMetadataResolverServiceImpl implements MetadataResolverService {
}

void constructXmlNodeForFilter(AlgorithmFilter filter, def markupBuilderDelegate) {
if (!filter.isFilterEnabled()) { return }
markupBuilderDelegate.MetadataFilter('xsi:type': 'Algorithm') {
// TODO: enhance. currently this does weird things with namespaces
if (!filter.isFilterEnabled()) {
return
}
markupBuilderDelegate.MetadataFilter(
'xsi:type': 'Algorithm',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xsi:schemaLocation': 'urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd urn:mace:shibboleth:2.0:security http://shibboleth.net/schema/idp/shibboleth-security.xsd urn:oasis:names:tc:SAML:2.0:assertion http://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd',
'xmlns:md': 'urn:oasis:names:tc:SAML:2.0:metadata',
'xmlns': 'urn:mace:shibboleth:2.0:metadata',
'xmlns:security': 'urn:mace:shibboleth:2.0:security',
'xmlns:saml2': 'urn:oasis:names:tc:SAML:2.0:assertion'
) {
filter.unknownXMLObjects.each { xmlObject ->
mkp.yieldUnescaped(openSamlObjects.marshalToXmlString(xmlObject, false))
{
if (xmlObject instanceof Entity) {
Entity(xmlObject.getValue())
} else {
mkp.yieldUnescaped(openSamlObjects.marshalToXmlString(xmlObject, false))
}
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,6 @@ public org.opensaml.xmlsec.encryption.OAEPparams getOAEPparams() {
public void setOAEPparams(@Nullable org.opensaml.xmlsec.encryption.OAEPparams oaePparams) {
this.oaePparams = oaePparams;
}
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class JPAXMLObjectProviderInitializerForTest extends AbstractXMLObjectProviderIn
@Override
protected String[] getConfigResources() {
return new String[]{
"/jpa-saml2-metadata-config.xml",
"/jpa-saml2-metadata-config.xml"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import edu.internet2.tier.shibboleth.admin.ui.AbstractBaseDataJpaTest
import edu.internet2.tier.shibboleth.admin.ui.configuration.PlaceholderResolverComponentsConfiguration
import edu.internet2.tier.shibboleth.admin.ui.configuration.ShibUIConfiguration
import edu.internet2.tier.shibboleth.admin.ui.domain.EncryptionMethod
import edu.internet2.tier.shibboleth.admin.ui.domain.EncryptionMethodBuilder
import edu.internet2.tier.shibboleth.admin.ui.domain.filters.EntityAttributesFilter
import edu.internet2.tier.shibboleth.admin.ui.domain.filters.EntityAttributesFilterTarget
import edu.internet2.tier.shibboleth.admin.ui.domain.filters.MetadataFilter
Expand All @@ -26,6 +27,7 @@ import groovy.xml.MarkupBuilder
import net.shibboleth.ext.spring.resource.ResourceHelper
import net.shibboleth.utilities.java.support.resolver.CriteriaSet
import org.opensaml.core.criterion.EntityIdCriterion
import org.opensaml.saml.common.xml.SAMLConstants
import org.opensaml.saml.metadata.resolver.MetadataResolver
import org.opensaml.saml.metadata.resolver.filter.MetadataFilterChain
import org.opensaml.saml.metadata.resolver.impl.ResourceBackedMetadataResolver
Expand Down Expand Up @@ -143,10 +145,14 @@ class JPAMetadataResolverServiceImplTests extends AbstractBaseDataJpaTest {
def 'test generating AlgorithmFilter xml snippet'() {
given:
def filter = TestObjectGenerator.algorithmFilter()
EncryptionMethod encryptionMethod = new EncryptionMethod()
EncryptionMethod encryptionMethod = new EncryptionMethod()
encryptionMethod.setElementLocalName(EncryptionMethod.DEFAULT_ELEMENT_LOCAL_NAME)
encryptionMethod.setNamespacePrefix(SAMLConstants.SAML20MD_PREFIX)
encryptionMethod.setNamespaceURI(SAMLConstants.SAML20MD_NS)
encryptionMethod.setSchemaLocation(SAMLConstants.SAML20MD_SCHEMA_LOCATION)
encryptionMethod.setAlgorithm("http://www.w3.org/2001/04/xmlenc#aes128-cbc")
encryptionMethod.setElementLocalName("EncryptionMethod")
filter.addUnknownXMLObject(encryptionMethod)

Entity entity = new Entity()
entity.setValue("https://broken.example.org/sp")
filter.addUnknownXMLObject(entity)
Expand Down
8 changes: 7 additions & 1 deletion backend/src/test/resources/conf/2268-simple.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<MetadataProvider id='ShibbolethMetadata' xmlns='urn:mace:shibboleth:2.0:metadata' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='ChainingMetadataProvider' xsi:schemaLocation='urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd urn:mace:shibboleth:2.0:resource http://shibboleth.net/schema/idp/shibboleth-resource.xsd urn:mace:shibboleth:2.0:security http://shibboleth.net/schema/idp/shibboleth-security.xsd urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd urn:oasis:names:tc:SAML:2.0:assertion http://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd'>
<MetadataProvider id='ShibbolethMetadata' xmlns='urn:mace:shibboleth:2.0:metadata'
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:type='ChainingMetadataProvider'
xsi:schemaLocation='urn:mace:shibboleth:2.0:metadata http://shibboleth.net/schema/idp/shibboleth-metadata.xsd
urn:mace:shibboleth:2.0:resource http://shibboleth.net/schema/idp/shibboleth-resource.xsd
urn:mace:shibboleth:2.0:security http://shibboleth.net/schema/idp/shibboleth-security.xsd
urn:oasis:names:tc:SAML:2.0:metadata http://docs.oasis-open.org/security/saml/v2.0/saml-schema-metadata-2.0.xsd
urn:oasis:names:tc:SAML:2.0:assertion http://docs.oasis-open.org/security/saml/v2.0/saml-schema-assertion-2.0.xsd'>
<MetadataFilter xsi:type='Algorithm'>
<md:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc" />
<Entity>https://broken.example.org/sp</Entity>
Expand Down

0 comments on commit c7cd06f

Please sign in to comment.