当前位置: 首页>>代码示例>>Java>>正文


Java StaticUserAuthenticator类代码示例

本文整理汇总了Java中org.apache.commons.vfs2.auth.StaticUserAuthenticator的典型用法代码示例。如果您正苦于以下问题:Java StaticUserAuthenticator类的具体用法?Java StaticUserAuthenticator怎么用?Java StaticUserAuthenticator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StaticUserAuthenticator类属于org.apache.commons.vfs2.auth包,在下文中一共展示了StaticUserAuthenticator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: WatchFTPRunner

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
public WatchFTPRunner(FTPConfig config) {
    this.config = config;
    try { 
        fsManager = VFS.getManager();
       
        UserAuthenticator auth = new StaticUserAuthenticator("", config.getConnection().getUsername(), config.getConnection().getPassword()); 
        DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
        FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts,true);
        FtpFileSystemConfigBuilder.getInstance().setPassiveMode(opts, true);
       
        resolvedAbsPath = fsManager.resolveFile(config.getFolder() + config.getConnection().getPathtomonitor() , opts);
        
        log.info("Connection successfully established to " +  resolvedAbsPath.getPublicURIString());        
        log.debug("Exists: " + resolvedAbsPath.exists());
        log.debug("Type  : " + resolvedAbsPath.getType());       
    } catch (FileSystemException e) {
        log.error("File system exception for " + config.getFolder(), e);
        //throw here?
    }
}
 
开发者ID:RapturePlatform,项目名称:Rapture,代码行数:21,代码来源:WatchFTPRunner.java

示例2: uploadFile

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
public static void uploadFile(String accntName, String accntHost, String accntKey, String containerName,
                                   Path localFile, Path remotePath) throws FileSystemException
{
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider());
    currMan.addProvider("file", new DefaultLocalFileProvider());
    currMan.init(); 
    
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", accntName, accntKey);
    FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
    
    String currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, accntHost, containerName, remotePath);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);
    FileObject currFile2 = currMan.resolveFile(
            String.format("file://%s", localFile));
    
    currFile.copyFrom(currFile2, Selectors.SELECT_SELF);
    
    currFile.close();
    currMan.close();
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:24,代码来源:AzTestUtils.java

示例3: deleteFile

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
public static void deleteFile(String accntName, String accntHost, String accntKey, String containerName,
                                   Path remotePath) throws FileSystemException
{
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider());
    currMan.init(); 
    
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", accntName, accntKey);
    FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
    
    String currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, accntHost, containerName, remotePath);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);
    
    Boolean delRes = currFile.delete();
    Assert.assertTrue(delRes);
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:19,代码来源:AzTestUtils.java

示例4: SimpleJsonExtractor

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
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)));
}
 
开发者ID:Hanmourang,项目名称:Gobblin,代码行数:24,代码来源:SimpleJsonExtractor.java

示例5: authSetup

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
@Override
public final void authSetup(final ConnectionDescription description, final FileSystemOptions options) throws FileSystemException {
	String username = description.getParameter(ConnectionDescription.PARAMETER_USERNAME);
	String password = description.getSecretParameter(ConnectionDescription.PARAMETER_PASSWORD);
	StaticUserAuthenticator auth = new StaticUserAuthenticator(null, username, password);
	DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth);
	SftpFileSystemConfigBuilder cfg = SftpFileSystemConfigBuilder.getInstance();
	//TODO: add cfg.setUserDirIsRoot(opts, false); and handle profile updates
	if (null != SSH_DIR_NAME) {
		cfg.setKnownHosts(options, new File(SSH_DIR_NAME, "known_hosts"));
	}
	logger.debug("SFTP using knownHosts: ", cfg.getKnownHosts(options));
	cfg.setUserInfo(options, this);
	cfg.setStrictHostKeyChecking(options, "ask");
	if ("enabled".equals(description.getParameter("publicKeyAuth"))) {
		cfg.setPreferredAuthentications(options, "publickey,password,keyboard-interactive");
	}
	else {
		cfg.setPreferredAuthentications(options, "password,keyboard-interactive");
	}
}
 
开发者ID:fullsync,项目名称:fullsync,代码行数:22,代码来源:SFTPAuthProvider.java

示例6: A001_uploadFile

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
/**
 * 
 */
