Search in sources :

Example 1 with SOSAuthenticationFailure

use of com.emc.storageos.vasa.fault.SOSAuthenticationFailure in project coprhd-controller by CoprHD.

the class SyncManager method verifyLogin.

/**
 * Makes call to Bourne to verify login attempt
 *
 * @param username
 * @param password
 * @throws SOSAuthenticationFailure
 *             on invalid login attempt
 * @throws SOSFailure
 */
public synchronized void verifyLogin(String username, String password) throws SOSAuthenticationFailure, SOSFailure {
    final String methodName = "verifyLogin(): ";
    final String FILE_COS_LIST_URI = "/file/vpools";
    try {
        _client.setLoginCredentials(username, password);
        _client.queryObject(FILE_COS_LIST_URI, String.class);
    } catch (NoSuchAlgorithmException e) {
        log.error(methodName + "NoSuchAlgorithmException occured", e);
        throw new SOSFailure(e);
    } catch (UniformInterfaceException e) {
        if (e.toString().contains("403 Forbidden")) {
            throw new SOSAuthenticationFailure("Incorrect login credentials");
        }
        if (e.toString().contains("401 Unauthorized")) {
            throw new SOSAuthenticationFailure("Incorrect login credentials");
        }
    }
}
Also used : UniformInterfaceException(com.sun.jersey.api.client.UniformInterfaceException) SOSFailure(com.emc.storageos.vasa.fault.SOSFailure) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) SOSAuthenticationFailure(com.emc.storageos.vasa.fault.SOSAuthenticationFailure)

Aggregations

SOSAuthenticationFailure (com.emc.storageos.vasa.fault.SOSAuthenticationFailure)1 SOSFailure (com.emc.storageos.vasa.fault.SOSFailure)1 UniformInterfaceException (com.sun.jersey.api.client.UniformInterfaceException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1