Problemas com segurança no tomcat

1 resposta
V

Para autenticaçao do usuario eu deveria acrescentar umas tabelas no meu
banco de dados, que eu ja mudei, e alterar a configuraçao do arquivo
conf/server.xml e mudar o web.xml.

O server.xml, depois de algumas tentativas ficou com a seguinte mudança :

"
<!-- Because this Realm is here, an instance will be shared globally
–>

<!-- REALM COMENTADO POR MIM
<Realm className=“org.apache.catalina.realm.MemoryRealm” />
–>
<!-- Replace the above Realm with one of the following to get a Realm
stored in a database and accessed via JDBC -->

<!-- REALM ACRESCENTADO -->

&lt;Realm className="org.apache.catalina.realm.JDBCRealm" debug="99"

driverName=“com.mysql.jdbc.Driver”

connectionURL="jdbc:mysql://localhost/flavia"
            connectionName="user"
            connectionPassword="pass"
            userTable="users" userNameCol="user_name"

userCredCol="user_pass"
userRoleTable=“user_roles” roleNameCol=“role_name”/>

"

Com essa mudança o tomcat “starta” normalmente, sem nenhum erro. Mas ao
mudar o web.xml da minha aplicaçao, acrescentando a parte para a
autenticaçao ocorre o seguinte erro ao starta-lo ( no arquivo
logs/catalina.out ):

PARSE error at line 11 column -1
org.xml.sax.SAXParseException: Root element type is “security-constraint”,
but was declared to be “web-app”.

e passa a nao reconhecer nenhum dos meus arquivos.

abaixo estah o meu web.xml modificado, quando o tomcat inicia normalmente
o web.xml soh possui a parte entre <web-app> e </web-app>, que é a parte
final do arquivo.

web.xml:

<?xml version=“1.0” encoding=“ISO-8859-1”?>

<!DOCTYPE web-app
PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”
http://java.sun.com/dtd/web-app_2_3.dtd”>

&lt;!-- Default login configuration uses form-based authentication --&gt;

<security-constraint>
<display-name>BDBComp Security Constraint</display-name>
<web-resource-collection>
<web-resource-name>Protected Area</web-resource-name>

<!-- Define the context-relative URL(s) to be protected -->

<!–
<url-pattern>*.do</url-pattern>

&lt;url-pattern&gt;*.jsp&lt;/url-pattern&gt;

–>
<url-pattern>autor.jsp</url-pattern>

&lt;!-- If you list http methods, only those methods are protected --&gt;
    &lt;http-method&gt;DELETE&lt;/http-method&gt;
    &lt;http-method&gt;GET&lt;/http-method&gt;
    &lt;http-method&gt;POST&lt;/http-method&gt;
    &lt;http-method&gt;PUT&lt;/http-method&gt;

</web-resource-collection>

<auth-constraint>

<!-- Anyone with one of the listed roles may access this area -->

<role-name>contribuidor</role-name>

</auth-constraint>
</security-constraint>

<login-config>
<auth-method>FORM</auth-method>
<realm-name>BDBComp Form-Based authentication</realm-name>
<form-login-config>
<form-login-page>/autoarq.jsp</form-login-page>
<form-error-page>/ajuda.jsp</form-error-page>
</form-login-config>
</login-config>

&lt;!-- Security roles referenced by this web application --&gt;

&lt;security-role&gt;
   &lt;role-name&gt;contribuidor&lt;/role-name&gt;
&lt;/security-role&gt;

<web-app>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>bdbcomp.jsp</welcome-file>
<welcome-file>ajuda.jsp</welcome-file>
<welcome-file>autoarq.jsp</welcome-file>
</welcome-file-list>

</web-app>

:roll: alguem sabe o que pode estar acontecendo ???

1 Resposta

J

Oi

Vinha, vc já tentou colocar isso dentro da tag web-app?

Mas bom, a melhor solução é, abrir a DTD, e descobrir com certeza onde fica essa tag…

T+

Criado 11 de fevereiro de 2005
Ultima resposta 19 de fev. de 2005
Respostas 1
Participantes 2