@Test
public void A001_uploadFile() throws Exception
{
    String currAccountStr = testProperties.getProperty("azure.account.name");
    String currKey = testProperties.getProperty("azure.account.key");
    String currContainerStr = testProperties.getProperty("azure.test0001.container.name");
    String currHost = testProperties.getProperty("azure.host");  // <account>.blob.core.windows.net
    String currFileNameStr;
    
    File temp = File.createTempFile("uploadFile01", ".tmp");
    try(FileWriter fw = new FileWriter(temp))
    {
        BufferedWriter bw = new BufferedWriter(fw);
        bw.append("testing...");
        bw.flush();
    }
    
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider());
    currMan.addProvider("file", new DefaultLocalFileProvider());
    currMan.init(); 
    
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey);
    FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
    
    currFileNameStr = "test01.tmp";
    String currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);
    FileObject currFile2 = currMan.resolveFile(
            String.format("file://%s", temp.getAbsolutePath()));
    
    currFile.copyFrom(currFile2, Selectors.SELECT_SELF);
    temp.delete();
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:40,代码来源:AzFileProviderTest.java

示例7: A002_downloadFile

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
@Test
public void A002_downloadFile() throws Exception
{
    String currAccountStr = testProperties.getProperty("azure.account.name"); 
    String currKey = testProperties.getProperty("azure.account.key");
    String currContainerStr = testProperties.getProperty("azure.test0001.container.name");
    String currHost = testProperties.getProperty("azure.host"); // <account>.blob.core.windows.net
    String currFileNameStr;
    
    File temp = File.createTempFile("downloadFile01", ".tmp");
    
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider());
    currMan.addProvider("file", new DefaultLocalFileProvider());
    currMan.init(); 
    
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey);
    FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
    
    currFileNameStr = "test01.tmp";
    String currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);
    
    String destStr = String.format("file://%s", temp.getAbsolutePath());
    FileObject currFile2 = currMan.resolveFile( destStr );
    
    log.info( String.format("copying '%s' to '%s'", currUriStr, destStr));
    
    currFile2.copyFrom(currFile, Selectors.SELECT_SELF);
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:33,代码来源:AzFileProviderTest.java

示例8: A003_exist

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
@Test
public void A003_exist() throws Exception
{
    String currAccountStr = testProperties.getProperty("azure.account.name"); 
    String currKey = testProperties.getProperty("azure.account.key");
    String currContainerStr = testProperties.getProperty("azure.test0001.container.name");
    String currHost = testProperties.getProperty("azure.host");  // <account>.blob.core.windows.net
    String currFileNameStr;
    
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider());
    currMan.init(); 
    
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey);
    FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
    
    currFileNameStr = "test01.tmp";
    String currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);
    
    log.info( String.format("exist() file '%s'", currUriStr));
    
    Boolean existRes = currFile.exists();
    Assert.assertTrue(existRes);
    
    
    currFileNameStr = "non-existant-file-8632857264.tmp";
    currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, currAccountStr, currContainerStr, currFileNameStr);
    currFile = currMan.resolveFile(currUriStr, opts);
    
    log.info( String.format("exist() file '%s'", currUriStr));
    
    existRes = currFile.exists();
    Assert.assertFalse(existRes);
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:39,代码来源:AzFileProviderTest.java

示例9: A004_getContentSize

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
@Test
public void A004_getContentSize() throws Exception
{
    String currAccountStr = testProperties.getProperty("azure.account.name"); 
    String currKey = testProperties.getProperty("azure.account.key");
    String currContainerStr = testProperties.getProperty("azure.test0001.container.name");
    String currHost = testProperties.getProperty("azure.host");  // <account>.blob.core.windows.net
    String currFileNameStr;
    
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider());
    currMan.init(); 
    
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey);
    FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
    
    currFileNameStr = "test01.tmp";
    String currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);
    
    log.info( String.format("exist() file '%s'", currUriStr));
    
    FileContent cont = currFile.getContent();
    long contSize = cont.getSize();
    
    Assert.assertTrue(contSize>0);
    
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:31,代码来源:AzFileProviderTest.java

示例10: A005_listChildren

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
/**
 * By default FileObject.getChildren() will use doListChildrenResolved() if available
 * 
 * @throws Exception 
 */
@Test
public void A005_listChildren() throws Exception
{
    String currAccountStr = testProperties.getProperty("azure.account.name"); 
    String currKey = testProperties.getProperty("azure.account.key");
    String currContainerStr = testProperties.getProperty("azure.test0001.container.name");
    String currHost = testProperties.getProperty("azure.host");  // <account>.blob.core.windows.net
    
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider());
    currMan.init(); 
    
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey);
    FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
    
    String currFileNameStr = "uploadFile02";
    String currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);
    
    FileObject[] currObjs = currFile.getChildren();
    for(FileObject obj : currObjs)
    {
        FileName currName = obj.getName();
        Boolean res = obj.exists();
        FileType ft = obj.getType();
        
        log.info( String.format("\nNAME.PATH : '%s'\nEXISTS : %b\nTYPE : %s\n\n", 
                       currName.getPath(), res, ft));
    }
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:38,代码来源:AzFileProviderTest.java

