Package org.opensaml.xmlsec.keyinfo.impl

# Class BasicKeyInfoGeneratorFactory

java.lang.Object
org.opensaml.xmlsec.keyinfo.impl.BasicKeyInfoGeneratorFactory

All Implemented Interfaces:
  `KeyInfoGeneratorFactory`

Direct Known Subclasses:
  `KeyAgreementKeyInfoGeneratorFactory`, `X509KeyInfoGeneratorFactory`

public class BasicKeyInfoGeneratorFactory extends Object implements KeyInfoGeneratorFactory
A factory implementation which produces instances of `KeyInfoGenerator` capable of handling the information contained within a `Credential`. All boolean options default to false.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`class`
`BasicKeyInfoGeneratorFactory.BasicKeyInfoGenerator`
An implementation of `KeyInfoGenerator` capable of handling the information contained within a `Credential`.
`protected class`
`BasicKeyInfoGeneratorFactory.BasicOptions`
Options to be used in the production of a `KeyInfo` from a `Credential`.

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final Map<Class<? extends KeyInfo>,QName>`
`CLASS_TO_NAME`
Mappings from KeyInfo Class to QNames.
`private final BasicKeyInfoGeneratorFactory.BasicOptions`
`options`
The set of options configured for the factory.

## Constructor Summary

Constructors
Constructor
Description
`BasicKeyInfoGeneratorFactory()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`emitEntityIDAsKeyName()`
Get the option to emit the entity ID value in a Credential as a KeyName element.
`boolean`
`emitKeyNames()`
Get the option to emit key names found in a Credential as KeyName elements.
`boolean`
`emitPublicDEREncodedKeyValue()`
Get the option to emit the value of `Credential.getPublicKey()` as a DEREncodedKeyValue element.
`boolean`
`emitPublicKeyValue()`
Get the option to emit the value of `Credential.getPublicKey()` as a KeyValue element.
`Class<? extends Credential>`
`getCredentialType()`
Get the type (interface) of the specific type of credential handled by generators produced by this factory.
`protected BasicKeyInfoGeneratorFactory.BasicOptions`
`getOptions()`
Get the options of this instance.
`boolean`
`handles(Credential credential)`
Check whether the generators produced by this factory can handle the specified credential.
`KeyInfoGenerator`
`newInstance()`
Get a new instance of the generator type produced by the factory.
`KeyInfoGenerator`
`newInstance(Class<? extends KeyInfo> type)`
Get a new instance of the generator type produced by the factory, and which generates `KeyInfo` instances of the specified type, for example `OriginatorKeyInfo` or `RecipientKeyInfo`.
`protected BasicKeyInfoGeneratorFactory.BasicOptions`
`newOptions()`
Get a new instance to hold options.
`void`
`setEmitEntityIDAsKeyName(boolean newValue)`
Set the option to emit the entity ID value in a Credential as a KeyName element.
`void`
`setEmitKeyNames(boolean newValue)`
Set the option to emit key names found in a Credential as KeyName elements.
`void`
`setEmitPublicDEREncodedKeyValue(boolean newValue)`
Set the option to emit the value of `Credential.getPublicKey()` as a DEREncodedKeyValue element.
`void`
`setEmitPublicKeyValue(boolean newValue)`
Set the option to emit the value of `Credential.getPublicKey()` as a KeyValue element.

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

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

## Field Details

### CLASS_TO_NAME

@Nonnull private static final Map<Class<? extends KeyInfo>,QName> CLASS_TO_NAME
Mappings from KeyInfo Class to QNames.

### options

@Nonnull private final BasicKeyInfoGeneratorFactory.BasicOptions options
The set of options configured for the factory.

## Constructor Details

### BasicKeyInfoGeneratorFactory

public BasicKeyInfoGeneratorFactory()
Constructor. All boolean options are initialzed as false;

## Method Details

### getCredentialType

@Nonnull public Class<? extends Credential> getCredentialType()
Get the type (interface) of the specific type of credential handled by generators produced by this factory. Primarily used as an index by manager implementions such as `KeyInfoGeneratorManager`.

Specified by:
  `getCredentialType` in interface `KeyInfoGeneratorFactory`
Returns:
  the specifc type of credential handled by the generators produced by this factory

### handles

public boolean handles(@Nonnull Credential credential)
Check whether the generators produced by this factory can handle the specified credential.

Specified by:
  `handles` in interface `KeyInfoGeneratorFactory`
Parameters:
  `credential` - the credential to evaluate
Returns:
  true if the generators produced by this factory can handle the type of the specified credential, false otherwise

### newInstance

@Nonnull public KeyInfoGenerator newInstance()
Get a new instance of the generator type produced by the factory.

Specified by:
  `newInstance` in interface `KeyInfoGeneratorFactory`
Returns:
  a new KeyInfoGenerator instance

### newInstance

@Nonnull public KeyInfoGenerator newInstance(@Nullable Class<? extends KeyInfo> type)
Get a new instance of the generator type produced by the factory, and which generates `KeyInfo` instances of the specified type, for example `OriginatorKeyInfo` or `RecipientKeyInfo`.

Specified by:
  `newInstance` in interface `KeyInfoGeneratorFactory`
Parameters:
  `type` - the type of element to produce. Null is interpreted as a standard `KeyInfo`.
Returns:
  a new KeyInfoGenerator instance

### emitEntityIDAsKeyName

public boolean emitEntityIDAsKeyName()
Get the option to emit the entity ID value in a Credential as a KeyName element.

Returns:
  return the option value

### setEmitEntityIDAsKeyName

public void setEmitEntityIDAsKeyName(boolean newValue)
Set the option to emit the entity ID value in a Credential as a KeyName element.

Parameters:
  `newValue` - the new option value to set

### emitKeyNames

public boolean emitKeyNames()
Get the option to emit key names found in a Credential as KeyName elements.

Returns:
  the option value

### setEmitKeyNames

public void setEmitKeyNames(boolean newValue)
Set the option to emit key names found in a Credential as KeyName elements.

Parameters:
  `newValue` - the new option value to set

### emitPublicKeyValue

public boolean emitPublicKeyValue()
Get the option to emit the value of `Credential.getPublicKey()` as a KeyValue element.

Returns:
  the option value

### setEmitPublicKeyValue

public void setEmitPublicKeyValue(boolean newValue)
Set the option to emit the value of `Credential.getPublicKey()` as a KeyValue element.

Parameters:
  `newValue` - the new option value to set

### emitPublicDEREncodedKeyValue

public boolean emitPublicDEREncodedKeyValue()
Get the option to emit the value of `Credential.getPublicKey()` as a DEREncodedKeyValue element.

Returns:
  the option value

### setEmitPublicDEREncodedKeyValue

public void setEmitPublicDEREncodedKeyValue(boolean newValue)
Set the option to emit the value of `Credential.getPublicKey()` as a DEREncodedKeyValue element.

Parameters:
  `newValue` - the new option value to set

### newOptions

@Nonnull protected BasicKeyInfoGeneratorFactory.BasicOptions newOptions()
Get a new instance to hold options. Used by the top-level superclass constructor. Subclasses MUST override to produce an instance of the appropriate subclass of `BasicKeyInfoGeneratorFactory.BasicOptions`.

Returns:
  a new instance of factory/generator options

### getOptions

@Nonnull protected BasicKeyInfoGeneratorFactory.BasicOptions getOptions()
Get the options of this instance. Used by subclass constructors to get the options built by the top-level class constructor with `newOptions()`.

Returns:
  the options instance