How to configure JDBC scope for container-managed security using tomcat?

I want to configure tomcat / my web application to use the JDBC scope for container-managed security. I specified the area in the tomcat server.xml file as follows:

<Realm className="org.apache.catalina.realm.JDBCRealm" driverName="net.sourceforge.jtds.jdbc.Driver" connectionURL="jdbc:jtds:sqlserver://hostname:1433/intranet;user=sa;password=sa04jT14;instance=instanceName" userTable="users" userNameCol="username" userCredCol="password" userRoleTable="roles" roleNameCol="role" />

I created a database and tables. I created a login page and added the following code in web.xml:

<login-config>
    <auth-method>FORM</auth-method>
    <form-login-config>
        <form-login-page>/login.xhtml</form-login-page>
        <form-error-page>/login.xhtml</form-error-page>
    </form-login-config>
</login-config>

But how does Tomcat know which area he should use for authentication? Do I need to add an element to an element? But what then should be the value?

Thanks in advance.

+3
source share
1 answer

. <Realm>, Tomcat webapp. Tomcat Realm Configuration HOWTO:

<Realm> Container. Realm " " (. - ):

  • <Engine> - Realm - , , <Host> <Context>.

  • <Host> - - , , <Context>.

  • <Context> - -.

<Engine> <Host> /conf/server.xml. <Context> . , , Webapp <Context>, - , Webapp/META-INF/context.xml.

, .

+5

Source: https://habr.com/ru/post/1735245/


All Articles