Java Codes
Beginners
Core Java
Date Time
Java2D
Java Applets
Java AWT
Mathematics
Networking
Servlets
Session
Sound
Swing
Threads
Util Package
JDBC
Learning
Other
Security
XML
Java > Java Servlets sample source codes
Get security information
Get security information package com.ack.web.servlet; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class GetSecurityInformation extends HttpServlet { public void doGet( HttpServletRequest req, HttpServletResponse res ) throws ServletException, IOException { res.setContentType( "text/html" ); PrintWriter pw = res.getWriter(); /** * security information made available within servlets */ pw.println( "
user principal: " + req.getUserPrincipal().getName() ); pw.println( "
authentication type: " + req.getAuthType() ); pw.println( "
user in footie role: " + req.isUserInRole( "footie" ) ); pw.println( "
are we using HTTPS: " + req.isSecure() ); } } /** * Here is a dump of the web.xml file containing the security * configuration details. *
footie_time</servlet-name>
com.ack.web.servlet.BasicAuthenticationWebResource</servlet-class> </servlet>
footie_time</servlet-name>
/protected/footie/get_time</url-pattern> </servlet-mapping>
security_info</servlet-name>
com.ack.servlet.GetSecurityInfo</servlet-class> </servlet>
security_info</servlet-name>
/protected/footie/info</url-pattern> </servlet-mapping>
protected_zone</web-resource-name>
/protected/footie/*</url-pattern>
GET</http-method>
POST</http-method>
PUT</http-method>
DELETE</http-method>
HEAD</http-method>
OPTIONS</http-method>
TRACE</http-method> </web-resource-collection>
footie</role-name> </auth-constraint>
NONE</transport-guarantee> </user-data-constraint> </security-constraint>
BASIC</auth-method>
pure genius football club</realm-name> </login-config>
the footie guys</description>
footie</role-name> </security-role> </web-app> */
Privacy Policy
|
Link to Us
|
Links