/** {@inheritDoc} */ @Override public boolean contains(@Nonnull @NotEmpty final String artifact) throws IOException { if (artifact.length() > artifactStoreKeySize) { throw new IOException("Length of artifact (" + artifact.length() + ") exceeds storage capabilities"); } return getStorageService().read(STORAGE_CONTEXT, artifact) != null; }
/** {@inheritDoc} */ @Override @Nullable public SAMLArtifactMapEntry get(@Nonnull @NotEmpty final String artifact) throws IOException { log.debug("Attempting to retrieve entry for artifact: {}", artifact); if (artifact.length() > artifactStoreKeySize) { throw new IOException("Length of artifact (" + artifact.length() + ") exceeds storage capabilities"); } final StorageRecord record = getStorageService().read(STORAGE_CONTEXT, artifact); if (record == null) { log.debug("No unexpired entry found for artifact: {}", artifact); return null; } log.debug("Found valid entry for artifact: {}", artifact); return (SAMLArtifactMapEntry) record.getValue((StorageSerializer) getEntryFactory(), STORAGE_CONTEXT, artifact); }
storageService.read(sessionId, SESSION_MASTER_KEY); if (sessionRecord != null) { return sessionRecord.getValue(serializer, sessionId, SESSION_MASTER_KEY);
try { final String context = context(clazz); final StorageRecord<T> sessionRecord = storageService.read(context, id); if (sessionRecord == null) { log.debug("{} not found in context {}", id, context); final StorageRecord<T> ticketRecord = storageService.read(sessionId, id); if (ticketRecord == null) { log.debug("{} not found in context {}", id, sessionId);
/** * Get the counter for the given storage key. * * @param storageService the storage service * @param storageContext the storage context * @param storageKey the storage key * @return the counter for the given storage key * @throws IOException if a storage service error occurs * @throws NumberFormatException if the storage record value cannot be parsed as an integer */ @Nullable protected Long getStorageKeyCounter(@Nonnull final StorageService storageService, @Nonnull final String storageContext, @Nonnull final String storageKey) throws IOException { Constraint.isNotNull(storageService, "Storage service cannot be null"); Constraint.isNotNull(storageContext, "Storage context cannot be null"); Constraint.isNotNull(storageKey, "Storage key cannot be null"); final String counterStorageKey = getCounterStorageKey(storageKey); final StorageRecord storageRecord = storageService.read(storageContext, counterStorageKey); log.debug("Read storage record '{}' with context '{}' and key '{}'", storageRecord, storageContext, counterStorageKey); return (storageRecord == null) ? null : storageRecord.getVersion(); }
/** * Get the counter for the given storage key. * * @param storageService the storage service * @param storageContext the storage context * @param storageKey the storage key * @return the counter for the given storage key * @throws IOException if a storage service error occurs * @throws NumberFormatException if the storage record value cannot be parsed as an integer */ @Nullable protected Long getStorageKeyCounter(@Nonnull final StorageService storageService, @Nonnull final String storageContext, @Nonnull final String storageKey) throws IOException { Constraint.isNotNull(storageService, "Storage service cannot be null"); Constraint.isNotNull(storageContext, "Storage context cannot be null"); Constraint.isNotNull(storageKey, "Storage key cannot be null"); final String counterStorageKey = getCounterStorageKey(storageKey); final StorageRecord storageRecord = storageService.read(storageContext, counterStorageKey); log.debug("Read storage record '{}' with context '{}' and key '{}'", storageRecord, storageContext, counterStorageKey); return (storageRecord == null) ? null : storageRecord.getVersion(); }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { try { final String value = Long.toString(System.currentTimeMillis()); final String context = getStorageContext(); final String key = getStorageKey(); final StorageRecord storageRecord = getStorageService().read(context, key); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, context, key); if (storageRecord == null) { log.debug("{} Creating counter with value '{}'", getLogPrefix(), value); getStorageService().create(context, key, value, null); } else { log.debug("{} Updating counter with value '{}'", getLogPrefix(), value); getStorageService().update(context, key, value, null); } } catch (final IOException e) { log.debug("{} Unable to update counter", getLogPrefix(), e); } }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { final String context = getStorageContext(); final String key = getStorageKey(); try { final StorageRecord storageRecord = getStorageService().read(context, key); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, context, key); if (storageRecord == null) { log.debug("{} No storage record for context '{}' and key '{}'", getLogPrefix(), context, key); return; } final Map<String, Consent> consents = (Map<String, Consent>) storageRecord.getValue(getStorageSerializer(), context, key); getConsentContext().getPreviousConsents().putAll(consents); } catch (final IOException e) { log.error("{} Unable to read consent from storage", getLogPrefix(), e); } }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { try { final String value = Long.toString(System.currentTimeMillis()); final String context = getStorageContext(); final String key = getStorageKey(); final StorageRecord storageRecord = getStorageService().read(context, key); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, context, key); if (storageRecord == null) { log.debug("{} Creating counter with value '{}'", getLogPrefix(), value); getStorageService().create(context, key, value, null); } else { log.debug("{} Updating counter with value '{}'", getLogPrefix(), value); getStorageService().update(context, key, value, null); } } catch (final IOException e) { log.debug("{} Unable to update counter", getLogPrefix(), e); } }
final StorageRecord<AuthenticationResult> record = sessionManager.getStorageService().read(getId(), flowId); if (record != null) { return record.getValue(flow, getId(), flowId);
StorageRecord entry = storage.read(context, key); if (entry == null) { log.debug("Value '{}' was not a replay, adding to cache with expiration time {}", s, expires);
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { final String context = getStorageContext(); final String key = getStorageKey(); try { final StorageRecord storageRecord = getStorageService().read(context, key); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, context, key); if (storageRecord == null) { log.debug("{} No storage record for context '{}' and key '{}'", getLogPrefix(), context, key); return; } final Map<String, Consent> consents = (Map<String, Consent>) storageRecord.getValue(getStorageSerializer(), context, key); getConsentContext().getPreviousConsents().putAll(consents); } catch (final IOException e) { log.error("{} Unable to read consent from storage", getLogPrefix(), e); } }
/** * Get the storage keys from the storage index record. * * @return the storage keys from the storage index record * @throws IOException if errors occur in the read process */ @Nonnull @NonnullElements protected List<String> getStorageKeysFromIndex() throws IOException { final StorageRecord storageRecord = getStorageService().read(getStorageContext(), getStorageIndexKey()); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, getStorageContext(), getStorageIndexKey()); if (storageRecord == null) { return Collections.emptyList(); } return new ArrayList<>((Collection<String>) storageRecord.getValue(getStorageKeysSerializer(), getStorageContext(), getStorageIndexKey())); }
/** * Get the storage keys from the storage index record. * * @return the storage keys from the storage index record * @throws IOException if errors occur in the read process */ @Nonnull @NonnullElements protected List<String> getStorageKeysFromIndex() throws IOException { final StorageRecord storageRecord = getStorageService().read(getStorageContext(), getStorageIndexKey()); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, getStorageContext(), getStorageIndexKey()); if (storageRecord == null) { return Collections.emptyList(); } return new ArrayList<>((Collection<String>) storageRecord.getValue(getStorageKeysSerializer(), getStorageContext(), getStorageIndexKey())); }
/** * Remove a storage key from the index storage record. * * @param keyToRemove storage key to remove from the index storage record * @return true if key removal succeeded, false otherwise * @throws IOException if an error occurs writing to the storage service */ protected boolean removeKeyFromStorageIndex(@Nonnull final String keyToRemove) throws IOException { final StorageRecord storageRecord = getStorageService().read(getStorageContext(), getStorageIndexKey()); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, getStorageContext(), getStorageIndexKey()); if (storageRecord == null) { log.debug("{} No storage record exists with context '{}' and key '{}', nothing to do", getLogPrefix(), getStorageContext(), getStorageIndexKey()); return false; } else { final LinkedHashSet<String> keys = new LinkedHashSet<>(getStorageKeysFromIndex()); if (keys.remove(keyToRemove)) { log.debug("{} Updating storage index by removing key '{}'", getLogPrefix(), keyToRemove); return getStorageService().update(getStorageContext(), storageIndexKey, keys, storageKeysSerializer, null); } else { log.debug("{} Storage key '{}' not indexed, nothing to do", getLogPrefix(), keyToRemove); return false; } } }
final StorageRecord record = idStore.read(TransientIdParameters.CONTEXT, transientId); if (null == record) { log.info("{} Could not find transient identifier", getLogPrefix());
/** * Remove a storage key from the index storage record. * * @param keyToRemove storage key to remove from the index storage record * @return true if key removal succeeded, false otherwise * @throws IOException if an error occurs writing to the storage service */ protected boolean removeKeyFromStorageIndex(@Nonnull final String keyToRemove) throws IOException { final StorageRecord storageRecord = getStorageService().read(getStorageContext(), getStorageIndexKey()); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, getStorageContext(), getStorageIndexKey()); if (storageRecord == null) { log.debug("{} No storage record exists with context '{}' and key '{}', nothing to do", getLogPrefix(), getStorageContext(), getStorageIndexKey()); return false; } else { final LinkedHashSet<String> keys = new LinkedHashSet<>(getStorageKeysFromIndex()); if (keys.remove(keyToRemove)) { log.debug("{} Updating storage index by removing key '{}'", getLogPrefix(), keyToRemove); return getStorageService().update(getStorageContext(), storageIndexKey, keys, storageKeysSerializer, null); } else { log.debug("{} Storage key '{}' not indexed, nothing to do", getLogPrefix(), keyToRemove); return false; } } }
/** * Add a storage key to the index storage record. * * @param keyToAdd storage key to add to the index storage record * @return true if key addition succeeded, false otherwise * @throws IOException if an error occurs writing to the storage service */ protected boolean addKeyToStorageIndex(@Nonnull final String keyToAdd) throws IOException { final StorageRecord storageRecord = getStorageService().read(getStorageContext(), getStorageIndexKey()); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, getStorageContext(), getStorageIndexKey()); if (storageRecord == null) { log.debug("{} Creating storage index with key '{}'", getLogPrefix(), keyToAdd); return getStorageService().create(getStorageContext(), getStorageIndexKey(), Collections.singletonList(keyToAdd), storageKeysSerializer, null); } else { final LinkedHashSet<String> keys = new LinkedHashSet<>(getStorageKeysFromIndex()); if (keys.add(keyToAdd)) { log.debug("{} Updating storage index by adding key '{}'", getLogPrefix(), keyToAdd); return getStorageService().update(getStorageContext(), getStorageIndexKey(), keys, storageKeysSerializer, null); } else { log.debug("{} Storage key '{}' already indexed, nothing to do", getLogPrefix(), keyToAdd); return false; } } }
/** * Add a storage key to the index storage record. * * @param keyToAdd storage key to add to the index storage record * @return true if key addition succeeded, false otherwise * @throws IOException if an error occurs writing to the storage service */ protected boolean addKeyToStorageIndex(@Nonnull final String keyToAdd) throws IOException { final StorageRecord storageRecord = getStorageService().read(getStorageContext(), getStorageIndexKey()); log.debug("{} Read storage record '{}' with context '{}' and key '{}'", getLogPrefix(), storageRecord, getStorageContext(), getStorageIndexKey()); if (storageRecord == null) { log.debug("{} Creating storage index with key '{}'", getLogPrefix(), keyToAdd); return getStorageService().create(getStorageContext(), getStorageIndexKey(), Collections.singletonList(keyToAdd), storageKeysSerializer, null); } else { final LinkedHashSet<String> keys = new LinkedHashSet<>(getStorageKeysFromIndex()); if (keys.add(keyToAdd)) { log.debug("{} Updating storage index by adding key '{}'", getLogPrefix(), keyToAdd); return getStorageService().update(getStorageContext(), getStorageIndexKey(), keys, storageKeysSerializer, null); } else { log.debug("{} Storage key '{}' already indexed, nothing to do", getLogPrefix(), keyToAdd); return false; } } }
sessionManager.getStorageService().read(getId(), StorageBackedSessionManager.SESSION_MASTER_KEY); if (record == null) { log.error("Record for session {} has disappeared from backing store", getId());