Package org.opensaml.xmlsec.agreement

# Class KeyAgreementSupport

java.lang.Object
org.opensaml.xmlsec.agreement.KeyAgreementSupport

public final class KeyAgreementSupport extends Object
Support for key agreement operations.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final Set<String>`
`KEY_ALGORITHMS`
JCA key algorithms that support key agreement.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`KeyAgreementSupport()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static KeyAgreementProcessorRegistry`
`ensureGlobalProcessorRegistry()`
Get the global `KeyAgreementProcessorRegistry` instance, raising an exception if unavailable.
`static Integer`
`getExplicitKeySize(AgreementMethod agreementMethod)`
Look for an explicit key size via an `AgreementMethod`'s grandparent's `EncryptionMethod` child's `KeySize` child element.
`static KeyAgreementProcessorRegistry`
`getGlobalProcessorRegistry()`
Get the global `KeyAgreementProcessorRegistry` instance.
`static KeyAgreementProcessor`
`getProcessor(String algorithm)`
Lookup and return the `KeyAgreementProcessor` to use for the specified key agreement algorithm.
`static boolean`
`supportsKeyAgreement(Credential credential)`
Evaluate whether the specified credential contains a public key which supports key agreement.
`static void`
`validateKeyAlgorithmAndSize(String algorithmURI, Integer specifiedKeyLength)`
Validate the specified algorithm URI and key length for consistency.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### KEY_ALGORITHMS

@Nonnull public static final Set<String> KEY_ALGORITHMS
JCA key algorithms that support key agreement.

## Constructor Details

### KeyAgreementSupport

private KeyAgreementSupport()
Constructor.

## Method Details

### getGlobalProcessorRegistry

@Nullable public static KeyAgreementProcessorRegistry getGlobalProcessorRegistry()
Get the global `KeyAgreementProcessorRegistry` instance.

Returns:
  the global processor registry, or null if nothing registered

### ensureGlobalProcessorRegistry

@Nonnull public static KeyAgreementProcessorRegistry ensureGlobalProcessorRegistry()
Get the global `KeyAgreementProcessorRegistry` instance, raising an exception if unavailable.

Returns:
  the global processor registry
Since:
  5.0.0

### getProcessor

@Nonnull public static KeyAgreementProcessor getProcessor(@Nonnull String algorithm) throws KeyAgreementException
Lookup and return the `KeyAgreementProcessor` to use for the specified key agreement algorithm.

Parameters:
  `algorithm` - the key agreement algorithm
Returns:
  the processor for that algorithm
Throws:
  `KeyAgreementException` - if global `KeyAgreementProcessorRegistry` is not configured or if no processor is registered for the specified algorithm

### getExplicitKeySize

@Nullable public static Integer getExplicitKeySize(@Nonnull AgreementMethod agreementMethod)
Look for an explicit key size via an `AgreementMethod`'s grandparent's `EncryptionMethod` child's `KeySize` child element.

Parameters:
  `agreementMethod` - the AgreementMethod to process
Returns:
  the key size, or null if not present

### validateKeyAlgorithmAndSize

public static void validateKeyAlgorithmAndSize(@Nonnull String algorithmURI, @Nullable Integer specifiedKeyLength) throws KeyAgreementException
Validate the specified algorithm URI and key length for consistency.

If the algorithm URI does not imply a key length, then the specified key length must be non-null. If the algorithm URI does imply a key length and the optional specified key length is non-null, they must be the same length.

Parameters:
  `algorithmURI` - the algorithm URI
  `specifiedKeyLength` - the optional specified key length
Throws:
  `KeyAgreementException` - if algorithm and specified key lengths are not consistent

### supportsKeyAgreement

public static boolean supportsKeyAgreement(@Nullable Credential credential)
Evaluate whether the specified credential contains a public key which supports key agreement.

Parameters:
  `credential` - the credential to evaluate
Returns:
  true if supports key agreement, false if does not