Skip to content

Commit 37df761

Browse files
Merge branch 'integration' into improve-fips-exception-handling-2025-01-30
2 parents 2ac7c05 + 08abbfa commit 37df761

File tree

37 files changed

+708
-180
lines changed

37 files changed

+708
-180
lines changed

dev/com.ibm.ws.concurrent_fat_schedasync/test-applications/SchedAsyncWeb/src/test/concurrency/schedasync/web/SchedAsyncAppScopedBean.java

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023,2024 IBM Corporation and others.
2+
* Copyright (c) 2023,2025 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -17,6 +17,7 @@
1717
import java.util.concurrent.CompletionStage;
1818
import java.util.concurrent.LinkedBlockingQueue;
1919
import java.util.concurrent.atomic.AtomicInteger;
20+
import java.util.zip.DataFormatException;
2021

2122
import jakarta.enterprise.concurrent.Asynchronous;
2223
import jakarta.enterprise.concurrent.Schedule;
@@ -74,6 +75,79 @@ void everyFourSecondsVirtual(AtomicInteger countdown, LinkedBlockingQueue<Thread
7475
System.out.println("< everyFourSecondsVirtual executed on " + Thread.currentThread());
7576
}
7677

78+
/**
79+
* Run every 7 seconds on seconds that have a remainder of 4 when divided by 7:
80+
* 4 11 18 25 32 39 46 53
81+
* Complete the future exceptionally upon the countdown reaching 0.
82+
*
83+
* @param countdown executions remaining
84+
*/
85+
@Asynchronous(executor = "java:module/concurrent/max-2-executor",
86+
runAt = @Schedule(cron = "4/7 * * * * *"))
87+
CompletableFuture<String> everySevenSecondsUntilExceptionalCompletion(AtomicInteger countdown) {
88+
System.out.println("> everySevenSecondsUntilExceptionalCompletion " + countdown);
89+
90+
if (countdown.decrementAndGet() == 0) {
91+
Exception x = new DataFormatException("Cannot find anything else to do.");
92+
Asynchronous.Result.getFuture().completeExceptionally(x);
93+
}
94+
95+
System.out.println("< everySevenSecondsUntilExceptionalCompletion executed on " +
96+
Thread.currentThread());
97+
return null;
98+
}
99+
100+
/**
101+
* Run every 7 seconds on seconds that have a remainder of 6 when divided by 7:
102+
* 6 13 27 34 41 48 55
103+
* Raise an exception upon the countdown reaching 0.
104+
*
105+
* @param countdown executions remaining
106+
*/
107+
@Asynchronous(executor = "java:module/concurrent/max-2-executor",
108+
runAt = @Schedule(cron = "6/7 * * * * *"))
109+
CompletableFuture<String> everySevenSecondsUntilThrowsError(AtomicInteger countdown) {
110+
System.out.println("> everySevenSecondsUntilThrowsError " + countdown);
111+
112+
if (countdown.decrementAndGet() == 0) {
113+
Error e = new Error("Countdown reached 0, so this won't run again.");
114+
System.out.println("< everySevenSecondsUntilThrowsError intentionally" +
115+
" raised error on " + Thread.currentThread() + ": " +
116+
e);
117+
throw e;
118+
} else {
119+
System.out.println("< everySevenSecondsUntilThrowsError executed on " +
120+
Thread.currentThread());
121+
return null;
122+
}
123+
}
124+
125+
/**
126+
* Run every 7 seconds on seconds that are divisible by 7:
127+
* 0 7 14 28 35 42 49 56
128+
* Raise an exception upon the countdown reaching 0.
129+
*
130+
* @param countdown executions remaining
131+
*/
132+
@Asynchronous(executor = "java:module/concurrent/max-2-executor",
133+
runAt = @Schedule(cron = "0/7 * * * * *"))
134+
CompletableFuture<String> everySevenSecondsUntilThrowsException(AtomicInteger countdown) {
135+
System.out.println("> everySevenSecondsUntilThrowsException " + countdown);
136+
137+
if (countdown.decrementAndGet() == 0) {
138+
ArrayIndexOutOfBoundsException x;
139+
x = new ArrayIndexOutOfBoundsException("Countdown has reached 0.");
140+
System.out.println("< everySevenSecondsUntilThrowsException intentionally" +
141+
" raised exception on " + Thread.currentThread() + ": " +
142+
x);
143+
throw x;
144+
} else {
145+
System.out.println("< everySevenSecondsUntilThrowsException executed on " +
146+
Thread.currentThread());
147+
return null;
148+
}
149+
}
150+
77151
/**
78152
* Combines 4 different schedules to run on seconds that have a remainder of 1 when divided by 6:
79153
* 1 7 13 19 25 31 37 43 49 55.

dev/com.ibm.ws.concurrent_fat_schedasync/test-applications/SchedAsyncWeb/src/test/concurrency/schedasync/web/SchedAsyncTestServlet.java

Lines changed: 110 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2023,2024 IBM Corporation and others.
2+
* Copyright (c) 2023,2025 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -22,10 +22,13 @@
2222
import java.util.HashSet;
2323
import java.util.Set;
2424
import java.util.concurrent.CompletableFuture;
25+
import java.util.concurrent.CompletionException;
2526
import java.util.concurrent.CompletionStage;
27+
import java.util.concurrent.ExecutionException;
2628
import java.util.concurrent.LinkedBlockingQueue;
2729
import java.util.concurrent.TimeUnit;
2830
import java.util.concurrent.atomic.AtomicInteger;
31+
import java.util.zip.DataFormatException;
2932

3033
import jakarta.enterprise.concurrent.ContextServiceDefinition;
3134
import jakarta.enterprise.concurrent.ManagedExecutorDefinition;
@@ -62,6 +65,12 @@ public class SchedAsyncTestServlet extends FATServlet {
6265
private static CompletableFuture<Long> cfEveryFiveSeconds4Times;
6366
private static AtomicInteger cfEveryFiveSeconds4TimesCountdown;
6467

68+
private static CompletableFuture<String> cfEverySevenSecondsUntilExceptionalCompletion;
69+
70+
private static CompletableFuture<String> cfEverySevenSecondsUntilThrowsError;
71+
72+
private static CompletableFuture<String> cfEverySevenSecondsUntilThrowsException;
73+
6574
private static CompletableFuture<long[]> cfEveryThreeAndEvenSeconds8Times;
6675
private static final AtomicInteger cfEveryThreeAndEvenSeconds8TimesCount = new AtomicInteger();
6776

@@ -95,6 +104,15 @@ public void init(ServletConfig config) throws ServletException {
95104

96105
bean.everySixSeconds(3, afterSixSeconds3TimesCount).thenAccept(l -> afterSixSeconds3Times.add(l));
97106

107+
cfEverySevenSecondsUntilExceptionalCompletion = bean
108+
.everySevenSecondsUntilExceptionalCompletion(new AtomicInteger(2));
109+
110+
cfEverySevenSecondsUntilThrowsError = bean
111+
.everySevenSecondsUntilThrowsError(new AtomicInteger(2));
112+
113+
cfEverySevenSecondsUntilThrowsException = bean
114+
.everySevenSecondsUntilThrowsException(new AtomicInteger(2));
115+
98116
cfEveryThreeAndEvenSeconds8Times = bean.everyThreeOrEvenSeconds(8, cfEveryThreeAndEvenSeconds8TimesCount);
99117

100118
bean.everyFourSecondsVirtual(everyFourSecondsVirtualCountdown = new AtomicInteger(4),
@@ -106,7 +124,10 @@ public void init(ServletConfig config) throws ServletException {
106124
// 05 11 17 23 29 35 41 47 53 59
107125
// 01 07 13 19 25 31 37 43 49 55
108126
// 00 02..04 06 08..10 12 14..16 18 20..22 24 26..28 30 32..34 36 38..40 42 44..46 48 50..52 54 56..58
109-
// 02 06 10 14 18 22 26 30 24 38 42 46 50 54 58
127+
// 02 06 10 14 18 22 26 30 34 38 42 46 50 54 58
128+
// 00 07 14 21 28 35 42 49 56
129+
// 04 11 18 25 32 39 46 53
130+
// 06 13 20 27 34 41 48 55
110131
}
111132

112133
/**
@@ -135,6 +156,93 @@ public void testEveryFiveSeconds4Times() throws Exception {
135156
fail("A task that runs every 5 seconds must not complete 4 executions in under 10 seconds. Elapsed nanoseconds: " + elapsed);
136157
}
137158

159+
/**
160+
* An asynchronous method that is scheduled to run every 7 seconds and complete
161+
* itself exceptionally after a supplied countdown reaches 0, must show as
162+
* completed with the requested exception.
163+
*/
164+
@Test
165+
public void testEverySevenSecondsUntilExceptionalCompletion() throws Exception {
166+
try {
167+
String s = cfEverySevenSecondsUntilExceptionalCompletion
168+
.get(TIMEOUT_NS, TimeUnit.NANOSECONDS);
169+
fail("Should have completed exceptionally, not with a result of " + s);
170+
} catch (ExecutionException x) {
171+
if (x.getCause() instanceof DataFormatException)
172+
; // expected
173+
else
174+
throw x;
175+
}
176+
177+
try {
178+
String s = cfEverySevenSecondsUntilExceptionalCompletion.join();
179+
fail("Should have completed exceptionally, not with the result " + s);
180+
} catch (CompletionException x) {
181+
if (x.getCause() instanceof DataFormatException)
182+
; // expected
183+
else
184+
throw x;
185+
}
186+
}
187+
188+
/**
189+
* An asynchronous method that is scheduled to run every 7 seconds and
190+
* raises an error after a supplied countdown reaches 0, must show as
191+
* completed with the raised exception.
192+
*/
193+
@Test
194+
public void testEverySevenSecondsUntilThrowsError() throws Exception {
195+
try {
196+
String s = cfEverySevenSecondsUntilThrowsError
197+
.get(TIMEOUT_NS, TimeUnit.NANOSECONDS);
198+
fail("Should have completed exceptionally, not with a result of " + s);
199+
} catch (ExecutionException x) {
200+
if (x.getCause() instanceof Error)
201+
; // expected
202+
else
203+
throw x;
204+
}
205+
206+
try {
207+
String s = cfEverySevenSecondsUntilThrowsError.join();
208+
fail("Should have completed exceptionally, not with the result " + s);
209+
} catch (CompletionException x) {
210+
if (x.getCause() instanceof Error)
211+
; // expected
212+
else
213+
throw x;
214+
}
215+
}
216+
217+
/**
218+
* An asynchronous method that is scheduled to run every 7 seconds and
219+
* raises an exception after a supplied countdown reaches 0, must show as
220+
* completed with the raised exception.
221+
*/
222+
@Test
223+
public void testEverySevenSecondsUntilThrowsException() throws Exception {
224+
try {
225+
String s = cfEverySevenSecondsUntilThrowsException
226+
.get(TIMEOUT_NS, TimeUnit.NANOSECONDS);
227+
fail("Should have completed exceptionally, not with a result of " + s);
228+
} catch (ExecutionException x) {
229+
if (x.getCause() instanceof ArrayIndexOutOfBoundsException)
230+
; // expected
231+
else
232+
throw x;
233+
}
234+
235+
try {
236+
String s = cfEverySevenSecondsUntilThrowsException.join();
237+
fail("Should have completed exceptionally, not with the result " + s);
238+
} catch (CompletionException x) {
239+
if (x.getCause() instanceof ArrayIndexOutOfBoundsException)
240+
; // expected
241+
else
242+
throw x;
243+
}
244+
}
245+
138246
/**
139247
* An asynchronous method that combines multiple schedules, intermixing cron and basic schedules
140248
* to run every 6 seconds for 3 executions and then complete must run exactly 3 times.

dev/com.ibm.ws.crypto.passwordutil/src/com/ibm/ws/crypto/util/PasswordCipherUtil.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2024 IBM Corporation and others.
2+
* Copyright (c) 2007, 2025 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -55,7 +55,7 @@
5555
import com.ibm.ws.crypto.util.custom.CustomManifest;
5656
import com.ibm.ws.crypto.util.custom.CustomUtils;
5757
import com.ibm.ws.common.crypto.CryptoUtils;
58-
import com.ibm.ws.kernel.productinfo.ProductInfo;
58+
5959
import com.ibm.wsspi.kernel.service.utils.AtomicServiceReference;
6060
import com.ibm.wsspi.security.crypto.CustomPasswordEncryption;
6161
import com.ibm.wsspi.security.crypto.EncryptedInfo;
@@ -266,8 +266,7 @@ private static byte[] aesDecipher(byte[] encrypted_bytes) throws InvalidKeySpecE
266266
throw new InvalidPasswordCipherException("FIPS 140-3 cannot use AES-128");
267267
} else if (encrypted_bytes[0] == 0) { // we only process if we understand the encoding scheme.
268268
return aesDecipherV0(encrypted_bytes);
269-
} else if (ProductInfo.getBetaEdition() && encrypted_bytes[0] == 1) {
270-
//TODO BETA CODE guarded
269+
} else if (encrypted_bytes[0] == 1) {
271270
return aesDecipherV1(encrypted_bytes);
272271
} else {
273272
throw new InvalidPasswordCipherException();
@@ -365,14 +364,7 @@ public static EncryptedInfo encipher_internal(byte[] decrypted_bytes, String cry
365364
if (properties != null) {
366365
cryptoKey = properties.get(PasswordUtil.PROPERTY_CRYPTO_KEY);
367366
}
368-
//TODO: remove beta
369-
if (ProductInfo.getBetaEdition()) {
370-
// Use AES-256(V1) if beta edition is enabled
371-
info = aesEncipherV1(decrypted_bytes, cryptoKey);
372-
} else {
373-
// Use AES-128(V0)otherwise
374-
info = aesEncipherV0(decrypted_bytes, cryptoKey, info, encrypted_bytes);
375-
}
367+
info = aesEncipherV1(decrypted_bytes, cryptoKey);
376368

377369
} else if (XOR.equalsIgnoreCase(crypto_algorithm)) {
378370
encrypted_bytes = xor(decrypted_bytes);

dev/com.ibm.ws.crypto.passwordutil/test/com/ibm/websphere/crypto/PasswordUtilTest.java

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -130,57 +130,19 @@ public void testUtil() {
130130

131131
@Test
132132
public void testAESEncoding() throws Exception {
133-
try {
134-
//TODO remove beta setting once AES-256 is GA
135-
System.setProperty("com.ibm.ws.beta.edition", "true");
136-
137-
String encoding = PasswordUtil.encode("WebAS", "aes");
138-
assertTrue("The encoded password should start with {aes} " + encoding, encoding.startsWith("{aes}"));
139-
String encoding2 = PasswordUtil.encode("WebAS", "aes");
140-
assertFalse("Encoding the same password twice should result in different encodings: " + encoding + " and " + encoding2, encoding.equals(encoding2));
141-
142-
assertEquals("The password was not decoded correctly", "WebAS", PasswordUtil.decode(encoding));
143-
assertEquals("The password was not decoded correctly", "WebAS", PasswordUtil.decode(encoding2));
144-
assertEquals("The password was not decoded correctly", "WebAS", PasswordUtil.decode("{aes}AGTpzRDW//VE3Jshg1fd89rxw/JMjHfFM9UdYdVNIUt2"));
145-
146-
assertEquals("Did not decode password encoded with AES_V0 (AES-128) encoded password", "alternatepwd",
147-
PasswordUtil.decode("{aes}AEmVKa+jOeA7pos+sSfpHNmH1MVfwg8ZoV29iDi6I0ZGcov6hSZsAxMhFr91jTSBYQ=="));
148-
assertEquals("Did not decode password encoded with AES_V1 (AES-256) encoded password", "alternatepwd",
149-
PasswordUtil.decode("{aes}ARABGAM7S4HrIRtZWJ229TnxuKZrrPN3dsKrrQzCQE/3U5F4zp3UrDQ+Czmnvz1kaQyN7JktDzieJxelwu077ZYET2V+7/1Gi37iztr7lY0i+j4dlHOFIi5PESnZ7V8XOmdSbH9DSgkuJaXNoEqb"));
150-
} finally {
151-
System.setProperty("com.ibm.ws.beta.edition", "false");
152-
}
153-
}
154-
155-
@Test
156-
public void testAES256EncodingFailsWithoutBeta() throws Exception {
157-
//TODO remove beta setting once AES-256 is GA
158-
try {
159-
System.setProperty("com.ibm.ws.beta.edition", "false");
160-
161-
String encoding = PasswordUtil.encode("WebAS", "aes");
162-
assertTrue("The encoded password should start with {aes} " + encoding, encoding.startsWith("{aes}"));
163-
String encoding2 = PasswordUtil.encode("WebAS", "aes");
164-
assertFalse("Encoding the same password twice should result in different encodings: " + encoding + " and " + encoding2, encoding.equals(encoding2));
165-
166-
assertEquals("The password was not decoded correctly", "WebAS", PasswordUtil.decode(encoding));
167-
assertEquals("The password was not decoded correctly", "WebAS", PasswordUtil.decode(encoding2));
168-
assertEquals("The password was not decoded correctly", "WebAS", PasswordUtil.decode("{aes}AGTpzRDW//VE3Jshg1fd89rxw/JMjHfFM9UdYdVNIUt2"));
169-
170-
assertEquals("Did not decode password encoded with AES_V0 (AES-128) encoded password", "alternatepwd",
171-
PasswordUtil.decode("{aes}AEmVKa+jOeA7pos+sSfpHNmH1MVfwg8ZoV29iDi6I0ZGcov6hSZsAxMhFr91jTSBYQ=="));
133+
String encoding = PasswordUtil.encode("WebAS", "aes");
134+
assertTrue("The encoded password should start with {aes} " + encoding, encoding.startsWith("{aes}"));
135+
String encoding2 = PasswordUtil.encode("WebAS", "aes");
136+
assertFalse("Encoding the same password twice should result in different encodings: " + encoding + " and " + encoding2, encoding.equals(encoding2));
172137

173-
// decode("{aes}<valid AES256 encoded password>); should fail with InvalidPasswordDecodingException when beta is disabled.
174-
try {
175-
PasswordUtil.decode("{aes}ARABGAM7S4HrIRtZWJ229TnxuKZrrPN3dsKrrQzCQE/3U5F4zp3UrDQ+Czmnvz1kaQyN7JktDzieJxelwu077ZYET2V+7/1Gi37iztr7lY0i+j4dlHOFIi5PESnZ7V8XOmdSbH9DSgkuJaXNoEqb");
176-
fail("decode AES256 encoded password should have failed with InvalidPasswordDecodingException when beta is disabled.");
177-
} catch (InvalidPasswordDecodingException e) {
178-
// expected exception
179-
}
180-
} finally {
181-
System.setProperty("com.ibm.ws.beta.edition", "false");
182-
}
138+
assertEquals("The password was not decoded correctly", "WebAS", PasswordUtil.decode(encoding));
139+
assertEquals("The password was not decoded correctly", "WebAS", PasswordUtil.decode(encoding2));
140+
assertEquals("The password was not decoded correctly", "WebAS", PasswordUtil.decode("{aes}AGTpzRDW//VE3Jshg1fd89rxw/JMjHfFM9UdYdVNIUt2"));
183141

142+
assertEquals("Did not decode password encoded with AES_V0 (AES-128) encoded password", "alternatepwd",
143+
PasswordUtil.decode("{aes}AEmVKa+jOeA7pos+sSfpHNmH1MVfwg8ZoV29iDi6I0ZGcov6hSZsAxMhFr91jTSBYQ=="));
144+
assertEquals("Did not decode password encoded with AES_V1 (AES-256) encoded password", "alternatepwd",
145+
PasswordUtil.decode("{aes}ARABGAM7S4HrIRtZWJ229TnxuKZrrPN3dsKrrQzCQE/3U5F4zp3UrDQ+Czmnvz1kaQyN7JktDzieJxelwu077ZYET2V+7/1Gi37iztr7lY0i+j4dlHOFIi5PESnZ7V8XOmdSbH9DSgkuJaXNoEqb"));
184146
}
185147

186148
@Test

dev/com.ibm.ws.jaxb_fat/fat/src/com/ibm/ws/jaxb/fat/LibertyJAXBSpecTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
import com.ibm.websphere.simplicity.ShrinkHelper;
2929

30+
import componenttest.annotation.MinimumJavaLevel;
3031
import componenttest.annotation.Server;
3132
import componenttest.annotation.SkipForRepeat;
3233
import componenttest.custom.junit.runner.FATRunner;
@@ -64,6 +65,7 @@ public void afterTest() throws Exception {
6465
* This property doesn't work for them.
6566
*/
6667
@Test
68+
@MinimumJavaLevel(javaLevel = 9)
6769
@SkipForRepeat({ SkipForRepeat.EE9_FEATURES, SkipForRepeat.EE10_FEATURES })
6870
public void testBackupWithParentNamespaceTrue_Servlet() throws Exception {
6971
Map<String, String> map = server.getJvmOptionsAsMap();

dev/com.ibm.ws.security.registry.basic_fat/publish/servers/com.ibm.ws.security.registry.basic.fat.federated/jvm.options

Lines changed: 0 additions & 1 deletion
This file was deleted.

dev/com.ibm.ws.security.registry.basic_fat/publish/servers/com.ibm.ws.security.registry.basic.fat/jvm.options

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)