/** * copy constructor * * @param copyFrom */ public UserInfo( IUser copyFrom ) { this.id = copyFrom.getObjectId(); this.login = copyFrom.getLogin(); this.password = copyFrom.getPassword(); this.username = copyFrom.getUsername(); this.description = copyFrom.getDescription(); this.enabled = copyFrom.isEnabled(); this.admin = copyFrom.isAdmin(); }
/** * Load user with login from repository and verify the password... * * @param rep * @param login * @param passwd * @throws KettleException */ public IUser loadUserInfo( IUser userInfo, String login, String passwd ) throws KettleException { if ( userInfo == null || login == null || login.length() <= 0 ) { throw new KettleDatabaseException( BaseMessages.getString( PKG, "UserInfo.Error.IncorrectPasswortLogin" ) ); } try { loadUserInfo( userInfo, login ); } catch ( KettleException ke ) { throw new KettleAuthException( BaseMessages.getString( PKG, "UserInfo.Error.IncorrectPasswortLogin" ) ); } // Verify the password: // decrypt password if needed and compare with the one String userPass = Encr.decryptPasswordOptionallyEncrypted( passwd ); if ( userInfo.getObjectId() == null || !userInfo.getPassword().equals( userPass ) ) { throw new KettleAuthException( BaseMessages.getString( PKG, "UserInfo.Error.IncorrectPasswortLogin" ) ); } return userInfo; }
/** * This method creates new user after all validations have been done. For updating user's data please use {@linkplain * #updateUser(IUser)}. * * @param userInfo user's info * @throws KettleException * @throws IllegalArgumentException if {@code userInfo.getObjectId() != null} */ public void saveUserInfo( IUser userInfo ) throws KettleException { normalizeUserInfo( userInfo ); if ( !validateUserInfo( userInfo ) ) { throw new KettleException( BaseMessages.getString( KettleDatabaseRepositorySecurityProvider.class, "KettleDatabaseRepositorySecurityProvider.ERROR_0001_UNABLE_TO_CREATE_USER" ) ); } if ( userInfo.getObjectId() != null ) { // not a message for UI throw new IllegalArgumentException( "Use updateUser() for updating" ); } String userLogin = userInfo.getLogin(); ObjectId exactMatch = userDelegate.getUserID( userLogin ); if ( exactMatch != null ) { // found the corresponding record in db, prohibit creation! throw new KettleException( BaseMessages.getString( KettleDatabaseRepositorySecurityProvider.class, "KettleDatabaseRepositorySecurityProvider.ERROR_0001_USER_NAME_ALREADY_EXISTS" ) ); } userDelegate.saveUserInfo( userInfo ); }
public void saveUserInfo( IUser userInfo ) throws KettleException { try { // Do we have a user id already? if ( userInfo.getObjectId() == null ) { userInfo.setObjectId( getUserID( userInfo.getLogin() ) ); // Get userid in the repository } if ( userInfo.getObjectId() == null ) { // This means the login doesn't exist in the database // and we have no id, so we don't know the old one... // Just grab the next user ID and do an insert: userInfo.setObjectId( repository.connectionDelegate.getNextUserID() ); repository.connectionDelegate.insertTableRow( "R_USER", fillTableRow( userInfo ) ); } else { repository.connectionDelegate.updateTableRow( "R_USER", "ID_USER", fillTableRow( userInfo ) ); } // Put a commit behind it! repository.commit(); } catch ( KettleDatabaseException dbe ) { throw new KettleException( BaseMessages.getString( PKG, "UserInfo.Error.SavingUser", userInfo.getLogin() ), dbe ); } }
if ( userinfo.getObjectId() == null ) { setNewUser( true );
public RowMetaAndData fillTableRow( IUser userInfo ) { RowMetaAndData r = new RowMetaAndData(); r.addValue( new ValueMetaInteger( "ID_USER" ), userInfo.getObjectId() ); r.addValue( new ValueMetaString( "LOGIN" ), userInfo.getLogin() ); r.addValue( new ValueMetaString( "PASSWORD" ), Encr.encryptPassword( userInfo .getPassword() ) ); r.addValue( new ValueMetaString( "NAME" ), userInfo.getUsername() ); r.addValue( new ValueMetaString( "DESCRIPTION" ), userInfo.getDescription() ); r.addValue( new ValueMetaBoolean( "ENABLED" ), Boolean.valueOf( userInfo.isEnabled() ) ); return r; }
public IUser loadUserInfo( IUser userInfo, String login ) throws KettleException { try { userInfo.setObjectId( getUserID( login ) ); if ( userInfo.getObjectId() != null ) { RowMetaAndData r = getUser( userInfo.getObjectId() ); if ( r != null ) { userInfo.setLogin( r.getString( "LOGIN", null ) ); userInfo.setPassword( Encr.decryptPassword( r.getString( "PASSWORD", null ) ) ); userInfo.setUsername( r.getString( "NAME", null ) ); userInfo.setDescription( r.getString( "DESCRIPTION", null ) ); userInfo.setEnabled( r.getBoolean( "ENABLED", false ) ); return userInfo; } else { throw new KettleDatabaseException( BaseMessages.getString( PKG, "UserInfo.Error.UserNotFound", login ) ); } } else { throw new KettleDatabaseException( BaseMessages.getString( PKG, "UserInfo.Error.UserNotFound", login ) ); } } catch ( KettleDatabaseException dbe ) { throw new KettleException( BaseMessages.getString( PKG, "UserInfo.Error.UserNotLoaded", login, "" ), dbe ); } }