JBoss and PHP
PostPosted:Thu Oct 14, 2010 3:42 pm
by qu3ll0
Hello folks,
Apache stores information about the certificate used for authenticating a client into the $_SERVER array and I can use such vars by e.g. $_SERVER['SSL_CLIENT_S_DN_CN']
Somebody knows where jboss stores such info and how I can use such variables into jsp or php pages?
Cheers,
Qu3!
Re: JBoss and PHP
PostPosted:Thu Oct 14, 2010 9:18 pm
by jllort
I'm not sure if it could be usefult to you ?
Code: Select allrequest.isUserInRole("Role name") // is a method to know is a user has some role
take a look at request methods
Re: JBoss and PHP
PostPosted:Wed Oct 20, 2010 9:16 am
by qu3ll0
Thanks jllort.
I found the answer to my question. Posting here hoping it can be helpful.
Code: Select all<%@ page import="java.security.cert.Certificate"%>
<%@ page import="java.security.cert.X509Certificate"%>
String CliCertCN = "";
if (request.isSecure()) {
X509Certificate[] certs = (X509Certificate[]) request.getAttribute("javax.servlet.request.X509Certificate");
// certs[0] is the user's certificate while certs[1]..[n] are CA's certificates chained into the user's cert
// Printing some attribute
out.print("SubjectDN = " + certs[0].getSubjectDN().getName()+"<BR>");
out.print("Start Validity Date = " + certs[0].getNotBefore()+"<BR>");
out.print("End Validity Date = " + certs[0].getNotAfter()+"<BR>");
out.print("Issuer = " + certs[0].getIssuerDN().getName()+"<BR>");
// Extracting Subject CN from Subject DN
X509Certificate cert1 = certs[0];
String CliCertDN = null;
CliCertDN = cert1.getSubjectDN().getName();
String attributeName = "CN=";
int i = CliCertDN.indexOf(attributeName);
if (i < 0) {
return;
}
i += attributeName.length();
int j = CliCertDN.indexOf(",", i);
if (j - 1 <= 0) {
return;
}
CliCertCN = CliCertDN.substring(i, j).trim();
out.print("Subject CN = " +CliCertCN+"<BR>");
}
Qu3!