Search in sources :

Example 1 with AuthenticatorConnectionException

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();
    }
}
Also used : AuthenticatorConnectionException(mom.trd.opentheso.bdd.auth.exceptions.AuthenticatorConnectionException) SQLException(java.sql.SQLException)

Example 2 with 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();
    }
}
Also used : AuthenticatorConnectionException(mom.trd.opentheso.bdd.auth.exceptions.AuthenticatorConnectionException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IOException(java.io.IOException) File(java.io.File) SAXException(org.xml.sax.SAXException)

Aggregations

AuthenticatorConnectionException (mom.trd.opentheso.bdd.auth.exceptions.AuthenticatorConnectionException)2 File (java.io.File)1 IOException (java.io.IOException)1 SQLException (java.sql.SQLException)1 DocumentBuilder (javax.xml.parsers.DocumentBuilder)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 SAXException (org.xml.sax.SAXException)1