T
- the contained typepublic abstract class AbstractMetadataContainer<T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject> extends Object implements MetadataContainer<T>
MetadataContainer
interface.Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_DESCRIPTOR_ID_SIZE
Default size for the ID attribute string.
|
static float |
DEFAULT_UPDATE_FACTOR
The default update factor for the metadata - 0,75 (75%), i.e.
|
static Duration |
DEFAULT_VALIDITY
The default validity for metadata - one week.
|
protected T |
descriptor
The encapsulated descriptor element.
|
protected int |
idSize
The size of the ID attribute string.
|
protected X509Credential |
signatureCredentials
The signature credentials for signing the metadata entry.
|
protected float |
updateFactor
The update factor.
|
protected Duration |
validity
The validity time for created entries.
|
Constructor and Description |
---|
AbstractMetadataContainer(T descriptor,
X509Credential signatureCredentials)
Constructor assigning the encapsulated descriptor element.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
assignID(T descriptor,
String id)
Assigns the supplied id to the ID attribute of the descriptor.
|
T |
cloneDescriptor()
Returns a deep clone of the descriptor element that is encapsulated by this object.
|
T |
getDescriptor()
Returns the metadata element that is encapsulated by this object.
|
protected abstract String |
getID(T descriptor)
Returns the ID attribute of the supplied descriptor.
|
int |
getIdSize()
Returns the size of the ID attribute that is generated.
|
protected abstract String |
getLogString(T descriptor)
Returns a log string of the supplied descriptor.
|
float |
getUpdateFactor()
Returns the factor (between 0 and 1) that is used to compute whether it is time to update the contained
descriptor.
|
Duration |
getValidity()
Returns the duration of the validity that the encapsulated descriptor has.
|
Element |
marshall()
Marshals the encapsulated descriptor into its XML representation.
|
void |
setIdSize(int idSize)
Assigns the size of the ID attribute that is generated.
|
void |
setUpdateFactor(float updateFactor)
Assigns the factor (between 0 and 1) that is used to compute whether it is time to update the contained descriptor.
|
void |
setValidity(Duration validity)
Assigns the duration of the validity that the encapsulated
EntityDescriptor should have. |
T |
sign()
Signs the encapsulated descriptor using the signature credentials configured for this object.
|
T |
update(boolean sign)
Updates the encapsulated descriptor with a newly generated ID, a validity time according to this
object's configuration, and then optionally signs the record.
|
boolean |
updateRequired(boolean signatureRequired)
Predicate that returns
true if the contained descriptor needs to be updated regarding its signature
status and validity. |
public static final Duration DEFAULT_VALIDITY
public static final float DEFAULT_UPDATE_FACTOR
getUpdateFactor()
,
Constant Field Valuespublic static final int DEFAULT_DESCRIPTOR_ID_SIZE
protected T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject descriptor
protected Duration validity
protected float updateFactor
protected int idSize
protected X509Credential signatureCredentials
public AbstractMetadataContainer(T descriptor, X509Credential signatureCredentials)
descriptor
- the descriptor objectsignatureCredentials
- the signature credentials for signing the descriptor. May be null
, but then no signing will be
possiblepublic T getDescriptor()
getDescriptor
in interface MetadataContainer<T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject>
public T cloneDescriptor() throws MarshallingException, UnmarshallingException
cloneDescriptor
in interface MetadataContainer<T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject>
MarshallingException
- for marshalling errors of the objectUnmarshallingException
- for unmarshalling errors of the objectpublic boolean updateRequired(boolean signatureRequired)
true
if the contained descriptor needs to be updated regarding its signature
status and validity. The method will also take into account the update interval configured for this instance of the
container.updateRequired
in interface MetadataContainer<T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject>
signatureRequired
- should be set if signatures are required for a entry to be regarded validtrue
is returned, otherwise
false
public T update(boolean sign) throws SignatureException, MarshallingException
update
in interface MetadataContainer<T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject>
sign
- flag that should be set if the metadata is to be signedSignatureException
- for signature errorsMarshallingException
- for marshalling errorsMetadataContainer.sign()
public T sign() throws SignatureException, MarshallingException
sign
in interface MetadataContainer<T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject>
SignatureException
- for signature errorsMarshallingException
- for marshalling errorsMetadataContainer.update(boolean)
public Element marshall() throws MarshallingException
marshall
in interface MetadataContainer<T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject>
MarshallingException
- for marshalling errorspublic Duration getValidity()
getValidity
in interface MetadataContainer<T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject>
public void setValidity(Duration validity)
EntityDescriptor
should have.
The default value is DEFAULT_VALIDITY
.
validity
- the validitypublic float getUpdateFactor()
if (expireInstant > now) {
return <update-required>
}
else {
return (updateFactor * getValidity()) > (expireInstant - now) ? <update-required> : <no-update-required>
}
The easiest way to get the meaning of the update factor is perhaps using words. Suppose the update factor is 0,5,
then the meaning is: "update the metadata when less than 50% of its original validity time remains".getUpdateFactor
in interface MetadataContainer<T extends TimeBoundSAMLObject & SignableSAMLObject & CacheableSAMLObject>
public void setUpdateFactor(float updateFactor)
The default value is DEFAULT_UPDATE_FACTOR
.
updateFactor
- the update factorgetUpdateFactor()
public int getIdSize()
public void setIdSize(int idSize)
The default value is DEFAULT_DESCRIPTOR_ID_SIZE
.
idSize
- the sizeprotected abstract String getID(T descriptor)
descriptor
- the descriptorprotected abstract void assignID(T descriptor, String id)
descriptor
- the descriptorid
- the ID attribute valueCopyright © 2018 Litsec AB. All rights reserved.