public static final String encryptPassword(final String iPassword) { return OSecurityManager.instance() .createHash(iPassword, OGlobalConfiguration.SECURITY_USER_PASSWORD_DEFAULT_ALGORITHM.getValueAsString(), true); }
public boolean checkPassword(final String iPassword) { return OSecurityManager.instance().checkPassword(iPassword, (String) document.field(PASSWORD_FIELD)); }
public boolean checkPassword(final String iPassword) { return OSecurityManager.instance().checkPassword(iPassword, getPassword()); }
@SuppressWarnings("unchecked") @ConsoleCommand(description = "Set a server user. If the user already exists, the password and permissions are updated. For more information look at http://orientdb.com/docs/last/Security.html#orientdb-server-security", onlineHelp = "Console-Command-Set-Server-User") public void setServerUser(@ConsoleParameter(name = "user-name", description = "User name") String iServerUserName, @ConsoleParameter(name = "user-password", description = "User password") String iServerUserPasswd, @ConsoleParameter(name = "user-permissions", description = "Permissions, look at http://orientdb.com/docs/last/Security.html#servers-resources") String iPermissions) { if (iServerUserName == null || iServerUserName.length() == 0) throw new IllegalArgumentException("User name null or empty"); if (iPermissions == null || iPermissions.length() == 0) throw new IllegalArgumentException("User permissions null or empty"); final File serverCfgFile = new File("../config/orientdb-server-config.xml"); if (!serverCfgFile.exists()) throw new OConfigurationException("Cannot access to file " + serverCfgFile); try { final OServerConfigurationManager serverCfg = new OServerConfigurationManager(serverCfgFile); final String defAlgo = OGlobalConfiguration.SECURITY_USER_PASSWORD_DEFAULT_ALGORITHM.getValueAsString(); final String hashedPassword = OSecurityManager.instance().createHash(iServerUserPasswd, defAlgo, true); serverCfg.setUser(iServerUserName, hashedPassword, iPermissions); serverCfg.saveConfiguration(); message("\nServer user '%s' set correctly", iServerUserName); } catch (Exception e) { error("\nError on loading %s file: %s", serverCfgFile, e.toString()); } }
public OUser authenticate(final String username, final String password) { if (delegate == null) throw new OSecurityAccessException("OSymmetricKeySecurity.authenticate() Delegate is null for username: " + username); if (database == null) throw new OSecurityAccessException("OSymmetricKeySecurity.authenticate() Database is null for username: " + username); final String dbName = database.getName(); OUser user = delegate.getUser(username); if (user == null) throw new OSecurityAccessException(dbName, "OSymmetricKeySecurity.authenticate() Username or Key is invalid for username: " + username); if (user.getAccountStatus() != OSecurityUser.STATUSES.ACTIVE) throw new OSecurityAccessException(dbName, "OSymmetricKeySecurity.authenticate() User '" + username + "' is not active"); try { OUserSymmetricKeyConfig userConfig = new OUserSymmetricKeyConfig(user); OSymmetricKey sk = OSymmetricKey.fromConfig(userConfig); String decryptedUsername = sk.decryptAsString(password); if (OSecurityManager.instance().checkPassword(username, decryptedUsername)) return user; } catch (Exception ex) { throw OException.wrapException(new OSecurityAccessException(dbName, "OSymmetricKeySecurity.authenticate() Exception for database: " + dbName + ", username: " + username + " " + ex .getMessage()), ex); } throw new OSecurityAccessException(dbName, "OSymmetricKeySecurity.authenticate() Username or Key is invalid for database: " + dbName + ", username: " + username); }
public OSharedContextEmbedded(OStorage storage) { schema = new OSchemaEmbedded(this); security = OSecurityManager.instance().newSecurity(); indexManager = new OIndexManagerShared(storage); functionLibrary = new OFunctionLibraryImpl(); scheduler = new OSchedulerImpl(); sequenceLibrary = new OSequenceLibraryImpl(); liveQueryOps = new OLiveQueryHook.OLiveQueryOps(); liveQueryOpsV2 = new OLiveQueryHookV2.OLiveQueryOps(); commandCache = new OCommandCacheSoftRefs(storage.getUnderlying()); statementCache = new OStatementCache( storage.getConfiguration().getContextConfiguration().getValueAsInteger(OGlobalConfiguration.STATEMENT_CACHE_SIZE)); executionPlanCache = new OExecutionPlanCache( storage.getConfiguration().getContextConfiguration().getValueAsInteger(OGlobalConfiguration.STATEMENT_CACHE_SIZE)); this.registerListener(executionPlanCache); queryStats = new OQueryStats(); activeDistributedQueries = new HashMap<>(); ((OAbstractPaginatedStorage) storage).setStorageConfigurationUpdateListener(update -> { for (OMetadataUpdateListener listener : browseListeners()) { listener.onStorageConfigurationUpdate(storage.getName(), update); } }); }