Search in sources :

Example 1 with SecurityModule

use of gov.ca.cwds.security.module.SecurityModule in project perry by ca-cwds.

the class TestModule method configure.

@Override
protected void configure() {
    bind(TestService.class).to(TestServiceImpl.class);
    install(new SecurityModule(null).addAuthorizer("case:read", CaseAuthorizer.class).addStaticAuthorizer(TestStaticAuthorizer.class));
    bindInterceptor(Matchers.any(), Matchers.any(), new MethodInterceptor() {

        PermissionAnnotationMethodInterceptor permissionAnnotationMethodInterceptor = new PermissionAnnotationMethodInterceptor();

        @Override
        public Object invoke(MethodInvocation invocation) throws Throwable {
            return permissionAnnotationMethodInterceptor.invoke(new org.apache.shiro.aop.MethodInvocation() {

                @Override
                public Object proceed() throws Throwable {
                    return invocation.proceed();
                }

                @Override
                public Method getMethod() {
                    return invocation.getMethod();
                }

                @Override
                public Object[] getArguments() {
                    return invocation.getArguments();
                }

                @Override
                public Object getThis() {
                    return invocation.getThis();
                }
            });
        }
    });
}
Also used : MethodInterceptor(org.aopalliance.intercept.MethodInterceptor) PermissionAnnotationMethodInterceptor(org.apache.shiro.authz.aop.PermissionAnnotationMethodInterceptor) PermissionAnnotationMethodInterceptor(org.apache.shiro.authz.aop.PermissionAnnotationMethodInterceptor) TestService(gov.ca.cwds.testapp.service.TestService) TestStaticAuthorizer(gov.ca.cwds.security.authorizer.TestStaticAuthorizer) MethodInvocation(org.aopalliance.intercept.MethodInvocation) SecurityModule(gov.ca.cwds.security.module.SecurityModule)

Example 2 with SecurityModule

use of gov.ca.cwds.security.module.SecurityModule in project cals-api by ca-cwds.

the class CalsApiApplication method applicationModule.

@Override
public Module applicationModule(Bootstrap<CalsApiConfiguration> bootstrap) {
    return new ApplicationModule<CalsApiConfiguration>(bootstrap) {

        @Override
        protected void configure() {
            super.configure();
            install(new DataAccessModule(bootstrap) {

                @Provides
                UnitOfWorkAwareProxyFactory provideUnitOfWorkAwareProxyFactory() {
                    return new UnitOfWorkAwareProxyFactory(getLisHibernateBundle(), getFasHibernateBundle(), getCmsHibernateBundle(), getCalsnsHibernateBundle(), getXaCmsHibernateBundle(), getXaCalsnsHibernateBundle());
                }
            });
            install(new SecurityModule(BaseApiApplication::getInjector).addAuthorizer(Authorize.PLACEMENT_HOME_CREATE, PlacementHomeCreateAuthorizer.class).addAuthorizer(Authorize.SUBSTITUTE_CARE_PROVIDER_CREATE, SubstituteCareProviderCreateAuthorizer.class).addAuthorizer(CLIENT_RESULT_READ, ClientResultReadAuthorizer.class).addStaticAuthorizer(FacilityReadStaticAuthorizer.class));
        }
    };
}
Also used : DataAccessModule(gov.ca.cwds.cals.inject.DataAccessModule) SubstituteCareProviderCreateAuthorizer(gov.ca.cwds.authorizer.SubstituteCareProviderCreateAuthorizer) UnitOfWorkAwareProxyFactory(io.dropwizard.hibernate.UnitOfWorkAwareProxyFactory) FacilityReadStaticAuthorizer(gov.ca.cwds.authorizer.FacilityReadStaticAuthorizer) Provides(com.google.inject.Provides) ApplicationModule(gov.ca.cwds.cals.inject.ApplicationModule) SecurityModule(gov.ca.cwds.security.module.SecurityModule)

Aggregations

SecurityModule (gov.ca.cwds.security.module.SecurityModule)2 Provides (com.google.inject.Provides)1 FacilityReadStaticAuthorizer (gov.ca.cwds.authorizer.FacilityReadStaticAuthorizer)1 SubstituteCareProviderCreateAuthorizer (gov.ca.cwds.authorizer.SubstituteCareProviderCreateAuthorizer)1 ApplicationModule (gov.ca.cwds.cals.inject.ApplicationModule)1 DataAccessModule (gov.ca.cwds.cals.inject.DataAccessModule)1 TestStaticAuthorizer (gov.ca.cwds.security.authorizer.TestStaticAuthorizer)1 TestService (gov.ca.cwds.testapp.service.TestService)1 UnitOfWorkAwareProxyFactory (io.dropwizard.hibernate.UnitOfWorkAwareProxyFactory)1 MethodInterceptor (org.aopalliance.intercept.MethodInterceptor)1 MethodInvocation (org.aopalliance.intercept.MethodInvocation)1 PermissionAnnotationMethodInterceptor (org.apache.shiro.authz.aop.PermissionAnnotationMethodInterceptor)1