in core/servicemix-core/src/main/java/org/apache/servicemix/jbi/security/login/CertificatesLoginModule.java [86:149]
public boolean login() throws LoginException {
File f = new File(baseDir, usersFile);
InputStream fis = null;
try {
fis = new java.io.FileInputStream(f);
users.load(fis);
} catch (IOException ioe) {
throw new LoginException("Unable to load user properties file " + f);
} finally {
if (fis != null) {
try {
fis.close();
fis = null;
} catch (IOException e) {
throw new LoginException("Unable to close user properties file " + f);
}
}
}
f = new File(baseDir, groupsFile);
try {
fis = new java.io.FileInputStream(f);
groups.load(fis);
} catch (IOException ioe) {
throw new LoginException("Unable to load group properties file " + f);
} finally {
if (fis != null) {
try {
fis.close();
fis = null;
} catch (IOException e) {
throw new LoginException("Unable to close group properties file " + f);
}
}
}
Callback[] callbacks = new Callback[1];
callbacks[0] = new CertificateCallback();
try {
callbackHandler.handle(callbacks);
} catch (IOException ioe) {
throw new LoginException(ioe.getMessage());
} catch (UnsupportedCallbackException uce) {
throw new LoginException(uce.getMessage() + " not available to obtain information from user");
}
X509Certificate cert = ((CertificateCallback) callbacks[0]).getCertificate();
if (cert == null) {
throw new FailedLoginException("Unable to retrieve certificate");
}
Principal principal = cert.getSubjectX500Principal();
String certName = principal.getName();
for (Iterator it = users.entrySet().iterator(); it.hasNext();) {
Map.Entry entry = (Map.Entry) it.next();
if (certName.equals(entry.getValue())) {
user = (String) entry.getKey();
principals.add(principal);
if (debug) {
LOGGER.debug("login {}", user);
}
return true;
}
}
throw new FailedLoginException();
}