Last active
August 29, 2015 14:01
-
-
Save daichan4649/7f2fa938eeae46716f1d to your computer and use it in GitHub Desktop.
tomcat7 basic authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void doGet(HttpServletRequest request, | |
HttpServletResponse response) throws ServletException, IOException { | |
// logon user name | |
final String userName = request.getUserPrincipal().getName(); | |
PrintWriter out = response.getWriter(); | |
out.println(String.format("doGet(%s)", userName)); | |
out.flush(); | |
out.close(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- ADD role, user--> | |
<role rolename="test-role" /> | |
<user username="user01" password="user01" roles="test-role" /> | |
<user username="user02" password="user02" roles="test-role" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<security-constraint> | |
<web-resource-collection> | |
<web-resource-name>User Basic Authentication</web-resource-name> | |
<url-pattern>/*</url-pattern> | |
</web-resource-collection> | |
<auth-constraint> | |
<role-name>test-role</role-name> | |
</auth-constraint> | |
</security-constraint> | |
<login-config> | |
<auth-method>BASIC</auth-method> | |
<realm-name>User Basic Authentication</realm-name> | |
</login-config> | |
<security-role> | |
<role-name>test-role</role-name> | |
</security-role> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment