Digest Authentication of HTTP Authentication

Source: Internet
Author: User
Tags auth http authentication tomcat
Similar to the content of the basic article, the difference is that the process uses the Digest certification:

Tomcat configuration:
1 Create a new directory under Tomcat WebApps Authen, then create a subdirectory subdir, below a index.jsp

2 Set up the Web-inf directory under the Authen directory, and devolve the Web. xml file as follows
XML code   <security-constraint>       <web-resource-collection>            <web-resource-name>                My App            </web-resource-name>            <url-pattern>/subdir/*</url-pattern>       </ web-resource-collection>       <auth-constraint>            <role-name>test</role-name>        </auth-constraint>   </security-constraint>      <login-config >       <auth-method>DIGEST</auth-method>  <!--  digest here -->       <realm-name>My Realm</realm-name>   </ login-config>  
<security-constraint>
	<web-resource-collection>
		<web-resource-name>
			My App
		</web-resource-name>
		<url-pattern>/subdir/*</url-pattern>
	</ web-resource-collection>
	<auth-constraint>
		<role-name>test</role-name>
	</ auth-constraint>
</security-constraint>

<login-config>
	<auth-method>digest </auth-method>  <!--DIGEST here--
	<realm-name>my realm</realm-name>
</ Login-config>

3 in the Tomcat Tomcat-users.xml file, add a user name password of test,test user, role test.


Client Access:
Visit http://localhost:port/authen/subdir/index.jsp
A dialog box prompts for authentication, enter test test to log in.


Workflow (can view request headers via Firebug)
1 The client first sends the request (does not know to certify, the head does not contain any special information)

2 server sends a 401 return, and contains the following header


3 Client Authentication, contains the following header

Response= "..." is the part that the client uses to sign.

Disadvantages:
An attacker who hears a message can use this message to submit a request.

implementation in the HttpClient
View the Authenticate method for the Digestscheme class of the Org.apache.commons.httpclient.auth package.

RFC2617 describes the calculation method:
A valid response contains a checksum (by default, the MD5 checksum) of the username, the password, the given nonce value, The HTTP method, and the requested URI.

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.