Implemented with Tomcat SSO

Source: Internet
Author: User
Tags tomcat

Target: After the user login once, you can access different webapp on the same server and implement the Tomcat single sign-on implementation. These are mainly divided into the following steps:

Modify Tomcat Conf/server.xml Open SSO support

Add a value node under <Host> node

<valve classname= "org.apache.catalina.authenticator.SingleSignOn"

debug= " 0 "requirereauthentication=" false "/>

</Host>

Container certification Realm:user, role, Server.xml <Realm...> settings.

Tomcat's authentication mechanism has 2 elements: User and role.

User is the only recognition that distinguishes users.

Role is a number of abstract permission levels, such as "admin", "manager", "member", "Guest" and so on, can be defined by themselves. A user can have a variety of role.

"But how is tomcat going to get my user/role information?" All my data is in the database, huh? "This information can be read using <Realm> tag in Tomcat's Server.xml, and Tomcat provides 3, 4 out-of-the-box Realm implementations, which are read from the file, read from JDBC, read from DataSource, There are also from LDAP read. The specific realm, and several realm configuration methods available, can refer to Tomcat's own documentation, which is not described here. (Take Tomcat's Webapp:tomcat-docs.war, look inside the config/realm.html) if these ready-made configurations do not meet your requirements, then you can also consider writing a realm implementation class to meet the specific requirements. Here's an example of a JDBC realm configuration look:

<realm classname= "Org.apache.catalina.realm.JDBCRealm" debug=

"drivername=" "Your.jdbc.driver.here" Connectionurl= "Your.jdbc.url.here"

connectionname= "test"

connectionpassword= "test"

usertable= " Users "

usernamecol=" user_name "

usercredcol=" User_pass "

userroletable=" User_roles "rolenamecol="

"Role_name"/>

WebApp using SSO:

Tell Tomcat this webapp to pass container certification.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.