Skip to content

Commit a763382

Browse files
Make source code compatible with JDK 8
Closes gh-10695
1 parent 60595f2 commit a763382

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

build.gradle

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ subprojects {
106106
}
107107
tasks.withType(JavaCompile) {
108108
options.encoding = "UTF-8"
109+
options.compilerArgs.add("-parameters")
110+
options.release = 8
109111
}
110112
}
111113

config/src/main/java/org/springframework/security/config/annotation/web/configurers/saml2/Saml2LoginConfigurer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ private String version() {
276276
if (version != null) {
277277
return version;
278278
}
279-
return Version.class.getModule().getDescriptor().version().map(Object::toString)
280-
.orElseThrow(() -> new IllegalStateException("cannot determine OpenSAML version"));
279+
return Version.getVersion();
281280
}
282281

283282
private void registerDefaultAuthenticationProvider(B http) {

config/src/test/java/org/springframework/security/config/annotation/web/configurers/NamespaceHttpX509Tests.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@
2121
import java.security.cert.CertificateFactory;
2222
import java.security.cert.X509Certificate;
2323

24+
import javax.security.auth.x500.X500Principal;
2425
import javax.servlet.http.HttpServletRequest;
2526

27+
import org.bouncycastle.asn1.x500.X500Name;
28+
import org.bouncycastle.asn1.x500.style.BCStyle;
2629
import org.junit.Rule;
2730
import org.junit.Test;
28-
import sun.security.x509.X500Name;
2931

3032
import org.springframework.beans.factory.annotation.Autowired;
3133
import org.springframework.context.annotation.Bean;
@@ -239,12 +241,8 @@ protected void configure(HttpSecurity http) throws Exception {
239241
}
240242

241243
private String extractCommonName(X509Certificate certificate) {
242-
try {
243-
return ((X500Name) certificate.getSubjectDN()).getCommonName();
244-
}
245-
catch (Exception ex) {
246-
throw new IllegalArgumentException(ex);
247-
}
244+
X500Principal principal = certificate.getSubjectX500Principal();
245+
return new X500Name(principal.getName()).getRDNs(BCStyle.CN)[0].getFirst().getValue().toString();
248246
}
249247

250248
}

0 commit comments

Comments
 (0)