/** {@inheritDoc} */ public synchronized void destroy() { metadataResource = null; super.destroy(); }
@Override public void run() { if (_idpMetaDataProvider == null) { return; } s_logger.debug("Starting SAML IDP Metadata Refresh Task"); Map <String, SAMLProviderMetadata> metadataMap = new HashMap<String, SAMLProviderMetadata>(); try { discoverAndAddIdp(_idpMetaDataProvider.getMetadata(), metadataMap); _idpMetadataMap = metadataMap; expireTokens(); s_logger.debug("Finished refreshing SAML Metadata and expiring old auth tokens"); } catch (MetadataProviderException e) { s_logger.warn("SAML Metadata Refresh task failed with exception: " + e.getMessage()); } } }
filterMetadata(metadata); } catch (FilterException e) { String errMsg = "Error filtering metadata from " + metadataIdentifier; releaseMetadataDOM(metadata); postProcessMetadata(metadataBytes, metadataDom, metadata); SAML2Helper.getEarliestExpiration(metadata, refreshStart.plus(getMaxRefreshDelay()), refreshStart); log.debug("Expiration of metadata from '{}' will occur at {}", metadataIdentifier, metadataExpirationTime.toString()); expirationTime = new DateTime(ISOChronology.getInstanceUTC()).plus(getMinRefreshDelay()); nextRefreshDelay = getMaxRefreshDelay(); } else { expirationTime = metadataExpirationTime; nextRefreshDelay = computeNextRefreshDelay(expirationTime); emitChangeEvent(); log.info("New metadata succesfully loaded for '{}'", getMetadataIdentifier());
String mdId = getMetadataIdentifier(); byte[] mdBytes = fetchMetadata(); if (mdBytes == null) { log.debug("Metadata from '{}' has not changed since last refresh", mdId); processCachedMetadata(mdId, now); } else { log.debug("Processing new metadata from '{}'", mdId); processNewMetadata(mdId, now, mdBytes);
/** * Processes a cached metadata document in order to determine, and schedule, the next time it should be refreshed. * * @param metadataIdentifier identifier of the metadata source * @param refreshStart when the current refresh cycle started * * @throws MetadataProviderException throw is there is a problem process the cached metadata */ protected void processCachedMetadata(String metadataIdentifier, DateTime refreshStart) throws MetadataProviderException { log.debug("Computing new expiration time for cached metadata from '{}", metadataIdentifier); DateTime metadataExpirationTime = SAML2Helper .getEarliestExpiration(cachedMetadata, refreshStart.plus(getMaxRefreshDelay()), refreshStart); expirationTime = metadataExpirationTime; long nextRefreshDelay = computeNextRefreshDelay(expirationTime); nextRefresh = new DateTime(ISOChronology.getInstanceUTC()).plus(nextRefreshDelay); }
/** * Computes the delay until the next refresh time based on the current metadata's expiration time and the refresh * interval floor. * * @param expectedExpiration the time when the metadata is expected to expire and need refreshing * * @return delay, in milliseconds, until the next refresh time */ protected long computeNextRefreshDelay(DateTime expectedExpiration) { long now = new DateTime(ISOChronology.getInstanceUTC()).getMillis(); long expireInstant = 0; if (expectedExpiration != null) { expireInstant = expectedExpiration.toDateTime(ISOChronology.getInstanceUTC()).getMillis(); } long refreshDelay = (long) ((expireInstant - now) * getRefreshDelayFactor()); // if the expiration time was null or the calculated refresh delay was less than the floor // use the floor if (refreshDelay < getMinRefreshDelay()) { refreshDelay = getMinRefreshDelay(); } return refreshDelay; }
/** * Processes metadata that has been determined to be invalid (usually because it's already expired) at the time it * was fetched. A metadata document is considered be invalid if its root element returns false when passed to the * {@link #isValid(XMLObject)} method. * * @param metadataIdentifier identifier of the metadata source * @param refreshStart when the current refresh cycle started * @param metadataBytes raw bytes of the new metadata document * @param metadata new metadata document unmarshalled */ protected void processPreExpiredMetadata(String metadataIdentifier, DateTime refreshStart, byte[] metadataBytes, XMLObject metadata) { log.warn("Entire metadata document from '{}' was expired at time of loading, existing metadata retained", metadataIdentifier); lastUpdate = refreshStart; nextRefresh = new DateTime(ISOChronology.getInstanceUTC()).plus(getMinRefreshDelay()); }
/** {@inheritDoc} */ public synchronized void destroy() { httpClient = null; metadataURI = null; cachedMetadataETag = null; cachedMetadataLastModified = null; authScope = null; super.destroy(); }
/** {@inheritDoc} */ public synchronized void destroy() { metadataFile = null; super.destroy(); }