net.shibboleth.metadata.dom.saml
Class PullUpCacheDurationStage

java.lang.Object
  extended by net.shibboleth.utilities.java.support.component.AbstractDestructableInitializableComponent
      extended by net.shibboleth.utilities.java.support.component.AbstractDestructableIdentifiableInitializableComponent
          extended by net.shibboleth.metadata.pipeline.BaseStage<ItemType>
              extended by net.shibboleth.metadata.pipeline.BaseIteratingStage<DomElementItem>
                  extended by net.shibboleth.metadata.dom.saml.PullUpCacheDurationStage
All Implemented Interfaces:
Stage<DomElementItem>, net.shibboleth.utilities.java.support.component.Component, net.shibboleth.utilities.java.support.component.DestructableComponent, net.shibboleth.utilities.java.support.component.IdentifiableComponent, net.shibboleth.utilities.java.support.component.InitializableComponent

@ThreadSafe
public class PullUpCacheDurationStage
extends BaseIteratingStage<DomElementItem>

For each Item collection element that is a SAML EntitiesDescriptor this stage will scan all descendant EntitiesDescriptors and EntityDescriptors, determine the shortest cache duration, set that on the root EntitiesDescriptor and remove the cache duration from all descendants.


Field Summary
private  long maxCacheDuration
          The maximum cache duration in milliseconds.
private  long minCacheDuration
          The minimum cache duration in milliseconds.
 
Constructor Summary
PullUpCacheDurationStage()
           
 
Method Summary
protected  boolean doExecute(DomElementItem item)
          Processes a given Item.
 long getMaximumCacheDuration()
          Gets the maximum cache duration in milliseconds.
 long getMinimumCacheDuration()
          Gets the minimum cache duration in milliseconds.
protected  Long getShortestCacheDuration(Element descriptor)
          Gets the shorts cache duration for a given entity and entities descriptor an all its descendant descriptors.
protected  void setCacheDuration(Element descriptor, Long cacheDuration)
          Sets the cache duration on the given descriptor.
 void setMaximumCacheDuration(long duration)
          Sets the maximum cache duration in milliseconds.
 void setMinimumCacheDuration(long duration)
          Sets the minimum cache duration in milliseconds.
 
Methods inherited from class net.shibboleth.metadata.pipeline.BaseIteratingStage
doExecute
 
Methods inherited from class net.shibboleth.metadata.pipeline.BaseStage
execute, setId
 
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractDestructableIdentifiableInitializableComponent
doInitialize, getId
 
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractDestructableInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.DestructableComponent
destroy, isDestroyed
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.IdentifiableComponent
getId
 
Methods inherited from interface net.shibboleth.utilities.java.support.component.InitializableComponent
initialize, isInitialized
 

Field Detail

minCacheDuration

private long minCacheDuration
The minimum cache duration in milliseconds. Default value: 0


maxCacheDuration

private long maxCacheDuration
The maximum cache duration in milliseconds. Default value: 9223372036854775807L

Constructor Detail

PullUpCacheDurationStage

public PullUpCacheDurationStage()
Method Detail

getMinimumCacheDuration

public long getMinimumCacheDuration()
Gets the minimum cache duration in milliseconds.

Returns:
minimum cache duration in milliseconds, always 0 or greater

setMinimumCacheDuration

public void setMinimumCacheDuration(long duration)
Sets the minimum cache duration in milliseconds.

Parameters:
duration - the minimum cache duration in milliseconds

getMaximumCacheDuration

public long getMaximumCacheDuration()
Gets the maximum cache duration in milliseconds.

Returns:
maximum cache duration in milliseconds, always greater than 0

setMaximumCacheDuration

public void setMaximumCacheDuration(long duration)
Sets the maximum cache duration in milliseconds.

Parameters:
duration - maximum cache duration in milliseconds, must be greater than 0

doExecute

protected boolean doExecute(@Nonnull
                            DomElementItem item)
                     throws StageProcessingException
Processes a given Item.

Specified by:
doExecute in class BaseIteratingStage<DomElementItem>
Parameters:
item - Item on which to operate
Returns:
true if the Item should be retained in the collection, false if not
Throws:
StageProcessingException - thrown if there is a problem with the stage processing

getShortestCacheDuration

protected Long getShortestCacheDuration(@Nonnull
                                        Element descriptor)
Gets the shorts cache duration for a given entity and entities descriptor an all its descendant descriptors.

Parameters:
descriptor - descriptor from which to get the shortest cache duration
Returns:
the shortest cache duration from the descriptor and its descendants or null if the descriptor does not contain a cache duration

setCacheDuration

protected void setCacheDuration(@Nonnull
                                Element descriptor,
                                @Nullable
                                Long cacheDuration)
Sets the cache duration on the given descriptor. If the given cache duration is less than, or equal to, 0 no duration is set. If the given cache duration is less than minCacheDuration then the minimum cache duration is set. If the given cache duration is greater than maxCacheDuration then the maximum cache duration is set. Otherwise the given cache duration is set.

Parameters:
descriptor - entity or entities descriptor to receive the cache duration, never null
cacheDuration - cache duration to be set, may be null


Copyright © 1999-2012. All Rights Reserved.