|
@@ -1,5 +1,5 @@
|
|
/*
|
|
/*
|
|
- * Copyright 2002-2022 the original author or authors.
|
|
|
|
|
|
+ * Copyright 2002-2023 the original author or authors.
|
|
*
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* you may not use this file except in compliance with the License.
|
|
@@ -72,6 +72,8 @@ public final class OpenSamlMetadataResolver implements Saml2MetadataResolver {
|
|
private Consumer<EntityDescriptorParameters> entityDescriptorCustomizer = (parameters) -> {
|
|
private Consumer<EntityDescriptorParameters> entityDescriptorCustomizer = (parameters) -> {
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ private boolean usePrettyPrint = true;
|
|
|
|
+
|
|
public OpenSamlMetadataResolver() {
|
|
public OpenSamlMetadataResolver() {
|
|
this.entityDescriptorMarshaller = (EntityDescriptorMarshaller) XMLObjectProviderRegistrySupport
|
|
this.entityDescriptorMarshaller = (EntityDescriptorMarshaller) XMLObjectProviderRegistrySupport
|
|
.getMarshallerFactory()
|
|
.getMarshallerFactory()
|
|
@@ -123,6 +125,15 @@ public final class OpenSamlMetadataResolver implements Saml2MetadataResolver {
|
|
this.entityDescriptorCustomizer = entityDescriptorCustomizer;
|
|
this.entityDescriptorCustomizer = entityDescriptorCustomizer;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Configure whether to pretty-print the metadata XML. This can be helpful when
|
|
|
|
+ * signing the metadata payload.
|
|
|
|
+ * @since 6.2
|
|
|
|
+ **/
|
|
|
|
+ public void setUsePrettyPrint(boolean usePrettyPrint) {
|
|
|
|
+ this.usePrettyPrint = usePrettyPrint;
|
|
|
|
+ }
|
|
|
|
+
|
|
private SPSSODescriptor buildSpSsoDescriptor(RelyingPartyRegistration registration) {
|
|
private SPSSODescriptor buildSpSsoDescriptor(RelyingPartyRegistration registration) {
|
|
SPSSODescriptor spSsoDescriptor = build(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
|
|
SPSSODescriptor spSsoDescriptor = build(SPSSODescriptor.DEFAULT_ELEMENT_NAME);
|
|
spSsoDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS);
|
|
spSsoDescriptor.addSupportedProtocol(SAMLConstants.SAML20P_NS);
|
|
@@ -204,7 +215,10 @@ public final class OpenSamlMetadataResolver implements Saml2MetadataResolver {
|
|
private String serialize(EntityDescriptor entityDescriptor) {
|
|
private String serialize(EntityDescriptor entityDescriptor) {
|
|
try {
|
|
try {
|
|
Element element = this.entityDescriptorMarshaller.marshall(entityDescriptor);
|
|
Element element = this.entityDescriptorMarshaller.marshall(entityDescriptor);
|
|
- return SerializeSupport.prettyPrintXML(element);
|
|
|
|
|
|
+ if (this.usePrettyPrint) {
|
|
|
|
+ return SerializeSupport.prettyPrintXML(element);
|
|
|
|
+ }
|
|
|
|
+ return SerializeSupport.nodeToString(element);
|
|
}
|
|
}
|
|
catch (Exception ex) {
|
|
catch (Exception ex) {
|
|
throw new Saml2Exception(ex);
|
|
throw new Saml2Exception(ex);
|
|
@@ -214,7 +228,10 @@ public final class OpenSamlMetadataResolver implements Saml2MetadataResolver {
|
|
private String serialize(EntitiesDescriptor entities) {
|
|
private String serialize(EntitiesDescriptor entities) {
|
|
try {
|
|
try {
|
|
Element element = this.entitiesDescriptorMarshaller.marshall(entities);
|
|
Element element = this.entitiesDescriptorMarshaller.marshall(entities);
|
|
- return SerializeSupport.prettyPrintXML(element);
|
|
|
|
|
|
+ if (this.usePrettyPrint) {
|
|
|
|
+ return SerializeSupport.prettyPrintXML(element);
|
|
|
|
+ }
|
|
|
|
+ return SerializeSupport.nodeToString(element);
|
|
}
|
|
}
|
|
catch (Exception ex) {
|
|
catch (Exception ex) {
|
|
throw new Saml2Exception(ex);
|
|
throw new Saml2Exception(ex);
|