示例11: A006_testContent

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
@Test
public void A006_testContent() throws Exception
{
    String currAccountStr = testProperties.getProperty("azure.account.name"); 
    String currKey = testProperties.getProperty("azure.account.key");
    String currContainerStr = testProperties.getProperty("azure.test0001.container.name");
    String currHost = testProperties.getProperty("azure.host");  // <account>.blob.core.windows.net
    String currFileNameStr;
    
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider());
    currMan.init(); 
    
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey);
    FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
    
    currFileNameStr = "file05";
    String currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);
    
    FileContent content = currFile.getContent();
    long size = content.getSize();
    Assert.assertTrue( size >= 0);
    
    long modTime = content.getLastModifiedTime();
    Assert.assertTrue(modTime>0);
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:30,代码来源:AzFileProviderTest.java

示例12: A007_deleteFile

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
@Test
public void A007_deleteFile() throws Exception
{
    String currAccountStr = testProperties.getProperty("azure.account.name"); 
    String currKey = testProperties.getProperty("azure.account.key");
    String currContainerStr = testProperties.getProperty("azure.test0001.container.name");
    String currHost = testProperties.getProperty("azure.host");  // <account>.blob.core.windows.net
    String currFileNameStr;
    
    DefaultFileSystemManager currMan = new DefaultFileSystemManager();
    currMan.addProvider(AzConstants.AZSBSCHEME, new AzFileProvider());
    currMan.init(); 
    
    StaticUserAuthenticator auth = new StaticUserAuthenticator("", currAccountStr, currKey);
    FileSystemOptions opts = new FileSystemOptions(); 
    DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(opts, auth); 
    
    currFileNameStr = "test01.tmp";
    String currUriStr = String.format("%s://%s/%s/%s", 
                       AzConstants.AZSBSCHEME, currHost, currContainerStr, currFileNameStr);
    FileObject currFile = currMan.resolveFile(currUriStr, opts);
    
    log.info( String.format("deleting '%s'", currUriStr));
    
    Boolean delRes = currFile.delete();
    Assert.assertTrue(delRes);
}
 
开发者ID:kervinpierre,项目名称:vfs-azure,代码行数:28,代码来源:AzFileProviderTest.java

示例13: authSetup

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
@Override
public final void authSetup(final ConnectionDescription description, final FileSystemOptions options) throws FileSystemException {
	String username = description.getParameter(ConnectionDescription.PARAMETER_USERNAME);
	String password = description.getSecretParameter(ConnectionDescription.PARAMETER_PASSWORD);
	StaticUserAuthenticator auth = new StaticUserAuthenticator(null, username, password);
	DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth);
}
 
开发者ID:fullsync,项目名称:fullsync,代码行数:8,代码来源:SmbAuthProvider.java

示例14: authSetup

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
@Override
public final void authSetup(final ConnectionDescription description, final FileSystemOptions options) throws FileSystemException {
	String username = description.getParameter(ConnectionDescription.PARAMETER_USERNAME);
	String password = description.getSecretParameter(ConnectionDescription.PARAMETER_PASSWORD);
	StaticUserAuthenticator auth = new StaticUserAuthenticator(null, username, password);
	FtpFileSystemConfigBuilder.getInstance().setPassiveMode(options, true);
	DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, auth);
}
 
开发者ID:fullsync,项目名称:fullsync,代码行数:9,代码来源:FTPAuthenticationProvider.java

示例15: testResolveFile_userAutheticator

import org.apache.commons.vfs2.auth.StaticUserAuthenticator; //导入依赖的package包/类
@Test
public void testResolveFile_userAutheticator() throws FileSystemException {
  UserAuthenticator userAuthenticator = new StaticUserAuthenticator( null, awsAccessKey, awsAccessKey );
  FileObject file = S3FileUtil.resolveFile( "s3://s3/", userAuthenticator );
  assertTrue( file.exists() );

  file = S3FileUtil.resolveFile( "s3://s3/_this_does_not_exist_", userAuthenticator );
  assertFalse( file.exists() );
}
 
开发者ID:pentaho,项目名称:pentaho-s3-vfs,代码行数:10,代码来源:S3FileUtilIT.java


注:本文中的org.apache.commons.vfs2.auth.StaticUserAuthenticator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。