Skip to content

Commit 5d2fbe1

Browse files
committed
Revert to JDK 7, as EE 7 samples should have that as minimum
1 parent 97e615e commit 5d2fbe1

File tree

2 files changed

+25
-22
lines changed

2 files changed

+25
-22
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<properties>
1313
<arquillian.version>1.1.14.Final</arquillian.version>
14-
<java.min.version>1.8</java.min.version>
14+
<java.min.version>1.7</java.min.version>
1515
<maven.min.version>3.0.0</maven.min.version>
1616
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1717

servlet/security-clientcert/src/test/java/org/javaee7/servlet/security/clientcert/SecureServletTest.java

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ public static WebArchive createDeployment() throws FileNotFoundException, IOExce
107107

108108
@Before
109109
public void setup() throws FileNotFoundException, IOException {
110-
110+
111111
// ### Ask the server for its certificate and add that to a new local trust store
112-
112+
113113
// First get the HTTPS url for which the server is listening
114114
baseHttps = ServerOperations.toContainerHttps(base);
115-
115+
116116
System.out.println("***************************************");
117117

118118
if (baseHttps != null) {
@@ -122,18 +122,18 @@ public void setup() throws FileNotFoundException, IOException {
122122
} else {
123123
System.out.println("No https URL could be created from " + base);
124124
}
125-
125+
126126

127127
webClient = new WebClient();
128128

129129
// Server -> client : the trust store certificates are used to validate the certificate sent
130130
// by the server
131-
131+
132132
String trustStorePath = System.getProperty("buildDirectory", "") + "/clientTrustStore.jks";
133133
System.out.println("Reading trust store from: " + trustStorePath);
134-
134+
135135
webClient.getOptions().setSSLTrustStore(new File(trustStorePath).toURI().toURL(), "changeit", "jks");
136-
136+
137137
String keyStorePath = System.getProperty("buildDirectory", "") + "/clientKeyStore.jks";
138138
System.out.println("Reading key store from: " + keyStorePath);
139139

@@ -153,37 +153,40 @@ public void tearDown() {
153153
public void testGetWithCorrectCredentials() throws Exception {
154154
try {
155155
TextPage page = webClient.getPage(baseHttps + "SecureServlet");
156-
156+
157157
log.info(page.getContent());
158-
158+
159159
assertTrue("my GET", page.getContent().contains("principal C=UK, ST=lak, L=zak, O=kaz, OU=bar, CN=lfoo"));
160160
} catch (Exception e) {
161161
e.printStackTrace();
162162
throw e;
163163
}
164164
}
165165

166-
166+
167167
// Private methods
168-
168+
169169
// TODO: may move these to utility class
170-
170+
171171
private static X509Certificate[] getCertificateChainFromServer(String host, int port) {
172172

173-
List<X509Certificate[]> X509Certificates = new ArrayList<>();
173+
final List<X509Certificate[]> X509Certificates = new ArrayList<>();
174174

175175
try {
176176
SSLContext context = SSLContext.getInstance("TLS");
177177

178178
TrustManager interceptingTrustManager = new X509TrustManager() {
179179

180+
@Override
180181
public X509Certificate[] getAcceptedIssuers() {
181182
return new X509Certificate[] {};
182183
}
183184

185+
@Override
184186
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
185187
}
186188

189+
@Override
187190
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
188191
System.out.println("**** intercepting checkServerTrusted chain" + chain + " authType " + authType);
189192
X509Certificates.add(chain);
@@ -225,10 +228,10 @@ public static X509Certificate createSelfSignedCertificate(KeyPair keys) {
225228
.setProvider(provider)
226229
.getCertificate(
227230
new X509v3CertificateBuilder(
228-
new X500Name("CN=lfoo, OU=bar, O=kaz, L=zak, ST=lak, C=UK"),
231+
new X500Name("CN=lfoo, OU=bar, O=kaz, L=zak, ST=lak, C=UK"),
229232
ONE,
230-
Date.from(now()),
231-
Date.from(now().plus(1, DAYS)),
233+
Date.from(now()),
234+
Date.from(now().plus(1, DAYS)),
232235
new X500Name("CN=lfoo, OU=bar, O=kaz, L=zak, ST=lak, C=UK"),
233236
SubjectPublicKeyInfo.getInstance(keys.getPublic().getEncoded()))
234237
.build(
@@ -257,12 +260,12 @@ private static void createKeyStore(PrivateKey privateKey, X509Certificate certif
257260
keyStore.load(null, null);
258261

259262
keyStore.setEntry(
260-
"clientKey",
263+
"clientKey",
261264
new PrivateKeyEntry(privateKey, new Certificate[] { certificate }),
262265
new PasswordProtection("changeit".toCharArray()));
263-
266+
264267
String path = System.getProperty("buildDirectory", "") + "/clientKeyStore.jks";
265-
268+
266269
System.out.println("Storing key store at: " + path);
267270

268271
keyStore.store(new FileOutputStream(path), "changeit".toCharArray());
@@ -279,9 +282,9 @@ private static void createTrustStore(X509Certificate[] certificates) {
279282
for (int i = 0; i < certificates.length; i++) {
280283
keyStore.setCertificateEntry("serverCert" + i, certificates[i]);
281284
}
282-
285+
283286
String path = System.getProperty("buildDirectory", "") + "/clientTrustStore.jks";
284-
287+
285288
System.out.println("Storing trust store at: " + path);
286289

287290
keyStore.store(new FileOutputStream(path), "changeit".toCharArray());

0 commit comments

Comments
 (0)