/*
 * Copyright 2018 Crown Copyright
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package stroom.security.impl;

import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;
import stroom.util.entity.EntityEvent;
import stroom.security.api.DocumentPermissionService;
import stroom.security.impl.event.PermissionChangeEvent;
import stroom.security.impl.event.PermissionChangeEventLifecycleModule;
import stroom.security.impl.event.PermissionChangeEventModule;
import stroom.util.guice.FilterBinder;
import stroom.util.guice.FilterInfo;
import stroom.util.guice.GuiceUtil;
import stroom.util.guice.HealthCheckBinder;
import stroom.util.shared.Clearable;
import stroom.util.shared.RestResource;

import javax.servlet.http.HttpSessionListener;

public class SecurityModule extends AbstractModule {
    private static final String MATCH_ALL_PATHS = "/*";

    @Override
    protected void configure() {
        install(new PermissionChangeEventModule());
        install(new PermissionChangeEventLifecycleModule());

        bind(DocumentPermissionService.class).to(DocumentPermissionServiceImpl.class);
        bind(UserService.class).to(UserServiceImpl.class);

        FilterBinder.create(binder())
                .bind(new FilterInfo(ContentSecurityFilter.class.getSimpleName(), MATCH_ALL_PATHS),
                        ContentSecurityFilter.class)
                .bind(new FilterInfo(SecurityFilter.class.getSimpleName(), MATCH_ALL_PATHS),
                        SecurityFilter.class);

        // Provide object info to the logging service.
        GuiceUtil.buildMultiBinder(binder(), Clearable.class)
                .addBinding(UserDocumentPermissionsCache.class)
                .addBinding(UserAppPermissionsCache.class)
                .addBinding(UserGroupsCache.class)
                .addBinding(UserCache.class);

        GuiceUtil.buildMultiBinder(binder(), HttpSessionListener.class)
                .addBinding(SessionMap.class);

        final Multibinder<EntityEvent.Handler> entityEventHandlerBinder = Multibinder.newSetBinder(binder(), EntityEvent.Handler.class);
        entityEventHandlerBinder.addBinding().to(UserGroupsCache.class);
        entityEventHandlerBinder.addBinding().to(UserAppPermissionsCache.class);

        final Multibinder<PermissionChangeEvent.Handler> permissionChangeEventHandlerBinder = Multibinder.newSetBinder(binder(), PermissionChangeEvent.Handler.class);
        permissionChangeEventHandlerBinder.addBinding().to(UserDocumentPermissionsCache.class);

        HealthCheckBinder.create(binder())
                .bind(JWTService.class);

        GuiceUtil.buildMultiBinder(binder(), RestResource.class)
                .addBinding(AppPermissionResourceImpl.class)
                .addBinding(AuthenticationResourceImpl.class)
                .addBinding(AuthorisationResource.class)
                .addBinding(DocPermissionResourceImpl.class)
                .addBinding(DocumentPermissionResourceImpl.class)
                .addBinding(UserResourceImpl.class)
                .addBinding(UserAppPermissionResourceImpl.class);
    }
}
@@ -3533,20 +3533,23 @@
 Binding(
-User
+Session
 Resource
@@ -3620,21 +3620,73 @@
 eImpl.class)
+%0A                .addBinding(UserResourceImpl.class)
 ;%0A    %7D%0A%7D

Add missing guice bind for SessionListListener