Class FlowDefinitionResourceFactory
java.lang.Object
net.shibboleth.idp.profile.spring.factory.FlowDefinitionResourceFactory
Derivation of SWF-supplied resource factory for flow definitions.
This implementation overrides the behavior of the built-in factory with regard to handling absolute paths while still supporting relative paths.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
Classpath scheme prefix.private static final String
Wildcard classpath scheme prefix.private static final String
File scheme prefix.private final ResourceLoader
Spring resource loader.private static final String
Path separator. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new flow definition resource factory using the specified resource loader. -
Method Summary
Modifier and TypeMethodDescriptioncreateResource
(String basePath, String path, AttributeMap<Object> attributes, String flowId) Create a flow definition resource from the path location provided.createResources
(String basePath, String pattern, AttributeMap<Object> attributes) Create an array of flow definition resources from the path pattern location provided.protected String
Obtains the flow id from the flow resource.private boolean
isAbsolute
(String path) Check if a path starts with a known scheme.private String
removeScheme
(String path) Remove the scheme from a path.private String
truncateFilePath
(String filePath, String basePath) If the file path contains the base path, then the part after the base path is returned, otherwise the entire file path is returned.
-
Field Details
-
CLASSPATH_SCHEME
Classpath scheme prefix.- See Also:
-
CLASSPATH_STAR_SCHEME
Wildcard classpath scheme prefix.- See Also:
-
FILESYSTEM_SCHEME
File scheme prefix.- See Also:
-
SLASH
Path separator.- See Also:
-
resourceLoader
Spring resource loader.
-
-
Constructor Details
-
FlowDefinitionResourceFactory
Creates a new flow definition resource factory using the specified resource loader.- Parameters:
loader
- the resource loader
-
-
Method Details
-
createResource
public FlowDefinitionResource createResource(@Nullable String basePath, @Nonnull @NotEmpty String path, @Nonnull AttributeMap<Object> attributes, @Nonnull @NotEmpty String flowId) Create a flow definition resource from the path location provided. The returned resource will be configured with the provided attributes and flow id.- Parameters:
basePath
- base location to use for a relative pathpath
- the encodedResource
path.attributes
- the flow definition meta attributes to configureflowId
- the flow definition id to configure- Returns:
- the flow definition resource
-
createResources
@Nonnull public Collection<FlowDefinitionResource> createResources(@Nonnull @NotEmpty String basePath, @Nonnull @NotEmpty String pattern, @Nonnull AttributeMap<Object> attributes) throws IOException Create an array of flow definition resources from the path pattern location provided.Unlike in the explicit case, we must have a base location provided here to properly compute the flow IDs.
- Parameters:
basePath
- base location for a relative path and in truncating to obtain the flow IDspattern
- the encodedResource
path patternattributes
- the flow definition meta attributes to configure- Returns:
- the flow definition resources
- Throws:
IOException
- if resolving the resources fails
-
getFlowId
protected String getFlowId(@Nonnull @NotEmpty String basePath, @Nonnull Resource flowResource) throws IOException Obtains the flow id from the flow resource. By default, the flow id becomes the portion of the path between the basePath and the filename.This is the key override from the SWF version, because it only operates on pattern-based flows, and it assumes a base path to strip. Explicit flow mappings are all assumed to have a flow ID explicitly assigned.
- Parameters:
basePath
- the base path applied to the computationflowResource
- the flow resource- Returns:
- the flow id
- Throws:
IOException
- if unable to obtain information about the underlying resource
-
truncateFilePath
@Nonnull @NotEmpty private String truncateFilePath(@Nonnull @NotEmpty String filePath, @Nonnull @NotEmpty String basePath) If the file path contains the base path, then the part after the base path is returned, otherwise the entire file path is returned.- Parameters:
filePath
- file path to examinebasePath
- base path to strip- Returns:
- result as above
-
isAbsolute
Check if a path starts with a known scheme.- Parameters:
path
- path to check- Returns:
- true iff the path starts with a known scheme
-
removeScheme
Remove the scheme from a path.- Parameters:
path
- path to strip- Returns:
- the input with the scheme removed.
-