Skip to content

Commit 2e5c87d

Browse files
committed
Restore Binary Compatibility
Issue gh-8835
1 parent b02e344 commit 2e5c87d

File tree

4 files changed

+83
-22
lines changed

4 files changed

+83
-22
lines changed

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/Saml2AuthenticationException.java

Lines changed: 68 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,20 +83,86 @@ public Saml2AuthenticationException(Saml2Error error, String message, Throwable
8383
this.setError(error);
8484
}
8585

86+
/**
87+
* Constructs a {@code Saml2AuthenticationException} using the provided parameters.
88+
*
89+
* @param error the {@link org.springframework.security.saml2.provider.service.authentication.Saml2Error SAML 2.0 Error}
90+
* @deprecated Use {@link org.springframework.security.saml2.provider.service.authentication.Saml2Error} constructor instead
91+
*/
92+
@Deprecated
93+
public Saml2AuthenticationException(org.springframework.security.saml2.provider.service.authentication.Saml2Error error) {
94+
this(error, error.getDescription());
95+
}
96+
97+
/**
98+
* Constructs a {@code Saml2AuthenticationException} using the provided parameters.
99+
*
100+
* @param error the {@link org.springframework.security.saml2.provider.service.authentication.Saml2Error SAML 2.0 Error}
101+
* @param cause the root cause
102+
* @deprecated Use {@link org.springframework.security.saml2.provider.service.authentication.Saml2Error} constructor instead
103+
*/
104+
@Deprecated
105+
public Saml2AuthenticationException(org.springframework.security.saml2.provider.service.authentication.Saml2Error error, Throwable cause) {
106+
this(error, cause.getMessage(), cause);
107+
}
108+
109+
/**
110+
* Constructs a {@code Saml2AuthenticationException} using the provided parameters.
111+
*
112+
* @param error the {@link Saml2Error SAML 2.0 Error}
113+
* @param message the detail message
114+
* @deprecated Use {@link Saml2Error} constructor instead
115+
*/
116+
@Deprecated
117+
public Saml2AuthenticationException(org.springframework.security.saml2.provider.service.authentication.Saml2Error error, String message) {
118+
super(message);
119+
this.setError(error);
120+
}
121+
122+
/**
123+
* Constructs a {@code Saml2AuthenticationException} using the provided parameters.
124+
*
125+
* @param error the {@link org.springframework.security.saml2.provider.service.authentication.Saml2Error SAML 2.0 Error}
126+
* @param message the detail message
127+
* @param cause the root cause
128+
* @deprecated Use {@link org.springframework.security.saml2.provider.service.authentication.Saml2Error} constructor instead
129+
*/
130+
@Deprecated
131+
public Saml2AuthenticationException(org.springframework.security.saml2.provider.service.authentication.Saml2Error error, String message, Throwable cause) {
132+
super(message, cause);
133+
this.setError(error);
134+
}
135+
136+
/**
137+
* Get the associated {@link Saml2Error}
138+
*
139+
* @return the associated {@link Saml2Error}
140+
*/
141+
public Saml2Error getSaml2Error() {
142+
return this.error;
143+
}
144+
86145
/**
87146
* Returns the {@link Saml2Error SAML 2.0 Error}.
88147
*
89148
* @return the {@link Saml2Error}
149+
* @deprecated Use {@link #getSaml2Error()} instead
90150
*/
91-
public Saml2Error getError() {
92-
return this.error;
151+
@Deprecated
152+
public org.springframework.security.saml2.provider.service.authentication.Saml2Error getError() {
153+
return new org.springframework.security.saml2.provider.service.authentication.Saml2Error(
154+
this.error.getErrorCode(), this.error.getDescription());
93155
}
94156

95157
private void setError(Saml2Error error) {
96158
Assert.notNull(error, "error cannot be null");
97159
this.error = error;
98160
}
99161

162+
private void setError(org.springframework.security.saml2.provider.service.authentication.Saml2Error error) {
163+
setError(new Saml2Error(error.getErrorCode(), error.getDescription()));
164+
}
165+
100166
@Override
101167
public String toString() {
102168
final StringBuffer sb = new StringBuffer("Saml2AuthenticationException{");

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/Saml2Error.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.io.Serializable;
2020

2121
import org.springframework.security.core.SpringSecurityCoreVersion;
22-
import org.springframework.util.Assert;
2322

2423
/**
2524
* A representation of an SAML 2.0 Error.
@@ -36,8 +35,7 @@
3635
public class Saml2Error implements Serializable {
3736
private static final long serialVersionUID = SpringSecurityCoreVersion.SERIAL_VERSION_UID;
3837

39-
private final String errorCode;
40-
private final String description;
38+
private final org.springframework.security.saml2.core.Saml2Error error;
4139

4240
/**
4341
* Constructs a {@code Saml2Error} using the provided parameters.
@@ -46,9 +44,7 @@ public class Saml2Error implements Serializable {
4644
* @param description the error description
4745
*/
4846
public Saml2Error(String errorCode, String description) {
49-
Assert.hasText(errorCode, "errorCode cannot be empty");
50-
this.errorCode = errorCode;
51-
this.description = description;
47+
this.error = new org.springframework.security.saml2.core.Saml2Error(errorCode, description);
5248
}
5349

5450
/**
@@ -57,7 +53,7 @@ public Saml2Error(String errorCode, String description) {
5753
* @return the error code
5854
*/
5955
public final String getErrorCode() {
60-
return this.errorCode;
56+
return this.error.getErrorCode();
6157
}
6258

6359
/**
@@ -66,7 +62,7 @@ public final String getErrorCode() {
6662
* @return the error description
6763
*/
6864
public final String getDescription() {
69-
return this.description;
65+
return this.error.getDescription();
7066
}
7167

7268
@Override

saml2/saml2-service-provider/src/main/java/org/springframework/security/saml2/provider/service/authentication/Saml2ErrorCodes.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,34 @@ public interface Saml2ErrorCodes {
3030
* SAML 2 Response object of type {@code ResponseType} per specification
3131
* https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf#page=46
3232
*/
33-
String UNKNOWN_RESPONSE_CLASS = "unknown_response_class";
33+
String UNKNOWN_RESPONSE_CLASS = org.springframework.security.saml2.core.Saml2ErrorCodes.UNKNOWN_RESPONSE_CLASS;
3434
/**
3535
* The response data is malformed or incomplete.
3636
* An invalid XML object was received, and XML unmarshalling failed.
3737
*/
38-
String MALFORMED_RESPONSE_DATA = "malformed_response_data";
38+
String MALFORMED_RESPONSE_DATA = org.springframework.security.saml2.core.Saml2ErrorCodes.MALFORMED_RESPONSE_DATA;
3939
/**
4040
* Response destination does not match the request URL.
4141
* A SAML 2 response object was received at a URL that
4242
* did not match the URL stored in the {code Destination} attribute
4343
* in the Response object.
4444
* https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf#page=38
4545
*/
46-
String INVALID_DESTINATION = "invalid_destination";
46+
String INVALID_DESTINATION = org.springframework.security.saml2.core.Saml2ErrorCodes.INVALID_DESTINATION;
4747
/**
4848
* The assertion was not valid.
4949
* The assertion used for authentication failed validation.
5050
* Details around the failure will be present in the error description.
5151
*/
52-
String INVALID_ASSERTION = "invalid_assertion";
52+
String INVALID_ASSERTION = org.springframework.security.saml2.core.Saml2ErrorCodes.INVALID_ASSERTION;
5353
/**
5454
* The signature of response or assertion was invalid.
5555
* Either the response or the assertion was missing a signature
5656
* or the signature could not be verified using the system's
5757
* configured credentials. Most commonly the IDP's
5858
* X509 certificate.
5959
*/
60-
String INVALID_SIGNATURE = "invalid_signature";
60+
String INVALID_SIGNATURE = org.springframework.security.saml2.core.Saml2ErrorCodes.INVALID_SIGNATURE;
6161
/**
6262
* The assertion did not contain a subject element.
6363
* The subject element, type SubjectType, contains
@@ -67,7 +67,7 @@ public interface Saml2ErrorCodes {
6767
*
6868
* https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf#page=18
6969
*/
70-
String SUBJECT_NOT_FOUND = "subject_not_found";
70+
String SUBJECT_NOT_FOUND = org.springframework.security.saml2.core.Saml2ErrorCodes.SUBJECT_NOT_FOUND;
7171
/**
7272
* The subject did not contain a user identifier
7373
* The assertion contained a subject element, but the subject
@@ -76,28 +76,28 @@ public interface Saml2ErrorCodes {
7676
*
7777
* https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf#page=18
7878
*/
79-
String USERNAME_NOT_FOUND = "username_not_found";
79+
String USERNAME_NOT_FOUND = org.springframework.security.saml2.core.Saml2ErrorCodes.USERNAME_NOT_FOUND;
8080
/**
8181
* The system failed to decrypt an assertion or a name identifier.
8282
* This error code will be thrown if the decryption of either a
8383
* {@code EncryptedAssertion} or {@code EncryptedID} fails.
8484
* https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf#page=17
8585
*/
86-
String DECRYPTION_ERROR = "decryption_error";
86+
String DECRYPTION_ERROR = org.springframework.security.saml2.core.Saml2ErrorCodes.DECRYPTION_ERROR;
8787
/**
8888
* An Issuer element contained a value that didn't
8989
* https://docs.oasis-open.org/security/saml/v2.0/saml-core-2.0-os.pdf#page=15
9090
*/
91-
String INVALID_ISSUER = "invalid_issuer";
91+
String INVALID_ISSUER = org.springframework.security.saml2.core.Saml2ErrorCodes.INVALID_ISSUER;
9292
/**
9393
* An error happened during validation.
9494
* Used when internal, non classified, errors are caught during the
9595
* authentication process.
9696
*/
97-
String INTERNAL_VALIDATION_ERROR = "internal_validation_error";
97+
String INTERNAL_VALIDATION_ERROR = org.springframework.security.saml2.core.Saml2ErrorCodes.INTERNAL_VALIDATION_ERROR;
9898
/**
9999
* The relying party registration was not found.
100100
* The registration ID did not correspond to any relying party registration.
101101
*/
102-
String RELYING_PARTY_REGISTRATION_NOT_FOUND = "relying_party_registration_not_found";
102+
String RELYING_PARTY_REGISTRATION_NOT_FOUND = org.springframework.security.saml2.core.Saml2ErrorCodes.RELYING_PARTY_REGISTRATION_NOT_FOUND;
103103
}

saml2/saml2-service-provider/src/test/java/org/springframework/security/saml2/provider/service/authentication/OpenSamlAuthenticationProviderTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
import org.xml.sax.InputSource;
5353

5454
import org.springframework.security.core.Authentication;
55-
import org.springframework.security.saml2.core.Saml2ErrorCodes;
5655
import org.springframework.security.saml2.credentials.Saml2X509Credential;
5756

5857
import static org.assertj.core.api.Assertions.assertThat;

0 commit comments

Comments
 (0)