Skip to content

Commit

Permalink
Add protected getter for settings to ease extension
Browse files Browse the repository at this point in the history
The various SAML message and metadata object classes have now a
protected getter that allows for subclasses to access the settings
specified at construction time. This is useful to ease extension, for
instance when implementing postProcessXml, so that extensions don't need
to save their own copy of the settings.
  • Loading branch information
mauromol committed Apr 7, 2021
1 parent b7747fc commit 91fb559
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 5 deletions.
9 changes: 9 additions & 0 deletions core/src/main/java/com/onelogin/saml2/authn/AuthnRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,4 +279,13 @@ public String getId()
{
return id;
}

/**
* Returns the SAML settings specified at construction time.
*
* @return the SAML settings
*/
protected Saml2Settings getSettings() {
return settings;
}
}
17 changes: 13 additions & 4 deletions core/src/main/java/com/onelogin/saml2/authn/SamlResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
*/
public class SamlResponse {
/**
* Private property to construct a logger for this class.
*/
* Private property to construct a logger for this class.
*/
private static final Logger LOGGER = LoggerFactory.getLogger(SamlResponse.class);

/**
* Settings data.
*/
* Settings data.
*/
private final Saml2Settings settings;

/**
Expand Down Expand Up @@ -1239,4 +1239,13 @@ protected void validateSpNameQualifier(final String spNameQualifier) throws Vali
throw new ValidationError("The SPNameQualifier value mismatch the SP entityID value.", ValidationError.SP_NAME_QUALIFIER_NAME_MISMATCH);
}
}

/**
* Returns the SAML settings specified at construction time.
*
* @return the SAML settings
*/
protected Saml2Settings getSettings() {
return settings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -786,4 +786,13 @@ public String getId()
{
return id;
}

/**
* Returns the SAML settings specified at construction time.
*
* @return the SAML settings
*/
protected Saml2Settings getSettings() {
return settings;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -493,4 +493,13 @@ public String getError() {
public Exception getValidationException() {
return validationException;
}

/**
* Returns the SAML settings specified at construction time.
*
* @return the SAML settings
*/
protected Saml2Settings getSettings() {
return settings;
}
}
17 changes: 16 additions & 1 deletion core/src/main/java/com/onelogin/saml2/settings/Metadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public class Metadata {
*/
private final Integer cacheDuration;

/**
* Settings data.
*/
private final Saml2Settings settings;

/**
* Constructs the Metadata object.
*
Expand All @@ -72,6 +77,7 @@ public class Metadata {
* @throws CertificateEncodingException
*/
public Metadata(Saml2Settings settings, Calendar validUntilTime, Integer cacheDuration, AttributeConsumingService attributeConsumingService) throws CertificateEncodingException {
this.settings = settings;
this.validUntilTime = validUntilTime;
this.attributeConsumingService = attributeConsumingService;
this.cacheDuration = cacheDuration;
Expand Down Expand Up @@ -102,7 +108,7 @@ public Metadata(Saml2Settings settings, Calendar validUntilTime, Integer cacheDu
* @throws CertificateEncodingException
*/
public Metadata(Saml2Settings settings) throws CertificateEncodingException {

this.settings = settings;
this.validUntilTime = Calendar.getInstance();
this.validUntilTime.add(Calendar.DAY_OF_YEAR, N_DAYS_VALID_UNTIL);

Expand Down Expand Up @@ -407,4 +413,13 @@ public static String signMetadata(String metadata, PrivateKey key, X509Certifica
LOGGER.debug("Signed metadata --> " + signedMetadata);
return signedMetadata;
}

/**
* Returns the SAML settings specified at construction time.
*
* @return the SAML settings
*/
protected Saml2Settings getSettings() {
return settings;
}
}

0 comments on commit 91fb559

Please sign in to comment.