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();
}
}
Aggregations