/** * Set the record value, using a custom serialization process. * * @param instance the new record value * @param serializer a custom serialization process to apply * @throws IOException if serialization fails */ protected void setValue(@Nonnull final Type instance, @Nonnull final StorageSerializer<Type> serializer) throws IOException { value = serializer.serialize(instance); }
/** {@inheritDoc} */ @Override @Nonnull @NotEmpty public String serialize(@Nonnull final AuthenticationResult instance) throws IOException { ComponentSupport.ifNotInitializedThrowUninitializedComponentException(this); return resultSerializer.serialize(instance); }
/** {@inheritDoc} */ @Override public boolean create(@Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key, @Nonnull final Object value, @Nonnull final StorageSerializer serializer, @Nullable @Positive final Long expiration) throws IOException { return create(context, key, serializer.serialize(value), expiration); }
/** {@inheritDoc} */ @Override public boolean update(@Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key, @Nonnull final Object value, @Nonnull final StorageSerializer serializer, @Nullable @Positive final Long expiration) throws IOException { return update(context, key, serializer.serialize(value), expiration); }
/** {@inheritDoc} */ @Override public boolean update(@Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key, @Nonnull final Object value, @Nonnull final StorageSerializer serializer, @Nullable @Positive final Long expiration) throws IOException { Constraint.isNotNull(serializer, "Serializer cannot be null"); return update(context, key, serializer.serialize(value), expiration); }
/** {@inheritDoc} */ // Checkstyle: ParameterNumber OFF @Override @Nullable public Long updateWithVersion(@Positive final long version, @Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key, @Nonnull final Object value, @Nonnull final StorageSerializer serializer, @Nullable @Positive final Long expiration) throws IOException, VersionMismatchException { return updateWithVersion(version, context, key, serializer.serialize(value), expiration); }
/** {@inheritDoc} */ @Override public boolean create(@Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key, @Nonnull final Object value, @Nonnull final StorageSerializer serializer, @Nullable @Positive final Long expiration) throws IOException { Constraint.isNotNull(serializer, "Serializer cannot be null"); return create(context, key, serializer.serialize(value), expiration); }
/** {@inheritDoc} */ @Override public Long updateWithVersion(@Positive final long version, @Nonnull @NotEmpty final String context, @Nonnull @NotEmpty final String key, @Nonnull final Object value, @Nonnull final StorageSerializer serializer, @Nullable @Positive final Long expiration) throws IOException, VersionMismatchException { Constraint.isNotNull(serializer, "Serializer cannot be null"); return updateWithVersion(version, context, key, serializer.serialize(value), expiration); }
/** {@inheritDoc} */ @Override @Nonnull @NotEmpty public String serialize(@Nonnull final Principal principal) throws IOException { final StringWriter sink = new StringWriter(128); final JsonGenerator gen = getJsonGenerator(sink); gen.writeStartObject(); final AuthenticationResult result = ((AuthenticationResultPrincipal) principal).getAuthenticationResult(); gen.write(PRINCIPAL_NAME_FIELD, resultSerializer.serialize(result)); gen.writeEnd(); gen.close(); return sink.toString(); }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { try { final Map<String, Consent> currentConsents = getConsentContext().getCurrentConsents(); final String value = getStorageSerializer().serialize(currentConsents); final long expiration = DateTime.now().plus(getConsentFlowDescriptor().getLifetime()).getMillis(); final ProfileInterceptorResult result = new ConsentResult(getStorageContext(), getStorageKey(), value, expiration); log.debug("{} Created consent result '{}'", getLogPrefix(), result); storeResultWithIndex(profileRequestContext, result); } catch (final IOException e) { log.debug("{} Unable to serialize consent", getLogPrefix(), e); } }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { try { final Map<String, Consent> currentConsents = getConsentContext().getCurrentConsents(); final String value = getStorageSerializer().serialize(currentConsents); final long expiration = DateTime.now().plus(getConsentFlowDescriptor().getLifetime()).getMillis(); final ProfileInterceptorResult result = new ConsentResult(getStorageContext(), getStorageKey(), value, expiration); log.debug("{} Created consent result '{}'", getLogPrefix(), result); storeResultWithIndex(profileRequestContext, result); } catch (final IOException e) { log.debug("{} Unable to serialize consent", getLogPrefix(), e); } }
/** * Encode a ticket. * * @param ticketClass class of ticket * @param ticket ticket * @param prefix ticket ID prefix * @param <T> type of ticket * * @return ticket encoded ticket */ private <T extends Ticket> T encode(final Class<T> ticketClass, final T ticket, final String prefix) { final String opaque; try { opaque = dataSealer.wrap( serializer(ticketClass).serialize(ticket), ticket.getExpirationInstant().getMillis()); } catch (final Exception e) { throw new RuntimeException("Ticket encoding failed", e); } return ticketClass.cast(ticket.clone(prefix + '-' + opaque)); }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { try { final Consent globalConsent = new Consent(); globalConsent.setId(Consent.WILDCARD); globalConsent.setApproved(true); final String value = getStorageSerializer().serialize(Collections.singletonMap(globalConsent.getId(), globalConsent)); final long expiration = DateTime.now().plus(getConsentFlowDescriptor().getLifetime()).getMillis(); final ProfileInterceptorResult result = new ConsentResult(getStorageContext(), getStorageKey(), value, expiration); log.debug("{} Created global consent result '{}'", getLogPrefix(), result); storeResultWithIndex(profileRequestContext, result); } catch (IOException e) { log.debug("{} Unable to serialize consent", getLogPrefix(), e); ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR); } } }
/** {@inheritDoc} */ @Override protected void doExecute(@Nonnull final ProfileRequestContext profileRequestContext, @Nonnull final ProfileInterceptorContext interceptorContext) { try { final Consent globalConsent = new Consent(); globalConsent.setId(Consent.WILDCARD); globalConsent.setApproved(true); final String value = getStorageSerializer().serialize(Collections.singletonMap(globalConsent.getId(), globalConsent)); final long expiration = DateTime.now().plus(getConsentFlowDescriptor().getLifetime()).getMillis(); final ProfileInterceptorResult result = new ConsentResult(getStorageContext(), getStorageKey(), value, expiration); log.debug("{} Created global consent result '{}'", getLogPrefix(), result); storeResultWithIndex(profileRequestContext, result); } catch (final IOException e) { log.debug("{} Unable to serialize consent", getLogPrefix(), e); ActionSupport.buildEvent(profileRequestContext, EventIds.IO_ERROR); } } }
builder.append(':').append(spSessionSerializer.serialize(session));