We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,996 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Client Authentication using Certificate

I'm currently working on a project where I need to Authenticate the Client using his/her certificate. I have created my own CA, Server and Client certificates and imported them into my browser. Then I wrote a JSP code just to read the certificate. That is the program returns the commonname, email, country, city and info I have in the certificate.

But I need to write a code where I need to check whether the client has the certificate. If YES, then I must display "Welcome <>". If NO, then I must display "Get the Certificate".

I have no idea how to do this. I read many post and found out getRemoteUser could help me doing this. But I am totally stuck here. I am also attaching my code to extract client information from the certificate.

My Code:

<%@page import="java.security.cert.X509Certificate"%>
<%
Object o = request.getAttribute("javax.servlet.request.X509Certificate");
if (o != null) {
X509Certificate certs[] = (X509Certificate[]) o;
X509Certificate cert = certs[0];
%>
<%= cert.getSubjectDN().getName() %>
<%
} else {
%>
Object was null.
<%
}
%>
1
Contributor
0
Replies
1
View
650U
Newbie Poster
8 posts since Apr 2011
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0637 seconds using 2.67MB