@Test public void testAuthenticate() throws Exception { InMemoryRealm realm = new InMemoryRealm(); StandardContext ctx = new StandardContext(); ctx.setName("OryxTest"); realm.setContainer(ctx); realm.start(); realm.addUser("foo", "bar"); Principal authPrincipal = realm.authenticate("foo", "bar"); assertNotNull(authPrincipal); assertEquals("foo", authPrincipal.getName()); assertNull(realm.authenticate("foo", "baz")); assertNull(realm.authenticate("bar", "foo")); assertEquals("bar", realm.getPassword("foo")); assertEquals("foo", realm.getPrincipal("foo").getName()); }
@BeforeMethod public void setup() throws LifecycleException, ClassNotFoundException, IOException { _manager = mock( SessionManager.class ); final Context context = new StandardContext(); when( _manager.getContext() ).thenReturn( context ); // needed for createSession // Manager.getContainer no longer available in tc 8.5+ if(_managerHasGetContainer) { when( _manager.getContainer() ).thenReturn( context ); } when( _manager.newMemcachedBackupSession() ).thenAnswer(new Answer<MemcachedBackupSession>() { @Override public MemcachedBackupSession answer(final InvocationOnMock invocation) throws Throwable { return newMemcachedBackupSession( _manager ); } }); final MemcachedSessionService service = new DummyMemcachedSessionService<SessionManager>( _manager ); when( _manager.createSession( anyString() ) ).thenAnswer(new Answer<MemcachedBackupSession>() { @Override public MemcachedBackupSession answer(final InvocationOnMock invocation) throws Throwable { return createSession(service); } }); when( _manager.readPrincipal( (ObjectInputStream)any() ) ).thenReturn( createPrincipal() ); when( _manager.getMemcachedSessionService() ).thenReturn( service ); when( _manager.willAttributeDistribute(anyString(), any())).thenReturn(true); }
@Override public StandardContext createContext(DeploymentUnit deploymentUnit) throws DeploymentUnitProcessingException { return new StandardContext(); }
public static StandardContext createContext() { final StandardEngine engine = new StandardEngine(); engine.setService( new StandardService() ); final StandardContext context = new StandardContext(); context.setPath( "/" ); context.setSessionCookiePath( "/" ); final WebappLoader webappLoader = new WebappLoader() { @Override public ClassLoader getClassLoader() { return Thread.currentThread().getContextClassLoader(); } }; context.setLoader( webappLoader ); final StandardHost host = new StandardHost(); engine.addChild( host ); host.addChild( context ); return context; }
private Context createDefaultContext(String contextPath, String docBase) { StandardContext context = new StandardContext(); context.setDocBase(docBase); context.setPath(contextPath); ContextConfig config = new ContextConfig(); context.addLifecycleListener(config); return context; }
private Context createDefaultContext(String contextPath, String docBase) { StandardContext context = new StandardContext(); context.setDocBase(docBase); context.setPath(contextPath); ContextConfig config = new ContextConfig(); context.addLifecycleListener(config); return context; }
private StandardContext createContext(String path, String docBase) { StandardContext context = new StandardContext(); context.setUnpackWAR(false); context.setDocBase(docBase); context.setPath(path); ContextConfig config = new ContextConfig(); context.addLifecycleListener(config); return (context); } }
public Context addWebapp( Host host, String url, String name, String path ) { Context ctx = new StandardContext(); ctx.setName( name ); ctx.setPath( url ); ctx.setDocBase( path ); ContextConfig ctxCfg = new ContextConfig(); ctx.addLifecycleListener( ctxCfg ); ctxCfg.setDefaultWebXml( new File( configurationDir, "conf/web.xml" ).getAbsolutePath() ); if ( host == null ) { getHost().addChild( ctx ); } else { host.addChild( ctx ); } return ctx; } }
private StandardContext createContext(String path, String docBase, ClassLoader classLoader, Map<String, List<Injector<?>>> injectors) { StandardContext context = new StandardContext(); context.setDocBase(docBase); context.setPath(path); ContextConfig config = new ContextConfig(); context.addLifecycleListener(config); context.setParentClassLoader(classLoader); Fabric3Loader loader = new Fabric3Loader(classLoader); context.setLoader(loader); // turn off unpacking so Tomcat does not copy the extracted WAR to the /webapps directory and autodeploy it on a subsequent boot context.setUnpackWAR(false); Fabric3AnnotationProcessor annotationProcessor = new Fabric3AnnotationProcessor(injectors); context.setAnnotationProcessor(annotationProcessor); context.getServletContext().setAttribute(AnnotationProcessor.class.getName(), annotationProcessor); return (context); }
@Override public Context createContext(String path, String docBase) { if( log.isDebugEnabled() ) log.debug("Creating context '" + path + "' with docBase '" + docBase + "'"); context = new StandardContext(); context.setDocBase(docBase); context.setPath(path); ContextConfig config = new ContextConfig(); config.setCustomAuthenticators(authenticators); ((Lifecycle) context).addLifecycleListener(config); return (context); }
public Context addContext(Host host, String contextPath, String dir) { silence(contextPath); Context ctx = new StandardContext(); ctx.setPath( contextPath ); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addContext(Host host, String contextPath, String dir) { silence(contextPath); Context ctx = new StandardContext(); ctx.setPath( contextPath ); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addContext(Host host, String contextPath, String dir) { silence(contextPath); Context ctx = new StandardContext(); ctx.setPath( contextPath ); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addContext(Host host, String contextPath, String contextName, String dir) { silence(host, contextPath); Context ctx = new StandardContext(); ctx.setName(contextName); ctx.setPath(contextPath); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addContext(Host host, String contextPath, String contextName, String dir) { silence(host, contextPath); Context ctx = new StandardContext(); ctx.setName(contextName); ctx.setPath(contextPath); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
/** * @see #addContext(String, String) */ public Context addContext(Host host, String contextPath, String contextName, String dir) { silence(host, contextPath); Context ctx = new StandardContext(); ctx.setName(contextName); ctx.setPath(contextPath); ctx.setDocBase(dir); ctx.addLifecycleListener(new FixContextListener()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
@Before public void setupManager() { Context context = new StandardContext(); Host host = new StandardHost(); this.manager.setContext(context); context.setName("test-context-name"); context.setParent(host); host.setName("test-host-name"); }
public Context addWebapp(Host host, String url, String name, String path) { silence(host, url); Context ctx = new StandardContext(); ctx.setName(name); ctx.setPath(url); ctx.setDocBase(path); ctx.addLifecycleListener(new DefaultWebXmlListener()); ContextConfig ctxCfg = new ContextConfig(); ctx.addLifecycleListener(ctxCfg); // prevent it from looking ( if it finds one - it'll have dup error ) ctxCfg.setDefaultWebXml(noDefaultWebXmlPath()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addWebapp(Host host, String url, String name, String path) { silence(host, url); Context ctx = new StandardContext(); ctx.setName(name); ctx.setPath(url); ctx.setDocBase(path); ctx.addLifecycleListener(new DefaultWebXmlListener()); ContextConfig ctxCfg = new ContextConfig(); ctx.addLifecycleListener(ctxCfg); // prevent it from looking ( if it finds one - it'll have dup error ) ctxCfg.setDefaultWebXml(noDefaultWebXmlPath()); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }
public Context addWebapp(Host host, String url, String path) { silence(url); Context ctx = new StandardContext(); ctx.setPath( url ); ctx.setDocBase(path); if (defaultRealm == null) { initSimpleAuth(); } ctx.setRealm(defaultRealm); ctx.addLifecycleListener(new DefaultWebXmlListener()); ContextConfig ctxCfg = new ContextConfig(); ctx.addLifecycleListener(ctxCfg); // prevent it from looking ( if it finds one - it'll have dup error ) ctxCfg.setDefaultWebXml("org/apache/catalin/startup/NO_DEFAULT_XML"); if (host == null) { getHost().addChild(ctx); } else { host.addChild(ctx); } return ctx; }