//Insert LDAP attributes from the config file
getLDAPAttributes(id);
//First read the u/p the credentails store, in this case using the same as the root login
logger.debug("LDAPSSO: trying to get creds from repository ID: " + id);
Credential cred = null;
try {
cred = creds.getCredential(id);
} catch (NullPointerException npe) {
logger.error("NPE while reading credentials of ID: " + id);
}
if (cred == null) {
cred = creds.getCredential("root");
if (cred != null) {
logger.info("LDAPSSO: credential ID used is \"root\"");
} else {
logger.error("LDAPSSO: No credentials available for " + id);
}
}
Cookie[] cookies = null;
// Initialize status code
int statusCode = HttpServletResponse.SC_UNAUTHORIZED;
// Read cookies
cookies = request.getCookies();
try {
authMaxAge = Integer.parseInt(valveConf.getAuthMaxAge());
} catch (NumberFormatException nfe) {
logger.error("Configuration error: chack the configuration file as the number set for authMaxAge is not OK:");
}
//If the required cookie was not found need to authenticate.
logger.info("Authenticating root user with LDAP");
try {
//Check if the LDAP credentials are OK
Ldap ldapconn =
new Ldap(ldapHost, cred.getUsername(), cred.getPassword(),
ldapBaseuser, ldapDomain, rdnAttr);
try {
logger.debug("Connecting to LDAP");
DirContext ctx = ldapconn.openConnection();
if (ctx == null) {
//Just send a comment
logger.debug("The user(" + cred.getUsername() +
")/password doesn't match");
ldapconn.closeConnection(ctx);
return (HttpServletResponse.SC_UNAUTHORIZED);
}
//Fetching credentials
logger.debug("Fetching credentials from the LDAP");
fetchingCredentials(ldapconn, ctx, cred.getUsername(), creds);
//Close the connection
ldapconn.closeConnection(ctx);
} catch (Exception ex) {