use of mom.trd.opentheso.bdd.auth.exceptions.AuthenticatorConnectionException in project opentheso by miledrousset.
the class DBAuthenticator method connect.
/* (non-Javadoc)
* @see fr.persee.aldo.auth.Authenticator#connect()
*/
public void connect() throws AuthenticatorConnectionException {
try {
// Register the JDBC driver
Class.forName("org.postgresql.Driver");
// Get a connection to the database
conn = DriverManager.getConnection(authBean.getURL(), authBean.getLogin(), authBean.getPasswd());
} catch (ClassNotFoundException cnfe) {
log.fatal("Couldn't find driver class.", cnfe);
throw new AuthenticatorConnectionException();
} catch (SQLException sqle) {
log.fatal("Couldn't connect to database.", sqle);
throw new AuthenticatorConnectionException();
}
}
use of mom.trd.opentheso.bdd.auth.exceptions.AuthenticatorConnectionException in project opentheso by miledrousset.
the class FileAuthenticator method connect.
/* (non-Javadoc)
* @see fr.persee.aldo.auth.Authenticator#connect()
*/
public void connect() throws AuthenticatorConnectionException {
File authFile = authBean.getFile();
// Check if file exists
if (!authFile.exists()) {
log.fatal("Authentication file is missing.");
throw new AuthenticatorConnectionException();
}
// Check if file is a file (!)
if (!authFile.isFile()) {
log.fatal("Authentication file is not a valid file.");
throw new AuthenticatorConnectionException();
}
if (!authFile.canRead()) {
log.fatal("Authentication file can't be read.");
throw new AuthenticatorConnectionException();
}
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = builder.parse(authFile);
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Aggregations