Search in sources :

Example 1 with JaxrsModule

use of io.crnk.rs.internal.JaxrsModule in project crnk-framework by crnk-project.

the class CrnkFeature method configure.

@Override
public boolean configure(final FeatureContext context) {
    boot.setPropertiesProvider(createPropertiesProvider(context));
    if (securityEnabled) {
        boot.addModule(new JaxrsModule(securityContext));
    }
    boot.boot();
    parameterProviderRegistry = buildParameterProviderRegistry();
    CrnkFilter crnkFilter = createCrnkFilter();
    context.register(crnkFilter);
    registerActionRepositories(context, boot);
    return true;
}
Also used : JaxrsModule(io.crnk.rs.internal.JaxrsModule)

Example 2 with JaxrsModule

use of io.crnk.rs.internal.JaxrsModule in project crnk-framework by crnk-project.

the class JaxrsModuleTest method testGetter.

@Test
public void testGetter() {
    SecurityContext securityContext = Mockito.mock(SecurityContext.class);
    JaxrsModule module = new JaxrsModule(securityContext);
    Assert.assertEquals("jaxrs", module.getModuleName());
}
Also used : SecurityContext(javax.ws.rs.core.SecurityContext) JaxrsModule(io.crnk.rs.internal.JaxrsModule) Test(org.junit.Test)

Example 3 with JaxrsModule

use of io.crnk.rs.internal.JaxrsModule in project crnk-framework by crnk-project.

the class JaxrsModuleTest method checkSecurityProviderRegistered.

@Test
public void checkSecurityProviderRegistered() {
    SecurityContext securityContext = Mockito.mock(SecurityContext.class);
    JaxrsModule module = new JaxrsModule(securityContext);
    CrnkBoot boot = new CrnkBoot();
    boot.addModule(module);
    boot.boot();
    SecurityProvider securityProvider = boot.getModuleRegistry().getSecurityProvider();
    Assert.assertNotNull(securityProvider);
    Mockito.when(securityContext.isUserInRole("admin")).thenReturn(true);
    Assert.assertTrue(securityProvider.isUserInRole("admin"));
    Assert.assertFalse(securityProvider.isUserInRole("other"));
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) SecurityContext(javax.ws.rs.core.SecurityContext) JaxrsModule(io.crnk.rs.internal.JaxrsModule) SecurityProvider(io.crnk.core.engine.security.SecurityProvider) Test(org.junit.Test)

Example 4 with JaxrsModule

use of io.crnk.rs.internal.JaxrsModule in project crnk-framework by crnk-project.

the class MetaModuleTest method setupBoot.

private void setupBoot() {
    boot = new CrnkBoot();
    boot.addModule(new JaxrsModule(null));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
    boot.addModule(metaModule);
    boot.boot();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) JaxrsModule(io.crnk.rs.internal.JaxrsModule) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider)

Example 5 with JaxrsModule

use of io.crnk.rs.internal.JaxrsModule in project crnk-framework by crnk-project.

the class ValidationMetaProviderTest method setup.

private void setup(boolean addValidationProvider) {
    CrnkBoot boot = new CrnkBoot();
    boot.addModule(new JaxrsModule(null));
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.validation.mock", new SampleJsonServiceLocator()));
    boot.boot();
    resourceMetaProvider = new ResourceMetaProvider();
    lookup = new MetaLookup();
    lookup.setModuleContext(boot.getModuleRegistry().getContext());
    lookup.addProvider(resourceMetaProvider);
    if (addValidationProvider) {
        lookup.addProvider(new ValidationMetaProvider());
    }
    lookup.initialize();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) MetaLookup(io.crnk.meta.MetaLookup) ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) JaxrsModule(io.crnk.rs.internal.JaxrsModule) SampleJsonServiceLocator(io.crnk.legacy.locator.SampleJsonServiceLocator) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery)

Aggregations

JaxrsModule (io.crnk.rs.internal.JaxrsModule)6 CrnkBoot (io.crnk.core.boot.CrnkBoot)4 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)3 ResourceMetaProvider (io.crnk.meta.provider.resource.ResourceMetaProvider)2 SecurityContext (javax.ws.rs.core.SecurityContext)2 Test (org.junit.Test)2 SecurityProvider (io.crnk.core.engine.security.SecurityProvider)1 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)1 SampleJsonServiceLocator (io.crnk.legacy.locator.SampleJsonServiceLocator)1 MetaLookup (io.crnk.meta.MetaLookup)1 TestModule (io.crnk.test.mock.TestModule)1 Before (org.junit.Before)1