/** * 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(); }
/** * Normalizes {@code user}'s data. According to {@linkplain #checkUserInfo(IUser) common rules}, simply trims login * and name. * * @param user user * @return normalized instance * @throws NullPointerException if {@code user} is {@code null} or {@code user}'s login and name */ public static IUser normalizeUserInfo( IUser user ) { user.setLogin( user.getLogin().trim() ); user.setName( user.getName().trim() ); return user; } }
public IUser getUserInfo() throws KettleException { IUser userInfo = rsm.constructUser(); userInfo.setDescription( description ); userInfo.setLogin( name ); userInfo.setName( name ); userInfo.setUsername( name ); userInfo.setPassword( password ); return userInfo; } }
public UserRoleListDelegate( PurRepositoryMeta repositoryMeta, IUser userInfo, Log logger, ServiceManager serviceManager ) { try { this.logger = logger; userDetailsRoleListWebService = serviceManager.createService( userInfo.getLogin(), userInfo.getPassword(), IUserRoleListWebService.class ); updateUserRoleList(); } catch ( Exception e ) { this.logger.error( BaseMessages.getString( PKG, "UserRoleListDelegate.ERROR_0001_UNABLE_TO_INITIALIZE_USER_ROLE_LIST_WEBSVC" ), e ); //$NON-NLS-1$ } }
public String getName() { return user.getLogin(); }
public void updateUserInLookupSet( IUser user ) { IUser userInfoToUpdate = null; for ( IUser userInfo : userInfoSet ) { if ( userInfo.getLogin().equals( user.getLogin() ) ) { userInfoToUpdate = userInfo; break; } } userInfoToUpdate.setDescription( user.getDescription() ); if ( !StringUtils.isEmpty( user.getPassword() ) ) { userInfoToUpdate.setPassword( user.getPassword() ); } if ( user instanceof IEEUser ) { ( (IEEUser) userInfoToUpdate ).setRoles( ( (IEEUser) user ).getRoles() ); } }
public void getData() { if ( userinfo.getLogin() != null ) { wLogin.setText( userinfo.getLogin() ); } if ( userinfo.getPassword() != null ) { wPassword.setText( userinfo.getPassword() ); } if ( userinfo.getUsername() != null ) { wUsername.setText( userinfo.getUsername() ); } if ( userinfo.getDescription() != null ) { wDescription.setText( userinfo.getDescription() ); // WANTED: Add enabled option from UserInfo here!!!! } }
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 ); } }
/** * Validates {@code user}'s data. Common rule for all repositories is: both login and name must contain at least one * meaningful char. * * @param user user * @return {@code true} if user's login and name are not empty * @throws NullPointerException is {@code user} is {@code null} */ public static boolean checkUserInfo( IUser user ) { return !StringUtils.isBlank( user.getLogin() ) && !StringUtils.isBlank( user.getName() ); }
public static ProxyPentahoUser convertToPentahoProxyUser( IUser userInfo ) { ProxyPentahoUser user = new ProxyPentahoUser(); user.setName( userInfo.getLogin() ); // Since we send the empty password to the client, if the client has not modified the password then we do change it if ( !StringUtils.isEmpty( userInfo.getPassword() ) ) { user.setPassword( userInfo.getPassword() ); } user.setDescription( userInfo.getDescription() ); return user; }
private Boolean isAdmin() { return getRepository().getUserInfo().isAdmin(); } }
public IUser loadUserInfo( String login, String password ) throws KettleException { // Create a UserInfo object IUser user = constructUser(); user.setLogin( login ); user.setPassword( password ); user.setName( login ); return user; }
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 ); } }
user1.setLogin( username ); user1.setPassword( decryptedPassword ); user1.setName( username ); result.setUser( user1 ); user1.setLogin( name ); user1.setName( name ); user1.setPassword( decryptedPassword ); result.setUser( user1 ); result.setSuccess( true ); result.getUser().setAdmin( PentahoSystem.get( IAuthorizationPolicy.class ).isAllowed( IAbsSecurityProvider.ADMINISTER_SECURITY_ACTION ) result.getUser().setAdmin( isAdmin ); result.getUser().setLogin( userName );
public SchedulerRequest build() { baseUrl = getRepositoryServiceBaseUrl(); httpPost = new HttpPost( baseUrl + API_SCHEDULER_JOB ); httpPost.setHeader( CONTENT_TYPE, APPLICATION_XML ); String username = repository.getUserInfo().getName(); String password = repository.getUserInfo().getPassword(); if ( username != null && password != null ) { byte[] encoding; try { String userPass = username + ":" + password; encoding = Base64.getEncoder().encode( userPass.getBytes( UTF_8 ) ); httpPost.setHeader( AUTHORIZATION, "Basic " + new String( encoding ) ); } catch ( UnsupportedEncodingException e ) { e.printStackTrace(); } } return new SchedulerRequest( this ); }
/** * 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 ); }
/** * 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; }
private KettleException cannotCreateUserException( IUser user, Exception e ) { return new KettleException( BaseMessages.getString( UserRoleDelegate.class, "UserRoleDelegate.ERROR_0002_UNABLE_TO_CREATE_USER", user.getName() ), e ); }
public String getPassword() { return user.getPassword(); }