Skip to content

Commit

Permalink
QPID-8658 - [Broker-J] Add Java 21 to the GitHub test matrix (#224)
Browse files Browse the repository at this point in the history
  • Loading branch information
dakirily authored Oct 31, 2023
1 parent c7b6edf commit 263dff3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
strategy:
fail-fast: false
matrix:
java: [ 11, 17 ]
java: [ 11, 17, 21 ]

steps:
- uses: actions/checkout@v3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import com.google.common.collect.HashMultimap;
import com.google.common.collect.ImmutableMultimap;
Expand All @@ -39,7 +41,7 @@
public class MimeContentConverterRegistry
{
private static final Logger LOGGER = LoggerFactory.getLogger(MimeContentConverterRegistry.class);

private static final String SEQUENCED_MAP = "java.util.SequencedMap";
private static final Map<String, MimeContentToObjectConverter> _mimeContentToObjectConverters;
private static final Multimap<Class, ObjectToMimeContentConverter> _classToMimeContentConverters;

Expand Down Expand Up @@ -105,7 +107,10 @@ public static ObjectToMimeContentConverter getBestFitObjectToMimeContentConverte
ObjectToMimeContentConverter converter = null;
if (object != null)
{
final List<Class<?>> classes = new ArrayList<>(Arrays.asList(object.getClass().getInterfaces()));
final List<Class<?>> classes = Stream.of(object.getClass().getInterfaces())
// Java 21 compatibility fix
.flatMap(anInterface -> SEQUENCED_MAP.equals(anInterface.getName()) ? Stream.of(anInterface.getInterfaces()) : Stream.of(anInterface))
.collect(Collectors.toList());
classes.add(object.getClass());
for (Class<?> i : classes)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,48 +138,35 @@ public static X509Certificate createCertificate(final KeyPair keyPair,
final String dn,
final Instant from,
final Instant to,
final AlternativeName... alternativeName)
final AlternativeName... alternativeNames)
throws CertificateException
{
return createCertificate(keyPair,
ca,
dn,
new ValidityPeriod(from, to),
createKeyUsageExtension(),
createAlternateNamesExtension(alternativeName));
return createCertificate(keyPair, ca, dn, new ValidityPeriod(from, to), alternativeNames, createKeyUsageExtension());
}


public static X509Certificate createCertificateForClientAuthorization(final KeyPair keyPair,
final KeyCertificatePair ca,
final String dn,
final AlternativeName... alternativeName)
final AlternativeName... alternativeNames)
throws CertificateException
{
return createCertificate(keyPair,
ca,
dn,
createValidityPeriod(),
createExtendedUsageExtension(new ExtendedKeyUsage(new KeyPurposeId[]{KeyPurposeId.id_kp_clientAuth})),
createAuthorityKeyExtension(ca.getCertificate().getPublicKey()),
createSubjectKeyExtension(keyPair.getPublic()),
createAlternateNamesExtension(alternativeName));
return createCertificate(keyPair, ca, dn, createValidityPeriod(), alternativeNames,
createExtendedUsageExtension(new ExtendedKeyUsage(new KeyPurposeId[]{KeyPurposeId.id_kp_clientAuth})),
createAuthorityKeyExtension(ca.getCertificate().getPublicKey()),
createSubjectKeyExtension(keyPair.getPublic()));
}

public static X509Certificate createCertificateForServerAuthorization(final KeyPair keyPair,
final KeyCertificatePair ca,
final String dn,
final AlternativeName... alternativeName)
final AlternativeName... alternativeNames)
throws CertificateException
{
return createCertificate(keyPair,
ca,
dn,
createValidityPeriod(),
createExtendedUsageExtension(new ExtendedKeyUsage(new KeyPurposeId[]{KeyPurposeId.id_kp_serverAuth})),
createAuthorityKeyExtension(ca.getCertificate().getPublicKey()),
createSubjectKeyExtension(keyPair.getPublic()),
createAlternateNamesExtension(alternativeName));
return createCertificate(keyPair, ca, dn, createValidityPeriod(), alternativeNames,
createExtendedUsageExtension(new ExtendedKeyUsage(new KeyPurposeId[]{KeyPurposeId.id_kp_serverAuth})),
createAuthorityKeyExtension(ca.getCertificate().getPublicKey()),
createSubjectKeyExtension(keyPair.getPublic()));
}

public static X509Certificate createCertificateWithCrlDistributionPoint(final KeyPair keyPair,
Expand All @@ -192,6 +179,7 @@ public static X509Certificate createCertificateWithCrlDistributionPoint(final Ke
caPair,
dn,
createValidityPeriod(),
null,
createKeyUsageExtension(),
createDistributionPointExtension(crlUri));
}
Expand All @@ -200,6 +188,7 @@ private static X509Certificate createCertificate(final KeyPair keyPair,
final KeyCertificatePair ca,
final String dn,
final ValidityPeriod validityPeriod,
final AlternativeName[] alternativeNames,
final Extension... extensions)
throws CertificateException
{
Expand All @@ -218,6 +207,10 @@ private static X509Certificate createCertificate(final KeyPair keyPair,
{
builder.addExtension(e);
}
if (alternativeNames != null && alternativeNames.length > 0)
{
builder.addExtension(createAlternateNamesExtension(alternativeNames));
}
return buildX509Certificate(builder, ca.getPrivateKey());
}
catch (OperatorException | IOException e)
Expand All @@ -244,7 +237,10 @@ private static X509Certificate createSelfSignedCertificate(final KeyPair keyPair
builder.addExtension(Extension.basicConstraints, false, new BasicConstraints(false));
builder.addExtension(createKeyUsageExtension());
builder.addExtension(createSubjectKeyExtension(keyPair.getPublic()));
builder.addExtension(createAlternateNamesExtension(alternativeName));
if (alternativeName != null && alternativeName.length > 0)
{
builder.addExtension(createAlternateNamesExtension(alternativeName));
}
return buildX509Certificate(builder, keyPair.getPrivate());
}
catch (OperatorException | IOException e)
Expand Down Expand Up @@ -330,7 +326,6 @@ private static X509Certificate generateIntermediateCertificate(final KeyPair key
new Date(validityPeriod.getTo().toEpochMilli()),
new X500Name(RFC4519Style.INSTANCE, dn),
keyPair.getPublic());
//builder.addExtension(Extension.keyUsage, false, new KeyUsage(KeyUsage.keyCertSign));
builder.addExtension(Extension.basicConstraints, false, new BasicConstraints(true));
builder.addExtension(createSubjectKeyExtension(keyPair.getPublic()));
builder.addExtension(createAuthorityKeyExtension(rootCA.getCertificate().getPublicKey()));
Expand Down Expand Up @@ -382,15 +377,10 @@ private static X509Certificate createCertificate(final KeyPair keyPair,
final KeyCertificatePair ca,
final String dn,
final ValidityPeriod validityPeriod,
final AlternativeName... alternativeName)
final AlternativeName... alternativeNames)
throws CertificateException
{
return createCertificate(keyPair,
ca,
dn,
validityPeriod,
createKeyUsageExtension(),
createAlternateNamesExtension(alternativeName));
return createCertificate(keyPair, ca, dn, validityPeriod, alternativeNames, createKeyUsageExtension());
}

private static KeyCertificatePair createSelfSigned(final String dn,
Expand Down

0 comments on commit 263dff3

Please sign in to comment.