HadoopFileInputMeta extends TextFileInputMeta implements HadoopFileMeta { protected String encryptDecryptPassword( String source, EncryptDirection direction ) { Validate.notNull( direction, "'direction' must not be null" ); try { URI uri = new URI( source ); String userInfo = uri.getUserInfo(); if ( userInfo != null ) { String[] userInfoArray = userInfo.split( ":", 2 ); if ( userInfoArray.length < 2 ) { return source; } String password = userInfoArray[ 1 ]; String processedPassword; switch ( direction ) { case ENCRYPT: processedPassword = Encr.encryptPasswordIfNotUsingVariables( password ); break; case DECRYPT: processedPassword = Encr.decryptPasswordOptionallyEncrypted( password ); break; default: throw new InvalidParameterException( "direction must be 'ENCODE' or 'DECODE'" ); } URI encryptedUri = new URI( uri.getScheme(), userInfoArray[ 0 ] + ":" + processedPassword, uri.getHost(), uri.getPort(), uri.getPath(), uri.getQuery(), uri.getFragment() ); return encryptedUri.toString(); } } catch ( URISyntaxException e ) { return source; } return source; } HadoopFileInputMeta();  HadoopFileInputMeta( NamedClusterService namedClusterService ); String loadUrl( String url, String ncName, IMetaStore metastore, Map<String, String> mappings ); void setNamedClusterURLMapping( Map<String, String> mappings ); Map<String, String> getNamedClusterURLMapping(); @Override String getClusterName( final String url ); String getClusterNameBy( String url ); String getUrlPath( String incomingURL ); void setVariableSpace( VariableSpace variableSpace ); NamedClusterService getNamedClusterService(); @Override FileInputList getFileInputList( VariableSpace space ); static final String SOURCE_CONFIGURATION_NAME; static final String LOCAL_SOURCE_FILE; static final String STATIC_SOURCE_FILE; static final String S3_SOURCE_FILE; static final String S3_DEST_FILE; @Injection( name = "ENVIRONMENT", group = "FILENAME_LINES" )
  public String[] environment; }
@Test public void testEncryption() throws Exception { KettleEnvironment.init(); HadoopFileInputMeta meta = new HadoopFileInputMeta(); String url = "hdfs: String encrypted = meta.encryptDecryptPassword( url, HadoopFileInputMeta.EncryptDirection.ENCRYPT ); assertTrue( !encrypted.contains( "password" ) ); assertEquals( url, meta.encryptDecryptPassword( encrypted, HadoopFileInputMeta.EncryptDirection.DECRYPT ) ); }
@Test public void testNoPassword() throws Exception { KettleEnvironment.init(); HadoopFileInputMeta meta = new HadoopFileInputMeta(); String url = "hdfs: String encrypted = meta.encryptDecryptPassword( url, HadoopFileInputMeta.EncryptDirection.ENCRYPT ); assertEquals( url, meta.encryptDecryptPassword( encrypted, HadoopFileInputMeta.EncryptDirection.DECRYPT ) ); }