Package org.opensaml.xmlsec.agreement.impl

# Class KANonce

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.xmlsec.agreement.impl.KANonce

All Implemented Interfaces:
  `Cloneable`, `Component`, `DestructableComponent`, `InitializableComponent`, `CloneableKeyAgreementParameter`, `KeyAgreementParameter`, `XMLExpressableKeyAgreementParameter`

public class KANonce extends AbstractInitializableComponent implements XMLExpressableKeyAgreementParameter, CloneableKeyAgreementParameter
Key agreement parameter to support use of `KANonce` values.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`KANonce.Parser`
Implementation of `KeyAgreementParameterParser`.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final Integer`
`DEFAULT_GENERATED_LENGTH`
Default length for generated salt, in bytes.
`private Integer`
`generatedLength`
Generated salt length, in bytes.
`private SecureRandom`
`secureRandom`
SecureRandom generator for salt.
`private String`
`value`
Base64-encoded nonce value.

## Constructor Summary

Constructors
Constructor
Description
`KANonce()`

## Method Summary

Modifier and Type
Method
Description
`XMLObject`
`buildXMLObject()`
Build an `XMLObject` instance representing this parameter.
`KANonce`
`clone()`
Clone the parameter instance.
`protected void`
`doInitialize()`
`static KANonce`
`fromXMLObject(KANonce xmlObject)`
Create and initialize a new instance from the specified `XMLObject`.
`protected String`
`generateValue()`
Generate a new random value.
`Integer`
`getGeneratedLength()`
Get the generated length, in bytes.
`SecureRandom`
`getRandom()`
Get the secure random generator.
`String`
`getValue()`
Get the Base64-encoded nonce value.
`void`
`setGeneratedLength(Integer length)`
Set the generated length, in bytes.
`void`
`setRandom(SecureRandom sr)`
Set the secure random generator.
`void`
`setValue(String newValue)`
Set the Base64-encoded nonce value.

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

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

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

## Field Details

### DEFAULT_GENERATED_LENGTH

@Nonnull public static final Integer DEFAULT_GENERATED_LENGTH
Default length for generated salt, in bytes.

### value

@Nullable private String value
Base64-encoded nonce value.

### generatedLength

@NonnullAfterInit private Integer generatedLength
Generated salt length, in bytes.

### secureRandom

@NonnullAfterInit private SecureRandom secureRandom
SecureRandom generator for salt.

## Constructor Details

### KANonce

public KANonce()

## Method Details

### getValue

@Nullable public String getValue()
Get the Base64-encoded nonce value.

Returns:
  the nonce value

### setValue

public void setValue(@Nullable String newValue)
Set the Base64-encoded nonce value.

Parameters:
  `newValue` - the nonce value

### getGeneratedLength

@NonnullAfterInit public Integer getGeneratedLength()
Get the generated length, in bytes.

Returns:
  the generated length, in bytes

### setGeneratedLength

public void setGeneratedLength(@Nullable Integer length)
Set the generated length, in bytes.

Parameters:
  `length` - the generated length

### getRandom

@NonnullAfterInit public SecureRandom getRandom()
Get the secure random generator.

Defaults to the platform default via `new SecureRandom()`

Returns:
  the secure random instance

### setRandom

public void setRandom(@Nullable SecureRandom sr)
Set the secure random generator.

Defaults to the platform default via `new SecureRandom()`

Parameters:
  `sr` - the secure random generator to set

### doInitialize

protected void doInitialize() throws ComponentInitializationException

Overrides:
  `doInitialize` in class `AbstractInitializableComponent`
Throws:
  `ComponentInitializationException`

### generateValue

protected String generateValue()
Generate a new random value.

Returns:
  the generated value

### clone

public KANonce clone()
Clone the parameter instance.

Specified by:
  `clone` in interface `CloneableKeyAgreementParameter`
Overrides:
  `clone` in class `Object`
Returns:
  the cloned parameter

### buildXMLObject

@Nonnull public XMLObject buildXMLObject()
Build an `XMLObject` instance representing this parameter.

Specified by:
  `buildXMLObject` in interface `XMLExpressableKeyAgreementParameter`
Returns:
  the XML object instance

### fromXMLObject

@Nonnull public static KANonce fromXMLObject(@Nonnull KANonce xmlObject) throws ComponentInitializationException
Create and initialize a new instance from the specified `XMLObject`.

Parameters:
  `xmlObject` - the XML object
Returns:
  new parameter instance
Throws:
  `ComponentInitializationException` - if component initialization fails