Tomcat 5.0 : MemoryBasedRealm [cross post] - Java - Programmation
Marsh Posté le 08-09-2004 à 15:58:30
http://forum.hardware.fr/forum2.ph [...] bcat=0#bas je tente ma chance ici, si c'est trop HS y'a k'a virer j'ai besoin de limiter l'acces a un serveur Tomcat par un mot de passe je l'ai dejà fait y'a quelques semaines pour tester et ca c'est passé sans prolème aujourd'hui je n'arrive plus a le faire ... server.xml
<?xml version='1.0' encoding='utf-8'?> <Server> <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/> <GlobalNamingResources> <Environment name="simpleValue" type="java.lang.Integer" value="30"/> <Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/> <ResourceParams name="UserDatabase"> <parameter> <name>factory</name> <value>org.apache.catalina.users.MemoryUserDatabaseFactory</value> </parameter> <parameter> <name>pathname</name> <value>conf/tomcat-users.xml</value> </parameter> </ResourceParams> </GlobalNamingResources> <Service name="Catalina"> <Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8443"> </Connector> <Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443"> </Connector> <Engine defaultHost="localhost" name="Catalina"> <Host appBase="webapps" name="localhost"> <Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/> <Realm className="org.apache.catalina.realm.MemoryRealm"/> </Host> <Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/> <!-- <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>--> </Engine> </Service> </Server>
tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?> <tomcat-users> <role rolename="user"/> <role rolename="tomcat"/> <role rolename="role1"/> <role rolename="manager"/> <role rolename="admin"/> <user username="tomcat" password="tomcat" roles="tomcat"/> <user username="role1" password="tomcat" roles="role1"/> <user username="both" password="tomcat" roles="tomcat,role1"/> <user username="demo" password="toto" roles="user"/> <user username="admin" password="pouet" fullName="" roles="admin,manager"/> </tomcat-users>
Make sure you enter the(*)required information where indicate.HTML code is not allowed
Marsh Posté le 08-09-2004 à 15:58:30
http://forum.hardware.fr/forum2.ph [...] bcat=0#bas
je tente ma chance ici, si c'est trop HS y'a k'a virer
j'ai besoin de limiter l'acces a un serveur Tomcat par un mot de passe
je l'ai dejà fait y'a quelques semaines pour tester et ca c'est passé sans prolème
aujourd'hui je n'arrive plus a le faire ...
server.xml
<?xml version='1.0' encoding='utf-8'?>
<Server>
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<GlobalNamingResources>
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<Resource auth="Container" description="User database that can be updated and saved" name="UserDatabase" type="org.apache.catalina.UserDatabase"/>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service name="Catalina">
<Connector acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" port="8080" redirectPort="8443">
</Connector>
<Connector port="8009" protocol="AJP/1.3" protocolHandlerClassName="org.apache.jk.server.JkCoyoteHandler" redirectPort="8443">
</Connector>
<Engine defaultHost="localhost" name="Catalina">
<Host appBase="webapps" name="localhost">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_log." suffix=".txt" timestamp="true"/>
<Realm className="org.apache.catalina.realm.MemoryRealm"/>
</Host>
<Logger className="org.apache.catalina.logger.FileLogger" prefix="catalina_log." suffix=".txt" timestamp="true"/>
<!-- <Realm className="org.apache.catalina.realm.UserDatabaseRealm"/>-->
</Engine>
</Service>
</Server>
tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="user"/>
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="manager"/>
<role rolename="admin"/>
<user username="tomcat" password="tomcat" roles="tomcat"/>
<user username="role1" password="tomcat" roles="role1"/>
<user username="both" password="tomcat" roles="tomcat,role1"/>
<user username="demo" password="toto" roles="user"/>
<user username="admin" password="pouet" fullName="" roles="admin,manager"/>
</tomcat-users>
Message édité par lint le 08-09-2004 à 15:59:48
---------------
\@/