Skip to content

Commit 91fb559

Browse files
committed
Add protected getter for settings to ease extension
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.
1 parent b7747fc commit 91fb559

File tree

5 files changed

+56
-5
lines changed

5 files changed

+56
-5
lines changed

core/src/main/java/com/onelogin/saml2/authn/AuthnRequest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,13 @@ public String getId()
279279
{
280280
return id;
281281
}
282+
283+
/**
284+
* Returns the SAML settings specified at construction time.
285+
*
286+
* @return the SAML settings
287+
*/
288+
protected Saml2Settings getSettings() {
289+
return settings;
290+
}
282291
}

core/src/main/java/com/onelogin/saml2/authn/SamlResponse.java

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@
3939
*/
4040
public class SamlResponse {
4141
/**
42-
* Private property to construct a logger for this class.
43-
*/
42+
* Private property to construct a logger for this class.
43+
*/
4444
private static final Logger LOGGER = LoggerFactory.getLogger(SamlResponse.class);
4545

4646
/**
47-
* Settings data.
48-
*/
47+
* Settings data.
48+
*/
4949
private final Saml2Settings settings;
5050

5151
/**
@@ -1239,4 +1239,13 @@ protected void validateSpNameQualifier(final String spNameQualifier) throws Vali
12391239
throw new ValidationError("The SPNameQualifier value mismatch the SP entityID value.", ValidationError.SP_NAME_QUALIFIER_NAME_MISMATCH);
12401240
}
12411241
}
1242+
1243+
/**
1244+
* Returns the SAML settings specified at construction time.
1245+
*
1246+
* @return the SAML settings
1247+
*/
1248+
protected Saml2Settings getSettings() {
1249+
return settings;
1250+
}
12421251
}

core/src/main/java/com/onelogin/saml2/logout/LogoutRequest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -786,4 +786,13 @@ public String getId()
786786
{
787787
return id;
788788
}
789+
790+
/**
791+
* Returns the SAML settings specified at construction time.
792+
*
793+
* @return the SAML settings
794+
*/
795+
protected Saml2Settings getSettings() {
796+
return settings;
797+
}
789798
}

core/src/main/java/com/onelogin/saml2/logout/LogoutResponse.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,4 +493,13 @@ public String getError() {
493493
public Exception getValidationException() {
494494
return validationException;
495495
}
496+
497+
/**
498+
* Returns the SAML settings specified at construction time.
499+
*
500+
* @return the SAML settings
501+
*/
502+
protected Saml2Settings getSettings() {
503+
return settings;
504+
}
496505
}

core/src/main/java/com/onelogin/saml2/settings/Metadata.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ public class Metadata {
6262
*/
6363
private final Integer cacheDuration;
6464

65+
/**
66+
* Settings data.
67+
*/
68+
private final Saml2Settings settings;
69+
6570
/**
6671
* Constructs the Metadata object.
6772
*
@@ -72,6 +77,7 @@ public class Metadata {
7277
* @throws CertificateEncodingException
7378
*/
7479
public Metadata(Saml2Settings settings, Calendar validUntilTime, Integer cacheDuration, AttributeConsumingService attributeConsumingService) throws CertificateEncodingException {
80+
this.settings = settings;
7581
this.validUntilTime = validUntilTime;
7682
this.attributeConsumingService = attributeConsumingService;
7783
this.cacheDuration = cacheDuration;
@@ -102,7 +108,7 @@ public Metadata(Saml2Settings settings, Calendar validUntilTime, Integer cacheDu
102108
* @throws CertificateEncodingException
103109
*/
104110
public Metadata(Saml2Settings settings) throws CertificateEncodingException {
105-
111+
this.settings = settings;
106112
this.validUntilTime = Calendar.getInstance();
107113
this.validUntilTime.add(Calendar.DAY_OF_YEAR, N_DAYS_VALID_UNTIL);
108114

@@ -407,4 +413,13 @@ public static String signMetadata(String metadata, PrivateKey key, X509Certifica
407413
LOGGER.debug("Signed metadata --> " + signedMetadata);
408414
return signedMetadata;
409415
}
416+
417+
/**
418+
* Returns the SAML settings specified at construction time.
419+
*
420+
* @return the SAML settings
421+
*/
422+
protected Saml2Settings getSettings() {
423+
return settings;
424+
}
410425
}

0 commit comments

Comments
 (0)