Package net.shibboleth.idp.profile.spring.factory

# 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 final String`
`CLASSPATH_SCHEME`
Classpath scheme prefix.
`private static final String`
`CLASSPATH_STAR_SCHEME`
Wildcard classpath scheme prefix.
`private static final String`
`FILESYSTEM_SCHEME`
File scheme prefix.
`private final ResourceLoader`
`resourceLoader`
Spring resource loader.
`private static final String`
`SLASH`
Path separator.

## Constructor Summary

Constructors
Constructor
Description
`FlowDefinitionResourceFactory(ResourceLoader loader)`
Creates a new flow definition resource factory using the specified resource loader.

## Method Summary

Modifier and Type
Method
Description
`FlowDefinitionResource`
`createResource(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 String`
`getFlowId(String basePath, Resource flowResource)`
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.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### 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 Details

### FlowDefinitionResourceFactory

public FlowDefinitionResourceFactory(@Nonnull ResourceLoader loader)
Creates a new flow definition resource factory using the specified resource loader.

Parameters:
  `loader` - the resource loader

## Method Details

### createResource

@Nonnull 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 path
  `path` - the encoded `Resource` path.
  `attributes` - the flow definition meta attributes to configure
  `flowId` - 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 IDs
  `pattern` - the encoded `Resource` path pattern
  `attributes` - 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 computation
  `flowResource` - 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 examine
  `basePath` - 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

### removeScheme

@Nonnull private String removeScheme(@Nonnull @NotEmpty String path)
Remove the scheme from a path.

Parameters:
  `path` - path to strip
Returns:
  the input with the scheme removed.