public SimpleJsonExtractor(WorkUnitState workUnitState) throws FileSystemException { this.workUnitState = workUnitState; // Resolve the file to pull if (workUnitState.getPropAsBoolean(ConfigurationKeys.SOURCE_CONN_USE_AUTHENTICATION, false)) { // Add authentication credential if authentication is needed UserAuthenticator auth = new StaticUserAuthenticator(workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_DOMAIN, ""), workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USERNAME), PasswordManager.getInstance(workUnitState) .readPassword(workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_PASSWORD))); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); this.fileObject = VFS.getManager().resolveFile(workUnitState.getProp(SOURCE_FILE_KEY), opts); } else { this.fileObject = VFS.getManager().resolveFile(workUnitState.getProp(SOURCE_FILE_KEY)); } // Open the file for reading LOGGER.info("Opening file " + this.fileObject.getURL().toString()); this.bufferedReader = this.closer.register(new BufferedReader(new InputStreamReader(this.fileObject.getContent().getInputStream(), ConfigurationKeys.DEFAULT_CHARSET_ENCODING))); }
/** * Authenticates if there is an authenticator, else returns null. * * @param opts The FileSystemOptions. * @param authenticatorTypes An array of types describing the data to be retrieved. * @return A UserAuthenticationData object containing the data requested. */ public static UserAuthenticationData authenticate(final FileSystemOptions opts, final UserAuthenticationData.Type[] authenticatorTypes) { final UserAuthenticator auth = DefaultFileSystemConfigBuilder.getInstance().getUserAuthenticator(opts); return authenticate(auth, authenticatorTypes); }
/** * Authenticates if there is an authenticator, else returns null. * * @param opts The FileSystemOptions. * @param authenticatorTypes An array of types describing the data to be retrieved. * @return A UserAuthenticationData object containing the data requested. */ public static UserAuthenticationData authenticate(final FileSystemOptions opts, final UserAuthenticationData.Type[] authenticatorTypes) { final UserAuthenticator auth = DefaultFileSystemConfigBuilder.getInstance().getUserAuthenticator(opts); return authenticate(auth, authenticatorTypes); }
protected AbstractFileSystem(final FileName rootName, final FileObject parentLayer, final FileSystemOptions fileSystemOptions) { this.parentLayer = parentLayer; this.rootName = rootName; this.fileSystemOptions = fileSystemOptions; final FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance(); String uri = builder.getRootURI(fileSystemOptions); if (uri == null) { uri = rootName.getURI(); } this.rootURI = uri; }
protected AbstractFileSystem(final FileName rootName, final FileObject parentLayer, final FileSystemOptions fileSystemOptions) { this.parentLayer = parentLayer; this.rootName = rootName; this.fileSystemOptions = fileSystemOptions; final FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance(); String uri = builder.getRootURI(fileSystemOptions); if (uri == null) { uri = rootName.getURI(); } this.rootURI = uri; }
/** * Authenticates if there is an authenticator, else returns null. * * @param opts The FileSystemOptions. * @param authenticatorTypes An array of types describing the data to be retrieved. * @return A UserAuthenticationData object containing the data requested. */ public static UserAuthenticationData authenticate(final FileSystemOptions opts, final UserAuthenticationData.Type[] authenticatorTypes) { final UserAuthenticator auth = DefaultFileSystemConfigBuilder.getInstance().getUserAuthenticator(opts); return authenticate(auth, authenticatorTypes); }
protected AbstractFileSystem(final FileName rootName, final FileObject parentLayer, final FileSystemOptions fileSystemOptions) { this.parentLayer = parentLayer; this.rootName = rootName; this.fileSystemOptions = fileSystemOptions; final FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance(); String uri = builder.getRootURI(fileSystemOptions); if (uri == null) { uri = rootName.getURI(); } this.rootURI = uri; }
/** * Authenticates if there is an authenticator, else returns null. * * @param opts The FileSystemOptions. * @param authenticatorTypes An array of types describing the data to be retrieved. * @return A UserAuthenticationData object containing the data requested. */ public static UserAuthenticationData authenticate(final FileSystemOptions opts, final UserAuthenticationData.Type[] authenticatorTypes) { final UserAuthenticator auth = DefaultFileSystemConfigBuilder.getInstance().getUserAuthenticator(opts); return authenticate(auth, authenticatorTypes); }
protected AbstractFileSystem(final FileName rootName, final FileObject parentLayer, final FileSystemOptions fileSystemOptions) { this.parentLayer = parentLayer; this.rootName = rootName; this.fileSystemOptions = fileSystemOptions; final FileSystemConfigBuilder builder = DefaultFileSystemConfigBuilder.getInstance(); String uri = builder.getRootURI(fileSystemOptions); if (uri == null) { uri = rootName.getURI(); } this.rootURI = uri; }
protected void setupOptions(final FtpsFileSystemConfigBuilder builder) { builder.setConnectTimeout(fileSystemOptions, Integer.valueOf(1000)); builder.setSoTimeout(fileSystemOptions, Integer.valueOf(1000)); builder.setDataTimeout(fileSystemOptions, Integer.valueOf(2000)); UserAuthenticator auth = new StaticUserAuthenticator(null, "test", "test"); try { DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(fileSystemOptions, auth); } catch (FileSystemException e) { throw new RuntimeException(e); } }
protected FileSystemOptions getFileSystemOptions() throws FileSystemException { FileSystemOptions opts = new FileSystemOptions(); AWSCredentials credentials = S3CredentialsProvider.getAWSCredentials(); if ( credentials != null ) { StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator( null, credentials.getAWSAccessKeyId(), credentials.getAWSSecretKey() ); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator( opts, userAuthenticator ); } return opts; } }
private FileSystemOptions getFileSystemOptions() throws FileSystemException { FileSystemOptions opts = new FileSystemOptions(); AWSCredentials credentials = S3CredentialsProvider.getAWSCredentials(); if ( credentials != null ) { StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator( null, credentials.getAWSAccessKeyId(), credentials.getAWSSecretKey() ); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator( opts, userAuthenticator ); } return opts; }
public SimpleJsonExtractor(WorkUnitState workUnitState) throws FileSystemException { this.workUnitState = workUnitState; // Resolve the file to pull if (workUnitState.getPropAsBoolean(ConfigurationKeys.SOURCE_CONN_USE_AUTHENTICATION, false)) { // Add authentication credential if authentication is needed UserAuthenticator auth = new StaticUserAuthenticator(workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_DOMAIN, ""), workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USERNAME), PasswordManager.getInstance(workUnitState) .readPassword(workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_PASSWORD))); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); this.fileObject = VFS.getManager().resolveFile(workUnitState.getProp(SOURCE_FILE_KEY), opts); } else { this.fileObject = VFS.getManager().resolveFile(workUnitState.getProp(SOURCE_FILE_KEY)); } // Open the file for reading LOGGER.info("Opening file " + this.fileObject.getURL().toString()); this.bufferedReader = this.closer.register(new BufferedReader(new InputStreamReader(this.fileObject.getContent().getInputStream(), ConfigurationKeys.DEFAULT_CHARSET_ENCODING))); }
public SimpleJsonExtractor(WorkUnitState workUnitState) throws FileSystemException { this.workUnitState = workUnitState; // Resolve the file to pull if (workUnitState.getPropAsBoolean(ConfigurationKeys.SOURCE_CONN_USE_AUTHENTICATION, false)) { // Add authentication credential if authentication is needed UserAuthenticator auth = new StaticUserAuthenticator(workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_DOMAIN, ""), workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_USERNAME), PasswordManager.getInstance(workUnitState) .readPassword(workUnitState.getProp(ConfigurationKeys.SOURCE_CONN_PASSWORD))); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); this.fileObject = VFS.getManager().resolveFile(workUnitState.getProp(SOURCE_FILE_KEY), opts); } else { this.fileObject = VFS.getManager().resolveFile(workUnitState.getProp(SOURCE_FILE_KEY)); } // Open the file for reading LOGGER.info("Opening file " + this.fileObject.getURL().toString()); this.bufferedReader = this.closer.register(new BufferedReader(new InputStreamReader(this.fileObject.getContent().getInputStream(), ConfigurationKeys.DEFAULT_CHARSET_ENCODING))); }
public FileObject resolveFile( String fileUri ) throws FileSystemException, KettleFileException { VariableSpace vs = getVariableSpace(); FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator( opts, new StaticUserAuthenticator( null, getAccessKey(), getSecretKey() ) ); FileObject file = KettleVFS.getFileObject( fileUri, vs, opts ); return file; }
private FileSystemOptions getFileSystemOptions() throws FileSystemException { FileSystemOptions opts = new FileSystemOptions(); try { AWSCredentials credentials = S3CredentialsProvider.getAWSCredentials(); if ( credentials != null ) { StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator( null, credentials.getAWSAccessKeyId(), credentials.getAWSSecretKey() ); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator( opts, userAuthenticator ); } } catch ( SdkClientException e ) { throw new FileSystemException( e ); } return opts; }
private String getS3FileObjectPath() throws FileSystemException, KettleFileException { FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator( opts, new StaticUserAuthenticator( null, getAWSAccessKeyId(), getAWSSecretKey() ) ); FileObject stagingDirFileObject = KettleVFS.getFileObject( stagingDir, getVariables(), opts ); return stagingDirFileObject.getName().getPath(); }
protected FileSystemOptions getFileSystemOptions() throws FileSystemException { FileSystemOptions opts = new FileSystemOptions(); if ( !Const.isEmpty( getAccessKey() ) || !Const.isEmpty( getSecretKey() ) ) { // create a FileSystemOptions with user & password StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator( null, getVariableSpace().environmentSubstitute( getAccessKey() ), getVariableSpace().environmentSubstitute( getSecretKey() ) ); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator( opts, userAuthenticator ); } return opts; }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // We test with non-empty FS options to make sure they are propagated final FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, new StaticUserAuthenticator("domain", null, null)); // Locate the base Tar file final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tar").getAbsolutePath(); // Now build the nested file system final String uri = "tar:file:" + tarFilePath + "!/test.tar"; final FileObject tarFile = manager.resolveFile(uri, opts); final FileObject nestedFS = manager.createFileSystem(tarFile); return nestedFS.resolveFile("/"); } }
/** * Returns the base folder for tests. */ @Override public FileObject getBaseTestFolder(final FileSystemManager manager) throws Exception { // We test with non-empty FS options to make sure they are propagated final FileSystemOptions opts = new FileSystemOptions(); DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, new StaticUserAuthenticator("domain", null, null)); // Locate the base Tar file final String tarFilePath = AbstractVfsTestCase.getTestResource("nested.tar").getAbsolutePath(); // Now build the nested file system final String uri = "tar:file:" + tarFilePath + "!/test.tar"; final FileObject tarFile = manager.resolveFile(uri, opts); final FileObject nestedFS = manager.createFileSystem(tarFile); return nestedFS.resolveFile("/"); } }