Package org.opensaml.xmlsec.keyinfo.impl

# Class BasicKeyInfoGeneratorFactory.BasicKeyInfoGenerator

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

All Implemented Interfaces:
  `KeyInfoGenerator`

Direct Known Subclasses:
  `KeyAgreementKeyInfoGeneratorFactory.KeyAgreementKeyInfoGenerator`, `X509KeyInfoGeneratorFactory.X509KeyInfoGenerator`

Enclosing class:
  BasicKeyInfoGeneratorFactory

public class BasicKeyInfoGeneratorFactory.BasicKeyInfoGenerator extends Object implements KeyInfoGenerator
An implementation of `KeyInfoGenerator` capable of handling the information contained within a `Credential`.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final XMLObjectBuilderFactory`
`builderFactory`
Builder factory for KeyInfo objects.
`private final Class<? extends KeyInfo>`
`keyInfoType`
The specific type of KeyInfo to generate.
`private final BasicKeyInfoGeneratorFactory.BasicOptions`
`options`
The set of options to be used by the generator.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`protected`
`BasicKeyInfoGenerator(BasicKeyInfoGeneratorFactory.BasicOptions newOptions, Class<? extends KeyInfo> type)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`protected KeyInfo`
`buildKeyInfo()`
Build a new KeyInfo instance.
`protected QName`
`classToElementName(Class<? extends KeyInfo> type)`
Map the specified KeyInfo type to an element `QName`.
`KeyInfo`
`generate(Credential credential)`
Generate a new KeyInfo object based on keying material and other information within a credential.
`protected void`
`processEntityID(KeyInfo keyInfo, Credential credential)`
Process the value of `Credential.getEntityId()`.
`protected void`
`processKeyNames(KeyInfo keyInfo, Credential credential)`
Process the values of `Credential.getKeyNames()`.
`protected void`
`processPublicKey(KeyInfo keyInfo, Credential credential)`
Process the value of `Credential.getPublicKey()`.

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

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

## Field Details

### options

@Nonnull private final BasicKeyInfoGeneratorFactory.BasicOptions options
The set of options to be used by the generator.

### keyInfoType

@Nonnull private final Class<? extends KeyInfo> keyInfoType
The specific type of KeyInfo to generate.

### builderFactory

@Nonnull private final XMLObjectBuilderFactory builderFactory
Builder factory for KeyInfo objects.

## Constructor Details

### BasicKeyInfoGenerator

protected BasicKeyInfoGenerator(@Nonnull BasicKeyInfoGeneratorFactory.BasicOptions newOptions, @Nullable Class<? extends KeyInfo> type)
Constructor.

Parameters:
  `newOptions` - the options to be used by the generator
  `type` - the type of element to produce

## Method Details

### generate

@Nullable public KeyInfo generate(@Nullable Credential credential) throws SecurityException
Generate a new KeyInfo object based on keying material and other information within a credential.

Specified by:
  `generate` in interface `KeyInfoGenerator`
Parameters:
  `credential` - the credential containing keying material and possibly other information
Returns:
  a new KeyInfo object or null if nothing was generated
Throws:
  `SecurityException` - thrown if there is any error generating the new KeyInfo from the credential

### buildKeyInfo

@Nonnull protected KeyInfo buildKeyInfo() throws SecurityException
Build a new KeyInfo instance.

The exact element type is determined by `keyInfoType` which was supplied at factory construction.

Returns:
  a new KeyInfo instance
Throws:
  `SecurityException` - if class type can not be mapped to an element `QName`

### classToElementName

@Nullable protected QName classToElementName(@Nonnull Class<? extends KeyInfo> type)
Map the specified KeyInfo type to an element `QName`.

Subclasses may override to implement new types or custom mappings.

Parameters:
  `type` - the KeyInfo element type
Returns:
  the mapped element name

### processKeyNames

protected void processKeyNames(@Nonnull KeyInfo keyInfo, @Nonnull Credential credential)
Process the values of `Credential.getKeyNames()`.

Parameters:
  `keyInfo` - the KeyInfo that is being built
  `credential` - the Credential that is geing processed

### processEntityID

protected void processEntityID(@Nonnull KeyInfo keyInfo, @Nonnull Credential credential)
Process the value of `Credential.getEntityId()`.

Parameters:
  `keyInfo` - the KeyInfo that is being built
  `credential` - the Credential that is geing processed

### processPublicKey

protected void processPublicKey(@Nonnull KeyInfo keyInfo, @Nonnull Credential credential) throws SecurityException
Process the value of `Credential.getPublicKey()`.

Parameters:
  `keyInfo` - the KeyInfo that is being built
  `credential` - the Credential that is being processed
Throws:
  `SecurityException` - if the public key can't be encoded properly