J'utilise Tomcat 7 avec pour Spring et JPA Application, base de données MySQL. Tout fonctionne bien.Mais parfois, un problème d'authentification realm.LockOutRealm se posera. J'ai également utilisé le pool de connexions dans mon application comme:
persistence.xml:
<properties>
<property name="hibernate.connection.username" value="---"/>
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
<property name="hibernate.connection.password" value="----------"/>
<property name="hibernate.connection.url" value="jdbc:mysql://----------?autoReconnect=true"/>
<!--Connection Pooling c3p0 configuration-->
<!--Minimum number of JDBC connections in the pool. Hibernate default: 1-->
<property name="hibernate.c3p0.min_size" value="5"/>
<!--Maximum number of JDBC connections in the pool. Hibernate default: 100-->
<property name="hibernate.c3p0.max_size" value="20"/>
<!--When an idle connection is removed from the pool (in second). Hibernate default: 0, never expire.-->
<property name="hibernate.c3p0.timeout" value="300"/>
<!--Number of prepared statements will be cached. Increase performance. Hibernate default: 0 , caching is disable.-->
<property name="hibernate.c3p0.max_statements" value="50"/>
<!--idle time in seconds before a connection is automatically validated. Hibernate default: 0-->
<property name="hibernate.c3p0.idle_test_period" value="300"/>
</properties>
et le domaine dans server.xml ressemble à:
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.Apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.Apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- SingleSignOn Valve, share authentication between web applications
Documentation at: /docs/config/Valve.html -->
<!--
<Valve className="org.Apache.catalina.authenticator.SingleSignOn" />
-->
Je recherche sur le net mais je n'ai pas trouvé de solution à ce sujet. y a-t-il quelqu'un sur l'attaque par force brute et s'il y a que quelle est la solution de cela.
Connexion d'erreur Catelina.out
en est:
Mar 02, 2013 3:28:34 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "Tomcat"
Mar 02, 2013 3:29:49 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "Tomcat"
Mar 02, 2013 3:31:04 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "Tomcat"
Mar 02, 2013 3:37:25 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "admin"
Mar 02, 2013 3:38:47 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "admin"
Mar 02, 2013 3:39:58 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "admin"
Mar 02, 2013 3:46:31 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "coyote"
Mar 02, 2013 3:52:49 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "manager"
Mar 02, 2013 3:59:03 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "administrator"
Mar 02, 2013 4:06:38 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "root"
Mar 02, 2013 4:07:52 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "root"
Mar 02, 2013 4:09:17 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "root"
Mar 02, 2013 4:10:35 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "root"
Mar 02, 2013 4:11:47 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "root"
Mar 02, 2013 4:13:02 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "root"
Mar 02, 2013 4:14:17 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "root"
Mar 02, 2013 4:15:34 PM org.Apache.catalina.realm.LockOutRealm authenticate
WARNING: An attempt was made to authenticate the locked user "root"
> Hibernate: select
----------------------------------
javax.persistence.PersistenceException:
org.hibernate.exception.JDBCConnectionException: could not execute query
(DelegatingConstructorAccessorImpl.Java:45)
at Java.lang.reflect.Constructor.newInstance(Constructor.Java:525)
at com.mysql.jdbc.Util.handleNewInstance(Util.Java:409)
at com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.Java:1118)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.Java:3321)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.Java:1940)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.Java:2113)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.Java:2568)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.Java:2113)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.Java:2275)
at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.Java:116)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.Java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.Java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.Java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.Java:236)
at org.hibernate.loader.Loader.doList(Loader.Java:2220)
... 39 more
Caused by: Java.net.SocketException: Broken pipe
L'avertissement ci-dessus signifie que vous ne parvenez pas à authentifier l'utilisateur Tomcat plusieurs fois. Tomcat soupçonne qu'il s'agit d'une attaque par force brute contre l'utilisateur Tomcat.
Quelle authentification utilisez-vous dans votre application? Quelle configuration de connexion utilisez-vous dans web.xml de l'application?
La configuration par défaut de resourceName "UserDatabase" est le fichier conf/Tomcat-users.xml. Avez-vous modifié la configuration de resourceName "UserDatabase"?
Vous pouvez trouver la configuration de la ressource UserDatabase dans le fichier server.xml:
<Resource name="UserDatabase" auth="Container"
type="org.Apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.Apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/Tomcat-users.xml" />
Par défaut, tous les utilisateurs sont commentés. Pour pouvoir travailler avec des utilisateurs à partir du fichier XML, vous devez décommenter. Ensuite, vous pourrez vous connecter avec l'utilisateur Tomcat:
<Tomcat-users>
<role rolename="Tomcat"/>
<user username="Tomcat" password="Tomcat" roles="Tomcat"/>
</Tomcat-users>
Meilleures salutations,
Michael
(Aux 16k visiteurs de cette page:
Puisque c'est sur SO, je suppose que les lecteurs sont développeurs.)
Cette erreur indique que vous avez un script/utilisateur essayant de se connecter avec un utilisateur/passe incorrect. La correction est simple, ajoutez simplement la bonne paire utilisateur/passe au fichier ApacheTomcat\conf\Tomcat-users.xml
et redémarrer le serveur.
Assurez-vous également que le rôle est correctement défini. Par exemple. si vous envoyez des demandes d'authentification HTTP de base à localhost:8080/manager
, vous aurez besoin du manager-gui
rôle:
<?xml version='1.0' encoding='utf-8'?>
<Tomcat-users>
<role rolename="manager-gui"/>
<user username="foobar" password="foobar" roles="Tomcat,role1, manager-gui "/>
</Tomcat-users>