/** * Set the map entry factory. * * <p> * In addition to implementing the {@link SAMLArtifactMapEntryFactory} interface, the injected * object must support the {@link StorageSerializer} interface to enable entries to be stored via the injected * {@link StorageService} instance. * </p> * * @param factory map entry factory */ public void setEntryFactory(@Nonnull final SAMLArtifactMapEntryFactory factory) { Constraint.isTrue(factory != null && factory instanceof StorageSerializer<?>, "SAMLArtifactMapEntryFactory cannot be null and must support the StorageSerializer interface"); entryFactory = factory; }
/** * Gets the value string. * * @return the value string. */ @Nullable public String getValue() { Constraint.isTrue(isPartialMatch(), "getValue is only meaningful for a partialMatch, use getPattern()"); return value; }
/** {@inheritDoc} We do not allow non-singleton beans, if we did then we loose constructability. */ @Override public void setSingleton(final boolean singleton) { Constraint.isTrue(singleton, "Can only be singleton"); super.setSingleton(singleton); }
/** * Constructor. * * @param baseDir the base directory, must be an absolute path * @param pp the parser pool instance to use */ public FilesystemLoadSaveManager(@Nonnull final File baseDir, @Nullable final ParserPool pp) { baseDirectory = Constraint.isNotNull(baseDir, "Base directory File instance was null"); Constraint.isTrue(baseDirectory.isAbsolute(), "Base directory specified was not an absolute path"); if (baseDirectory.exists()) { Constraint.isTrue(baseDirectory.isDirectory(), "Existing base directory path was not a directory"); } else { Constraint.isTrue(baseDirectory.mkdirs(), "Base directory did not exist and could not be created"); } parserPool = pp; if (parserPool == null) { parserPool = Constraint.isNotNull(XMLObjectProviderRegistrySupport.getParserPool(), "Specified ParserPool was null and global ParserPool was not available"); } fileFilter = new DefaultFileFilter(); }
/** * Constructor. * * @param baseDir the base directory, must be an absolute path * @param pp the parser pool instance to use */ public FilesystemLoadSaveManager(@Nonnull final File baseDir, @Nullable final ParserPool pp) { baseDirectory = Constraint.isNotNull(baseDir, "Base directory File instance was null"); Constraint.isTrue(baseDirectory.isAbsolute(), "Base directory specified was not an absolute path"); if (baseDirectory.exists()) { Constraint.isTrue(baseDirectory.isDirectory(), "Existing base directory path was not a directory"); } else { Constraint.isTrue(baseDirectory.mkdirs(), "Base directory did not exist and could not be created"); } parserPool = pp; if (parserPool == null) { parserPool = Constraint.isNotNull(XMLObjectProviderRegistrySupport.getParserPool(), "Specified ParserPool was null and global ParserPool was not available"); } fileFilter = new DefaultFileFilter(); }
/** * Convert a 2-byte artifact endpoint index byte[] as typically used by SAML 2 artifact types to an integer, * appropriate for use with {@link org.opensaml.saml.saml2.metadata.IndexedEndpoint} impls. * * <p> * The max input value supported is 0x7FFF (32767), which is the largest possible unsigned 16 bit value. * This should be more than sufficient for typical SAML cases. * </p> * * @param artifactEndpointIndex the endpoint index byte array, must have length == 2, and big endian byte order. * @return the convert integer value */ @Nonnull public static int convertSAML2ArtifactEndpointIndex(@Nonnull byte[] artifactEndpointIndex) { Constraint.isNotNull(artifactEndpointIndex, "Artifact endpoint index cannot be null"); Constraint.isTrue(artifactEndpointIndex.length == 2, "Artifact endpoint index length was not 2, was: " + artifactEndpointIndex.length); short value = ByteBuffer.wrap(artifactEndpointIndex).order(ByteOrder.BIG_ENDIAN).getShort(); return (int) Constraint.isGreaterThanOrEqual(0, value, "Input value was too large, resulting in a negative 16-bit short"); }
/** * Constructor. * * @param invokedPipeline the pipeline that will be invoked; must be initialized; can not be null * @param items the collection of items upon which the pipeline will operate, can not be null */ public PipelineCallable(@Nonnull final Pipeline<T> invokedPipeline, @Nonnull @NonnullElements final Collection<Item<T>> items) { pipeline = Constraint.isNotNull(invokedPipeline, "To-be-invoked pipeline can not be null"); Constraint.isTrue(invokedPipeline.isInitialized(), "To-be-invoked pipeline must be initialized"); itemCollection = Constraint.isNotNull(items, "Item collection can not be null"); }
/** * Constructor. * * @param definition attribute definition that was resolved to produce the given attribute * @param attribute attribute produced by the given attribute definition */ public ResolvedAttributeDefinition(@Nonnull final AttributeDefinition definition, @Nullable final IdPAttribute attribute) { resolvedDefinition = Constraint.isNotNull(definition, "Resolved attribute definition can not be null"); Constraint.isTrue(definition.isInitialized(), "Resolved definition must have been initialized"); Constraint.isFalse(definition.isDestroyed(), "Resolved definition can not have been destroyed"); resolvedAttribute = attribute; }
/** * Constructor. * * @param connector data connector that was resolved to produce the attributes * @param attributes attributes produced by the resolved data connector */ public ResolvedDataConnector(@Nonnull final DataConnector connector, @Nullable final Map<String, IdPAttribute> attributes) { resolvedConnector = Constraint.isNotNull(connector, "Resolved data connector cannot be null"); resolvedAttributes = attributes; Constraint.isTrue(connector.isInitialized(), "Provided connector should be initialized"); Constraint.isFalse(connector.isDestroyed(), "Provided connector must not be destroyed"); }
/** * Set the HTTP method. * * <p>Defaults to "POST".</p> * * @param m method */ public void setMethod(@Nonnull @NotEmpty final String m) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); ComponentSupport.ifDestroyedThrowDestroyedComponentException(this); method = Constraint.isNotNull(StringSupport.trimOrNull(m), "HTTP method cannot be null or empty"); Constraint.isTrue(HttpPost.METHOD_NAME.equals(method) || HttpPut.METHOD_NAME.equals(method), "HTTP method must be POST or PUT"); }
/** * Set the backing store for the cache. * * @param storageService backing store to use */ public void setStorage(@Nonnull final StorageService storageService) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); storage = Constraint.isNotNull(storageService, "StorageService cannot be null"); final StorageCapabilities caps = storage.getCapabilities(); if (caps instanceof StorageCapabilitiesEx) { Constraint.isTrue(((StorageCapabilitiesEx) caps).isServerSide(), "StorageService cannot be client-side"); } }
final String trimmedAttributeId = Constraint.isNotNull(StringSupport.trimOrNull(attributeId), "Attribute ID can not be null or empty"); Constraint.isTrue(prefilteredAttributes.containsKey(trimmedAttributeId), "no attribute with ID " + trimmedAttributeId + " exists in the pre-filtered attribute set");
final String trimmedAttributeId = Constraint.isNotNull(StringSupport.trimOrNull(attributeId), "Attribute ID can not be null or empty"); Constraint.isTrue(prefilteredAttributes.containsKey(trimmedAttributeId), "No attribute with ID " + trimmedAttributeId + " exists in the pre-filtered attribute set");
/** * Set the {@link StorageService} back-end to use. * * @param storage the back-end to use */ public void setStorageService(@Nonnull final StorageService storage) { ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this); storageService = Constraint.isNotNull(storage, "StorageService cannot be null"); final StorageCapabilities caps = storageService.getCapabilities(); if (caps instanceof StorageCapabilitiesEx) { Constraint.isTrue(((StorageCapabilitiesEx) caps).isServerSide(), "StorageService cannot be client-side"); if (!((StorageCapabilitiesEx) caps).isClustered()) { log.info("Use of non-clustered storage service will result in per-node lockout behavior"); } } }
/** * Check if a result generated by this flow is still active. * * @param result {@link AuthenticationResult} to check * * @return true iff the result remains valid */ public boolean isResultActive(@Nonnull final AuthenticationResult result) { Constraint.isNotNull(result, "AuthenticationResult cannot be null"); Constraint.isTrue(result.getAuthenticationFlowId().equals(getId()), "AuthenticationResult was not produced by this flow"); final long now = System.currentTimeMillis(); if (getLifetime() > 0 && result.getAuthenticationInstant() + getLifetime() <= now) { return false; } else if (getInactivityTimeout() > 0 && result.getLastActivityInstant() + getInactivityTimeout() <= now) { return false; } return true; }