Skip to content

Commit f606b83

Browse files
committed
Throw Saml2Exception is a SAML error occurs
1 parent b34ea89 commit f606b83

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

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

+2-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
2929
import org.springframework.security.authentication.AuthenticationProvider;
3030
import org.springframework.security.authentication.InsufficientAuthenticationException;
31-
import org.springframework.security.authentication.ProviderNotFoundException;
3231
import org.springframework.security.core.Authentication;
3332
import org.springframework.security.core.AuthenticationException;
3433
import org.springframework.security.core.GrantedAuthority;
@@ -109,15 +108,15 @@ private Assertion validateSaml2Response(Saml2AuthenticationToken token,
109108
String recipient,
110109
Response samlResponse) throws AuthenticationException {
111110
if (hasText(samlResponse.getDestination()) && !recipient.equals(samlResponse.getDestination())) {
112-
throw new ProviderNotFoundException("Invalid SAML response destination: " + samlResponse.getDestination());
111+
throw new Saml2Exception("Invalid SAML response destination: " + samlResponse.getDestination());
113112
}
114113

115114
final String issuer = samlResponse.getIssuer().getValue();
116115
if (logger.isDebugEnabled()) {
117116
logger.debug("Processing SAML response from " + issuer);
118117
}
119118
if (token == null) {
120-
throw new ProviderNotFoundException(format("SAML 2 Provider for %s was not found.", issuer));
119+
throw new Saml2Exception(format("SAML 2 Provider for %s was not found.", issuer));
121120
}
122121
boolean responseSigned = hasValidSignature(samlResponse, token);
123122
for (Assertion a : samlResponse.getAssertions()) {

0 commit comments

Comments
 (0)