Search in sources :

Example 1 with OCredentialInterceptor

use of com.orientechnologies.orient.core.security.OCredentialInterceptor in project orientdb by orientechnologies.

the class OStorageRemote method open.

public void open(final String iUserName, final String iUserPassword, final Map<String, Object> iOptions) {
    stateLock.acquireWriteLock();
    addUser();
    try {
        OStorageRemoteSession session = getCurrentSession();
        if (status == STATUS.CLOSED || !iUserName.equals(session.connectionUserName) || !iUserPassword.equals(session.connectionUserPassword) || session.sessions.isEmpty()) {
            OCredentialInterceptor ci = OSecurityManager.instance().newCredentialInterceptor();
            if (ci != null) {
                ci.intercept(getURL(), iUserName, iUserPassword);
                session.connectionUserName = ci.getUsername();
                session.connectionUserPassword = ci.getPassword();
            } else // Do Nothing
            {
                session.connectionUserName = iUserName;
                session.connectionUserPassword = iUserPassword;
            }
            parseOptions(iOptions);
            openRemoteDatabase();
            final OStorageConfiguration storageConfiguration = new OStorageRemoteConfiguration(this, recordFormat);
            storageConfiguration.load(iOptions);
            configuration = storageConfiguration;
            componentsFactory = new OCurrentStorageComponentsFactory(configuration);
        } else {
            reopenRemoteDatabase();
        }
    } catch (Exception e) {
        removeUser();
        if (e instanceof RuntimeException)
            // PASS THROUGH
            throw (RuntimeException) e;
        else
            throw OException.wrapException(new OStorageException("Cannot open the remote storage: " + name), e);
    } finally {
        stateLock.releaseWriteLock();
    }
}
Also used : OCredentialInterceptor(com.orientechnologies.orient.core.security.OCredentialInterceptor) OCurrentStorageComponentsFactory(com.orientechnologies.orient.core.db.record.OCurrentStorageComponentsFactory) OStorageConfiguration(com.orientechnologies.orient.core.config.OStorageConfiguration) OException(com.orientechnologies.common.exception.OException) NamingException(javax.naming.NamingException) OTokenException(com.orientechnologies.orient.core.metadata.security.OTokenException) ODistributedRedirectException(com.orientechnologies.orient.enterprise.channel.binary.ODistributedRedirectException) OInterruptedException(com.orientechnologies.common.concur.lock.OInterruptedException) OTokenSecurityException(com.orientechnologies.orient.enterprise.channel.binary.OTokenSecurityException) OIOException(com.orientechnologies.common.io.OIOException) IOException(java.io.IOException) OOfflineNodeException(com.orientechnologies.common.concur.OOfflineNodeException) OModificationOperationProhibitedException(com.orientechnologies.common.concur.lock.OModificationOperationProhibitedException)

Aggregations

OOfflineNodeException (com.orientechnologies.common.concur.OOfflineNodeException)1 OInterruptedException (com.orientechnologies.common.concur.lock.OInterruptedException)1 OModificationOperationProhibitedException (com.orientechnologies.common.concur.lock.OModificationOperationProhibitedException)1 OException (com.orientechnologies.common.exception.OException)1 OIOException (com.orientechnologies.common.io.OIOException)1 OStorageConfiguration (com.orientechnologies.orient.core.config.OStorageConfiguration)1 OCurrentStorageComponentsFactory (com.orientechnologies.orient.core.db.record.OCurrentStorageComponentsFactory)1 OTokenException (com.orientechnologies.orient.core.metadata.security.OTokenException)1 OCredentialInterceptor (com.orientechnologies.orient.core.security.OCredentialInterceptor)1 ODistributedRedirectException (com.orientechnologies.orient.enterprise.channel.binary.ODistributedRedirectException)1 OTokenSecurityException (com.orientechnologies.orient.enterprise.channel.binary.OTokenSecurityException)1 IOException (java.io.IOException)1 NamingException (javax.naming.NamingException)1