Skip to content

Commit b33bc28

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 e71392d commit b33bc28

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
@@ -288,4 +288,13 @@ public String getId()
288288
public Calendar getIssueInstant() {
289289
return issueInstant == null? null: (Calendar) issueInstant.clone();
290290
}
291+
292+
/**
293+
* Returns the SAML settings specified at construction time.
294+
*
295+
* @return the SAML settings
296+
*/
297+
protected Saml2Settings getSettings() {
298+
return settings;
299+
}
291300
}

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

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141
*/
4242
public class SamlResponse {
4343
/**
44-
* Private property to construct a logger for this class.
45-
*/
44+
* Private property to construct a logger for this class.
45+
*/
4646
private static final Logger LOGGER = LoggerFactory.getLogger(SamlResponse.class);
4747

4848
/**
49-
* Settings data.
50-
*/
49+
* Settings data.
50+
*/
5151
private final Saml2Settings settings;
5252

5353
/**
@@ -1322,4 +1322,13 @@ public Calendar getResponseIssueInstant() throws ValidationError {
13221322
}
13231323
return result;
13241324
}
1325+
1326+
/**
1327+
* Returns the SAML settings specified at construction time.
1328+
*
1329+
* @return the SAML settings
1330+
*/
1331+
protected Saml2Settings getSettings() {
1332+
return settings;
1333+
}
13251334
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,4 +829,13 @@ public String getId()
829829
public Calendar getIssueInstant() {
830830
return issueInstant == null? null: (Calendar) issueInstant.clone();
831831
}
832+
833+
/**
834+
* Returns the SAML settings specified at construction time.
835+
*
836+
* @return the SAML settings
837+
*/
838+
protected Saml2Settings getSettings() {
839+
return settings;
840+
}
832841
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,4 +534,13 @@ public Calendar getIssueInstant() throws ValidationError {
534534
} else
535535
return issueInstant == null? null: (Calendar) issueInstant.clone();
536536
}
537+
538+
/**
539+
* Returns the SAML settings specified at construction time.
540+
*
541+
* @return the SAML settings
542+
*/
543+
protected Saml2Settings getSettings() {
544+
return settings;
545+
}
537546
}

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)