use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OSecurityExternal method authenticate.
@Override
public OUser authenticate(final String iUsername, final String iUserPassword) {
OUser user = null;
final String dbName = getDatabase().getName();
if (!(getDatabase().getStorage() instanceof OStorageProxy)) {
if (Orient.instance().getSecurity() == null)
throw new OSecurityAccessException(dbName, "External Security System is null!");
// Uses the external authenticator.
// username is returned if authentication is successful, otherwise null.
String username = Orient.instance().getSecurity().authenticate(iUsername, iUserPassword);
if (username != null) {
user = getUser(username);
if (user == null)
throw new OSecurityAccessException(dbName, "User or password not valid for username: " + username + ", database: '" + dbName + "'");
if (user.getAccountStatus() != OSecurityUser.STATUSES.ACTIVE)
throw new OSecurityAccessException(dbName, "User '" + username + "' is not active");
} else {
// Will use the local database to authenticate.
if (Orient.instance().getSecurity().isDefaultAllowed()) {
user = super.authenticate(iUsername, iUserPassword);
} else {
// WAIT A BIT TO AVOID BRUTE FORCE
try {
Thread.sleep(200);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
throw new OSecurityAccessException(dbName, "User or password not valid for username: " + iUsername + ", database: '" + dbName + "'");
}
}
}
return user;
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OPropertyImpl method setDescription.
@Override
public OPropertyImpl setDescription(final String iDescription) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s description %s", getFullNameQuoted(), quoteString(iDescription));
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s description %s", getFullNameQuoted(), quoteString(iDescription));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(new OCommandSQL(cmd)).execute();
setDescriptionInternal(iDescription);
} else
setDescriptionInternal(iDescription);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OPropertyImpl method clearCustom.
public void clearCustom() {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
final String cmd = String.format("alter property %s custom clear", getFullNameQuoted());
final OCommandSQL commandSQL = new OCommandSQL(cmd);
if (storage instanceof OStorageProxy) {
database.command(commandSQL).execute();
} else if (isDistributedCommand()) {
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
clearCustomInternal();
} else
clearCustomInternal();
} finally {
releaseSchemaWriteLock();
}
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OPropertyImpl method setMin.
public OPropertyImpl setMin(final String min) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
acquireSchemaWriteLock();
try {
final ODatabaseDocumentInternal database = getDatabase();
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s min %s", getFullNameQuoted(), quoteString(min));
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s min %s", getFullNameQuoted(), quoteString(min));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setMinInternal(min);
} else
setMinInternal(min);
} finally {
releaseSchemaWriteLock();
}
return this;
}
use of com.orientechnologies.orient.core.storage.OStorageProxy in project orientdb by orientechnologies.
the class OPropertyImpl method setType.
public OPropertyImpl setType(final OType type) {
getDatabase().checkSecurity(ORule.ResourceGeneric.SCHEMA, ORole.PERMISSION_UPDATE);
final ODatabaseDocumentInternal database = getDatabase();
acquireSchemaWriteLock();
try {
final OStorage storage = database.getStorage();
if (storage instanceof OStorageProxy) {
final String cmd = String.format("alter property %s type %s", getFullNameQuoted(), quoteString(type.toString()));
database.command(new OCommandSQL(cmd)).execute();
} else if (isDistributedCommand()) {
final String cmd = String.format("alter property %s type %s", getFullNameQuoted(), quoteString(type.toString()));
final OCommandSQL commandSQL = new OCommandSQL(cmd);
commandSQL.addExcludedNode(((OAutoshardedStorage) storage).getNodeId());
database.command(commandSQL).execute();
setTypeInternal(type);
} else
setTypeInternal(type);
} finally {
releaseSchemaWriteLock();
}
owner.fireDatabaseMigration(database, globalRef.getName(), globalRef.getType());
return this;
}
Aggregations