Return-Path: Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: (qmail 14769 invoked from network); 7 Jan 2011 21:08:09 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 7 Jan 2011 21:08:09 -0000 Received: (qmail 61971 invoked by uid 500); 7 Jan 2011 21:08:05 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 61913 invoked by uid 500); 7 Jan 2011 21:08:05 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 61904 invoked by uid 99); 7 Jan 2011 21:08:05 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Jan 2011 21:08:05 +0000 X-ASF-Spam-Status: No, hits=1.5 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of cogross@gmail.com designates 74.125.82.173 as permitted sender) Received: from [74.125.82.173] (HELO mail-wy0-f173.google.com) (74.125.82.173) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Jan 2011 21:07:58 +0000 Received: by wyg36 with SMTP id 36so19223540wyg.18 for ; Fri, 07 Jan 2011 13:07:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=KE0cEptCcxigcqUoOb440QJbcrxdn9IUwVAdKjmnt3g=; b=alXTWIGaDj7s+6gOe21hv7+viR7UEdcbbe8aKbbFoP39lI3dcQa5iKUBYw1s3nnTHd kP1ygZqEj1Sa/Eu9fd1ZR/2LjQSPFGVgeVHa5V9o4QV6dzlCSqiD+lryPFbN14BDDmel 9L5RlAr1hcOrmlPHB9dXHd4BqyuyKvwRXjabM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=JK+ROE0Z+8zbFIoR+GRaxhTWOiAeGDp7iRKg0wXhNIDEnL2O5F3HOY4kECU0O1Sv35 u/RknQ4IGptpITK9sclsdXDBUGWWOmyFZFhGlwFoAPCUMO0TjS1704UlF1rFvuA4Nf/J nAnzEaGsS2TMh1UrjZpJsxaLufuoL7dSqRHwo= Received: by 10.227.141.130 with SMTP id m2mr16341516wbu.54.1294434458347; Fri, 07 Jan 2011 13:07:38 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.167.195 with HTTP; Fri, 7 Jan 2011 13:07:18 -0800 (PST) In-Reply-To: <4D277DC7.4090909@pidster.com> References: <4D277DC7.4090909@pidster.com> From: Christopher Gross Date: Fri, 7 Jan 2011 16:07:18 -0500 Message-ID: Subject: Re: Configuring Embedded Tomcat To: Tomcat Users List Content-Type: multipart/alternative; boundary=001485f8946813275c04994802d0 X-Virus-Checked: Checked by ClamAV on apache.org --001485f8946813275c04994802d0 Content-Type: text/plain; charset=ISO-8859-1 OK, so I'd need to add a Realm for the UserDatabaseRealm in either of the spots you listed. I'll probably use the file, so that I can adjust it if need be. Where do I put the tomcat-users.xml file, so that the Realm has users/passwords? Is there a way for me to tell the Embedded object where it is, or will it look in a certain spot by default? Thanks! -- Chris On Fri, Jan 7, 2011 at 3:55 PM, Pid wrote: > 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. > > > > My code is like this: > > > > public void start() throws Exception { > > String hostname = System.getProperty("hostname"); > > int port = Integer.parseInt(System.getProperty("port")); > > String path = System.getProperty("path"); > > Embedded embedded = new Embedded(); > > Engine engine = embedded.createEngine(); > > engine.setName("Monitor"); > > engine.setHostname(hostname); > > Host host = embedded.createHost(hostname, path); > > engine.addChild(host); > > Context sp = embedded.createContext("/Monitor", path + > > "/webapps/monitor"); > > host.addChild(sp); > > embedded.addEngine(engine); > > InetAddress addr = null; > > Connector connector = embedded.createConnector(addr, port, false); > > embedded.addConnector(connector); > > embedded.setName("WebServerThread"); > > embedded.start(); > > } > > > > 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 > now). > > Should I be using a different module? Is there a spot where the > embedded > > 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. > > > > Thanks! > > > > -- Chris > > > > --001485f8946813275c04994802d0--