<commit_before># io.ifar: dw-shiro-bundle

ShiroBundle for DropWizard.

Simplifies Shiro configuration and usage in a DropWizard stack.

## Functionality

The bundle initializes Shiro to work within Dropwizard.  The functionality has three steps:

1. Optionally add a Jetty SessionHandler to the Dropwizard environment.  This is done only if a) the `ShiroConfiguration` `dropwizard_session_handler` property is`true`, and b) the environment doesn't already have a SessionHandler set.
2. Add the Shiro `EnvironmentLoaderListener` to the Dropwizard environment.  This will initialize Shiro.
3. Add a `ShiroFilter` instance to handle URLs matching the configured pattern.

The rest of the functionality and configuration are provided by Shiro and/or Dropwizard directly.

## Usage

Include the maven dependency:

        <dependency>
            <groupId>io.ifar</groupId>
            <artifactId>dw-shiro-bundle</artifactId>
            <version>${current.release.version}</version>
        </dependency>

Add an instance of the ShiroBundle to your service. For example,

    ...
    import io.ifar.dropwizard.shiro.ShiroBundle;
    import io.ifar.dropwizard.shiro.ShiroConfiguration;
    ...
    private final ShiroBundle shiroBundle =
            new ShiroBundle<MyConfiguration>() {
                @Override public Optional<ShiroConfiguration> getShiroConfiguration(final MyConfiguration configuration)
                { return Optional.<ShiroConfiguration>fromNullable(configuration.getShiroConfiguration()); }
            };
    ...
    @Override
    public void initialize(final Bootstrap<MyConfiguration> bootstrap) {
        ...
        bootstrap.addBundle(this.shiroBundle);
        ...
    }
    ...

Of course you will need to expose the `ShiroConfiguration` via the `MyConfiguration` instance:

    ...<commit_msg>one set of maven instructions suffices<commit_after># io.ifar: dw-shiro-bundle

ShiroBundle for DropWizard.

Simplifies Shiro configuration and usage in a DropWizard stack.

## Functionality

The bundle initializes Shiro to work within Dropwizard.  The functionality has three steps:

1. Optionally add a Jetty SessionHandler to the Dropwizard environment.  This is done only if a) the `ShiroConfiguration` `dropwizard_session_handler` property is`true`, and b) the environment doesn't already have a SessionHandler set.
2. Add the Shiro `EnvironmentLoaderListener` to the Dropwizard environment.  This will initialize Shiro.
3. Add a `ShiroFilter` instance to handle URLs matching the configured pattern.

The rest of the functionality and configuration are provided by Shiro and/or Dropwizard directly.

## Usage

Include [the maven dependency](#access-with-maven).

Add an instance of the ShiroBundle to your service. For example,

    ...
    import io.ifar.dropwizard.shiro.ShiroBundle;
    import io.ifar.dropwizard.shiro.ShiroConfiguration;
    ...
    private final ShiroBundle shiroBundle =
            new ShiroBundle<MyConfiguration>() {
                @Override public Optional<ShiroConfiguration> getShiroConfiguration(final MyConfiguration configuration)
                { return Optional.<ShiroConfiguration>fromNullable(configuration.getShiroConfiguration()); }
            };
    ...
    @Override
    public void initialize(final Bootstrap<MyConfiguration> bootstrap) {
        ...
        bootstrap.addBundle(this.shiroBundle);
        ...
    }
    ...

Of course you will need to expose the `ShiroConfiguration` via the `MyConfiguration` instance:

    ...
{'fraction_non_alphanumeric': 0.0756494433342849, 'fraction_numerical': 0.0017128175849272054, 'mean_word_length': 3.4354430379746836, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1233324', 'n_tokens_mistral': 926, 'n_tokens_neox': 893, 'n_words': 316}