Class FlowDefinitionResourceFactory
- java.lang.Object
-
- net.shibboleth.idp.profile.spring.factory.FlowDefinitionResourceFactory
-
public class FlowDefinitionResourceFactory extends Object
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
Fields Modifier and Type Field Description private static StringCLASSPATH_SCHEMEClasspath scheme prefix.private static StringCLASSPATH_STAR_SCHEMEWildcard classpath scheme prefix.private static StringFILESYSTEM_SCHEMEFile scheme prefix.private ResourceLoaderresourceLoaderSpring resource loader.private static StringSLASHPath separator.
-
Constructor Summary
Constructors Constructor Description FlowDefinitionResourceFactory(ResourceLoader loader)Creates a new flow definition resource factory using the specified resource loader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FlowDefinitionResourcecreateResource(String basePath, String path, AttributeMap<Object> attributes, String flowId)Create a flow definition resource from the path location provided.Collection<FlowDefinitionResource>createResources(String basePath, String pattern, AttributeMap<Object> attributes)Create an array of flow definition resources from the path pattern location provided.protected StringgetFlowId(String basePath, Resource flowResource)Obtains the flow id from the flow resource.private booleanisAbsolute(String path)Check if a path starts with a known scheme.private StringremoveScheme(String path)Remove the scheme from a path.private StringtruncateFilePath(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 Detail
-
CLASSPATH_SCHEME
@Nonnull @NotEmpty private static final String CLASSPATH_SCHEME
Classpath scheme prefix.- See Also:
- Constant Field Values
-
CLASSPATH_STAR_SCHEME
@Nonnull @NotEmpty private static final String CLASSPATH_STAR_SCHEME
Wildcard classpath scheme prefix.- See Also:
- Constant Field Values
-
FILESYSTEM_SCHEME
@Nonnull @NotEmpty private static final String FILESYSTEM_SCHEME
File scheme prefix.- See Also:
- Constant Field Values
-
SLASH
@Nonnull @NotEmpty private static final String SLASH
Path separator.- See Also:
- Constant Field Values
-
resourceLoader
@Nonnull private final ResourceLoader resourceLoader
Spring resource loader.
-
-
Constructor Detail
-
FlowDefinitionResourceFactory
public FlowDefinitionResourceFactory(@Nonnull ResourceLoader loader)Creates a new flow definition resource factory using the specified resource loader.- Parameters:
loader- the resource loader
-
-
Method Detail
-
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 encodedResourcepath.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 encodedResourcepath 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
private boolean isAbsolute(@Nonnull @NotEmpty String path)
Check if a path starts with a known scheme.- Parameters:
path- path to check- Returns:
- true iff the path starts with a known scheme
-
-