List of usage examples for org.apache.commons.vfs2 UserAuthenticationData UserAuthenticationData
public UserAuthenticationData()
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; }//from w w w . j a va2 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: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();// ww w. j a va 2s. com } } } 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 www . j a v a 2s. c o m } } } return data; }
From source file:org.esupportail.portlet.filemanager.services.vfs.auth.DynamicUserAuthenticator.java
public UserAuthenticationData requestAuthentication(Type[] types) { UserPassword userPassword = null;/*w w w . ja va 2 s. c o m*/ 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; }