List of usage examples for org.apache.commons.vfs2 UserAuthenticationData setData
public void setData(final Type type, final char[] data)
From source file:maspack.fileutil.vfs.SimpleUserAuthenticator.java
public UserAuthenticationData requestAuthentication(UserAuthenticationData.Type[] types) { UserAuthenticationData data = new UserAuthenticationData(); for (Type type : types) { if (type == UserAuthenticationData.DOMAIN) { data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(domain)); } else if (type == UserAuthenticationData.USERNAME) { data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(username)); } else if (type == UserAuthenticationData.PASSWORD) { try { // unfortunately, we seem to have to pass it in plaintext data.setData(UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(password)); } catch (Exception e) { e.printStackTrace();/*from ww w . j a va2 s.c o m*/ } } } return data; }
From source file:maspack.fileutil.vfs.EncryptedUserAuthenticator.java
public UserAuthenticationData requestAuthentication(UserAuthenticationData.Type[] types) { UserAuthenticationData data = new UserAuthenticationData(); for (Type type : types) { if (type == UserAuthenticationData.DOMAIN) { data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(domain)); } else if (type == UserAuthenticationData.USERNAME) { data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(username)); } else if (type == UserAuthenticationData.PASSWORD) { try { // unfortunately, we have to pass it in plaintext, but the original password // could be encrypted from the get-go using the global Cryptor String passwd = getCryptor().decrypt(encryptedPassword); char[] chars = UserAuthenticatorUtils.toChar(passwd); data.setData(UserAuthenticationData.PASSWORD, chars); } catch (Exception e) { e.printStackTrace();//from w ww.ja v a 2s.co m } } } return data; }
From source file:maspack.fileutil.vfs.ConsoleUserAuthenticator.java
public UserAuthenticationData requestAuthentication(Type[] types) { UserAuthenticationData data = new UserAuthenticationData(); System.out.println("Authentication requested..."); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); for (int i = 0; i < types.length; i++) { if (types[i] == UserAuthenticationData.DOMAIN) { System.out.print("Domain: "); String domain = storage.get(UserAuthenticationData.DOMAIN); if (domain == null) { try { domain = in.readLine(); // storage.put(UserAuthenticationData.DOMAIN, domain); } catch (IOException e) { e.printStackTrace(); continue; }// w w w . j av a2 s .c o m } data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(domain)); } else if (types[i] == UserAuthenticationData.USERNAME) { System.out.print("Username: "); String user = storage.get(UserAuthenticationData.DOMAIN); if (user == null) { try { user = in.readLine(); // storage.put(UserAuthenticationData.USERNAME, user); } catch (IOException e) { e.printStackTrace(); continue; } } data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(user)); } else if (types[i] == UserAuthenticationData.PASSWORD) { System.out.print("Password: "); String pass = storage.get(UserAuthenticationData.PASSWORD); if (pass == null) { try { pass = in.readLine(); // storage.put(UserAuthenticationData.PASSWORD, pass); } catch (IOException e) { e.printStackTrace(); continue; } } data.setData(UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(pass)); } } return data; }
From source file:org.esupportail.portlet.filemanager.services.vfs.auth.DynamicUserAuthenticator.java
public UserAuthenticationData requestAuthentication(Type[] types) { UserPassword userPassword = null;/*from w w w . j av a 2s. com*/ if (authenticatorService != null) { userPassword = authenticatorService.getUserPassword(userParameters); } if (userPassword == null) return null; UserAuthenticationData data = new UserAuthenticationData(); data.setData(UserAuthenticationData.DOMAIN, UserAuthenticatorUtils.toChar(userPassword.getDomain())); data.setData(UserAuthenticationData.USERNAME, UserAuthenticatorUtils.toChar(userPassword.getUsername())); data.setData(UserAuthenticationData.PASSWORD, UserAuthenticatorUtils.toChar(userPassword.getPassword())); return data; }
From source file:pl.otros.vfs.browser.auth.SftpUserAuthenticator.java
@Override protected void getAuthenticationData(UserAuthenticationData authenticationData) { super.getAuthenticationData(authenticationData); authenticationData.setData(UserAuthenticationDataWrapper.SSH_KEY, sshKeyFileField.getText().trim().toCharArray()); if (StringUtils.isNotBlank(sshKeyFileField.getText())) { try {/*from w w w.ja v a 2 s . c om*/ SftpFileSystemConfigBuilder.getInstance().setIdentities(getFileSystemOptions(), new File[] { new File(sshKeyFileField.getText()) }); //TODO set user auth data file path } catch (FileSystemException e) { e.printStackTrace(); } } }
From source file:pl.otros.vfs.browser.auth.SmbUserAuthenticator.java
@Override protected void getAuthenticationData(UserAuthenticationData authenticationData) { super.getAuthenticationData(authenticationData); authenticationData.setData(UserAuthenticationData.DOMAIN, fieldTf.getText().toCharArray()); }
From source file:pl.otros.vfs.browser.auth.UserPassUserAuthenticator.java
@Override protected void getAuthenticationData(UserAuthenticationData authenticationData) { authenticationData.setData(UserAuthenticationData.USERNAME, nameTf.getSelectedItem().toString().toCharArray()); authenticationData.setData(UserAuthenticationData.PASSWORD, passTx.getPassword()); }