public OImmutableUser(long version, OUser user) { this.version = version; this.name = user.getName(); this.password = user.getPassword(); this.status = user.getAccountStatus(); this.rid = user.getIdentity().getIdentity(); this.user = user; for (ORole role : user.getRoles()) { roles.add(new OImmutableRole(role)); } }
public OUser authenticate(final String iUserName, final String iUserPassword) { final String dbName = getDatabase().getName(); final OUser user = getUser(iUserName); if (user == null) throw new OSecurityAccessException(dbName, "User or password not valid for database: '" + dbName + "'"); if (user.getAccountStatus() != OSecurityUser.STATUSES.ACTIVE) throw new OSecurityAccessException(dbName, "User '" + iUserName + "' is not active"); if (!(getDatabase().getStorage() instanceof OStorageProxy)) { // CHECK USER & PASSWORD if (!user.checkPassword(iUserPassword)) { // WAIT A BIT TO AVOID BRUTE FORCE try { Thread.sleep(200); } catch (InterruptedException ignore) { Thread.currentThread().interrupt(); } throw new OSecurityAccessException(dbName, "User or password not valid for database: '" + dbName + "'"); } } return user; }
"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");
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 OUser authenticate(final OToken authToken) { final String dbName = getDatabase().getName(); if (authToken.getIsValid() != true) { throw new OSecurityAccessException(dbName, "Token not valid"); } OUser user = authToken.getUser(getDatabase()); if (user == null && authToken.getUserName() != null) { // Token handler may not support returning an OUser so let's get username (subject) and query: user = getUser(authToken.getUserName()); } if (user == null) { throw new OSecurityAccessException(dbName, "Authentication failed, could not load user from token"); } if (user.getAccountStatus() != STATUSES.ACTIVE) throw new OSecurityAccessException(dbName, "User '" + user.getName() + "' is not active"); return user; }