On 1/7/11 6:59 PM, Christopher Gross wrote:
> I've been looking around, but I can't seem to find somewhere that shows=
how
> you can configure Tomcat when you embed it into an application.
>=20
> My code is like this:
>=20
> public void start() throws Exception {
> String hostname =3D System.getProperty("hostname");
> int port =3D Integer.parseInt(System.getProperty("port"));
> String path =3D System.getProperty("path");
> Embedded embedded =3D new Embedded();
> Engine engine =3D embedded.createEngine();
> engine.setName("Monitor");
> engine.setHostname(hostname);
> Host host =3D embedded.createHost(hostname, path);
> engine.addChild(host);
> Context sp =3D embedded.createContext("/Monitor", path +
> "/webapps/monitor");
> host.addChild(sp);
> embedded.addEngine(engine);
> InetAddress addr =3D null;
> Connector connector =3D embedded.createConnector(addr, port, false);=
> embedded.addConnector(connector);
> embedded.setName("WebServerThread");
> embedded.start();
> }
>=20
> It works fine as it is now, but I'd like to use Tomcat to authenticate
> users. I'll make a separate app for basic users to use to just view a =
page,
> but give admins access to a more advanced page (the pages that I have n=
ow).
> Should I be using a different module? Is there a spot where the embed=
ded
> Tomcat will look by default?
Container managed authentication & authorization is dependent on config
in web.xml, part of the application.
Tomcat needs a Realm against which users are configured. Add a Realm to
the webapp/META-INF/context.xml or as a child of the Host.
p
> Any tips would be greatly appreciated.
>=20
> Thanks!
>=20
> -- Chris
>=20
|