-
May 20th, 2012, 03:16 AM
#1
Reading userCertificate from LDAP
I have to read the certificate from LDAP to check for its expiry date. My code is like this,,,,
List<?> CNs = ldapTemplate.search("", andFilter.encode(), new AttributesMapper() {
@Override
public Object mapFromAttributes(Attributes attributes) throws NamingException {
// TODO Auto-generated method stub
return (Object) attributes.get("userCertificate").get(); //LINE-1get the certificate given uid:
}
});
System.out.println("Cert List size: "+CNs.size()); // prints 1
String temp = CNs.get(0).toString();
InputStream in = new ByteArrayInputStream(temp.getBytes());
CertificateFactory factory = CertificateFactory.getInstance("X509");
X509Certificate cert = (X509Certificate) factory.generateCertificate(in); // ERROR :Could not parse certificate: java.io.IOException: Empty input
when "userCertficate;binary" is used, it throws NullPointerException at the LINE-1
Any idea?????????????
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules