Skip to content

Commit

Permalink
Enable aarch64/x86-64 Mac bundling OpenJCEPlus
Browse files Browse the repository at this point in the history
OpenJCEPlus providers are supported on the Mac OS with aarch64
and amd64 architectures. This PR aims to add aarch64-mac and
x86_64-mac to platforms bundling OpenJCEPlus.

Signed-off-by: Jinhang Zhang <[email protected]>
  • Loading branch information
JinhangZhang committed Nov 21, 2024
1 parent 9fe7c73 commit e3a7f72
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 36 deletions.
2 changes: 1 addition & 1 deletion closed/make/modules/openjceplus/Copy.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ifeq (true,$(BUILD_OPENJCEPLUS))
# Copy OpenJCEPlus native libraries.
$(eval $(call SetupCopyFiles, OPENJCEPLUS_JGSKIT_LIBS_COPY, \
SRC := $(OPENJCEPLUS_TOPDIR)/target, \
FILES := $(filter %.dll %.so %.x, $(call FindFiles, $(OPENJCEPLUS_TOPDIR)/target)), \
FILES := $(filter %.dll %.dylib %.so %.x, $(call FindFiles, $(OPENJCEPLUS_TOPDIR)/target)), \
FLATTEN := true, \
DEST := $(LIB_DST_DIR), \
))
Expand Down
7 changes: 7 additions & 0 deletions closed/make/modules/openjceplus/Lib.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ else ifeq ($(call isTargetOs, linux), true)
else ifeq ($(call isTargetCpu, x86_64), true)
OPENJCEPLUS_JGSKIT_PLATFORM := x86-linux64
endif
else ifeq ($(call isTargetOs, macosx), true)
ifeq ($(call isTargetCpu, aarch64), true)
OPENJCEPLUS_JGSKIT_PLATFORM := aarch64-mac
else ifeq ($(call isTargetCpu, x86_64), true)
OPENJCEPLUS_JGSKIT_PLATFORM := x86_64-mac
endif
OPENJCEPLUS_JGSKIT_MAKE := jgskit.mac.mak
else ifeq ($(call isTargetOs, windows), true)
ifeq ($(call isTargetCpu, x86_64), true)
EXPORT_COMPILER_ENV_VARS := LIB='$(OPENJ9_VS_LIB)'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public final class RestrictedSecurity {
private static final boolean allowSetProperties;

private static final boolean isNSSSupported;
private static final boolean isOpenJCEPlusSupported;
private static final boolean isOpenJCEPlusFIPSSupported;

private static final boolean userSetProfile;
private static final boolean shouldEnableSecurity;
Expand All @@ -83,15 +83,7 @@ public final class RestrictedSecurity {

private static final Set<String> unmodifiableProperties = new HashSet<>();

private static final Map<String, List<String>> supportedPlatformsNSS = new HashMap<>();
private static final Map<String, List<String>> supportedPlatformsOpenJCEPlus = new HashMap<>();

static {
supportedPlatformsNSS.put("Arch", List.of("amd64", "ppc64le", "s390x"));
supportedPlatformsNSS.put("OS", List.of("Linux"));

supportedPlatformsOpenJCEPlus.put("Arch", List.of("amd64", "ppc64", "s390x"));
supportedPlatformsOpenJCEPlus.put("OS", List.of("Linux", "AIX", "Windows"));

@SuppressWarnings("removal")
String[] props = AccessController.doPrivileged(
Expand All @@ -106,36 +98,54 @@ public String[] run() {
}
});

boolean isOsSupported, isArchSupported;
boolean isOsSupported;
boolean isArchSupported;

// Check whether the NSS FIPS solution is supported.
isOsSupported = false;
for (String os: supportedPlatformsNSS.get("OS")) {
if (props[2].contains(os)) {
isOsSupported = true;
}
}
isArchSupported = false;
for (String arch: supportedPlatformsNSS.get("Arch")) {
if (props[3].contains(arch)) {
isArchSupported = true;
}
switch (props[2]) { // os.name
case "Linux":
isOsSupported = true;
break;
default:
isOsSupported = false;
break;
}

switch (props[3]) { // os.arch
case "amd64":
case "ppc64le":
case "s390x":
isArchSupported = true;
break;
default:
isArchSupported = false;
break;
}
isNSSSupported = isOsSupported && isArchSupported;

// Check whether the OpenJCEPlus FIPS solution is supported.
isOsSupported = false;
for (String os: supportedPlatformsOpenJCEPlus.get("OS")) {
if (props[2].contains(os)) {
isOsSupported = true;
}
}
isArchSupported = false;
for (String arch: supportedPlatformsOpenJCEPlus.get("Arch")) {
if (props[3].contains(arch)) {
isArchSupported = true;
}
}
isOpenJCEPlusSupported = isOsSupported && isArchSupported;
switch (props[2]) { // os.name
case "AIX":
case "Linux":
case "Windows":
isOsSupported = true;
break;
default:
isOsSupported = false;
break;
}

switch (props[3]) { // os.arch
case "amd64":
case "ppc64le":
case "s390x":
isArchSupported = true;
break;
default:
isArchSupported = false;
break;
}
isOpenJCEPlusFIPSSupported = isOsSupported && isArchSupported;

// Check the default solution to see if FIPS is supported.
isFIPSSupported = isNSSSupported;
Expand Down Expand Up @@ -381,7 +391,7 @@ private static void checkIfKnownProfileSupported() {
+ " on this platform.");
}

if (profileID.contains("OpenJCEPlus") && !isOpenJCEPlusSupported) {
if (profileID.contains("OpenJCEPlusFIPS") && !isOpenJCEPlusFIPSSupported) {
printStackTraceAndExit("OpenJCEPlus RestrictedSecurity profiles are not supported"
+ " on this platform.");
}
Expand Down

0 comments on commit e3a7f72

Please sign in to comment.