Package org.apache.commons.vfs2.auth

Examples of org.apache.commons.vfs2.auth.StaticUserAuthenticator


     */
    public void testDeleteAllFiles() throws Exception
    {
        final FileObject scratchFolder = createScratchFolder();

        assertEquals(scratchFolder.delete(new FileTypeSelector(FileType.FILE)), 2);
    }
View Full Code Here


    {
        FileObject file = null;
        try
        {
            file = getReadFolder().resolveFile("file1.txt");
            RandomAccessContent ra = file.getContent().getRandomAccessContent(RandomAccessMode.READ);

            // read first byte
            byte c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(0));
            assertEquals("fp", ra.getFilePointer(), 1);

            // start at pos 4
            ra.seek(3);
            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(3));
            assertEquals("fp", ra.getFilePointer(), 4);

            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(4));
            assertEquals("fp", ra.getFilePointer(), 5);

            // restart at pos 4
            ra.seek(3);
            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(3));
            assertEquals("fp", ra.getFilePointer(), 4);

            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(4));
            assertEquals("fp", ra.getFilePointer(), 5);

            // advance to pos 11
            ra.seek(10);
            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(10));
            assertEquals("fp", ra.getFilePointer(), 11);

            c = ra.readByte();
            assertEquals(c, TEST_DATA.charAt(11));
            assertEquals("fp", ra.getFilePointer(), 12);
        }
        finally
        {
            if (file != null)
            {
View Full Code Here

public class FTPFileSystem implements FileSystem {

  @Override
  public final void authSetup(final ConnectionDescription description, final FileSystemOptions options) throws FileSystemException {
    StaticUserAuthenticator auth = new StaticUserAuthenticator(null, description.getParameter(ConnectionDescription.PARAMETER_USERNAME), description.getSecretParameter(ConnectionDescription.PARAMETER_PASSWORD));
    FtpFileSystemConfigBuilder.getInstance().setPassiveMode(options, true);
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth);
  }
View Full Code Here

    }
  }

  @Override
  public final void authSetup(final ConnectionDescription description, final FileSystemOptions options) throws org.apache.commons.vfs2.FileSystemException {
    StaticUserAuthenticator auth = new StaticUserAuthenticator(null, description.getParameter(ConnectionDescription.PARAMETER_USERNAME), description.getSecretParameter(ConnectionDescription.PARAMETER_PASSWORD));
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth);
    SftpFileSystemConfigBuilder cfg = SftpFileSystemConfigBuilder.getInstance();
    if (null != sshDirName) {
      cfg.setKnownHosts(options, new File(sshDirName, "known_hosts"));
    }
View Full Code Here

    return new CommonsVfsConnection(description, this);
  }

  @Override
  public final void authSetup(final ConnectionDescription description, final FileSystemOptions options) throws org.apache.commons.vfs2.FileSystemException {
    StaticUserAuthenticator auth = new StaticUserAuthenticator(null, description.getParameter(ConnectionDescription.PARAMETER_USERNAME), description.getSecretParameter(ConnectionDescription.PARAMETER_PASSWORD));
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth);
  }
View Full Code Here

        assertFalse(isEmpty(config.getProperty(ACCESS_KEY)), NO_CREDENTIALS_MESSAGE);
        assertFalse(isEmpty(config.getProperty(SECRET_KEY)), NO_CREDENTIALS_MESSAGE);

        // Configure VFS
        StaticUserAuthenticator auth = new StaticUserAuthenticator(null, config.getProperty(ACCESS_KEY), config.getProperty(SECRET_KEY));
        FileSystemOptions opts = S3FileProvider.getDefaultFileSystemOptions();
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);
    }
View Full Code Here

    if (propertyResource == null) {
      throw new IOException(propertyFileLocation + " not found");
    }
    userConfig.load(propertyResource);
    // create authenticator
    final StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator(null, userConfig.getProperty("aws.key-id", ""),
        userConfig.getProperty("aws.key", ""));
    final FileSystemOptions options = S3FileProvider.getDefaultFileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, userAuthenticator);
    log.info("s3 provider initialized");
  }
View Full Code Here

   * @throws FileSystemException file system configuration could not be build
   */
    @Deprecated
  public static void initS3Provider(final String awsKeyId, final String awsKey) throws FileSystemException {
    // create authenticator
    final StaticUserAuthenticator userAuthenticator = new StaticUserAuthenticator(null, awsKeyId, awsKey);
    final FileSystemOptions options = S3FileProvider.getDefaultFileSystemOptions();
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, userAuthenticator);
    log.info("s3 provider initialized");
  }
View Full Code Here

     * @see org.springframework.beans.factory.FactoryBean#getObject()
     */
    @Override
    public FileSystemManager getObject() throws Exception {
        // Configure VFS
        StaticUserAuthenticator auth = new StaticUserAuthenticator(null, awsAccessKey, awsSecretKey);
        FileSystemOptions opts = S3FileProvider.getDefaultFileSystemOptions();
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth);

        return VFS.getManager();
    }
View Full Code Here

    public FilesCache getFilesCache()
    {
        if (cache == null)
        {
            // cache = new DefaultFilesCache();
            cache = new SoftRefFilesCache();
        }

        return cache;
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.vfs2.auth.StaticUserAuthenticator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.