List of usage examples for org.apache.commons.vfs2 UserAuthenticationData DOMAIN
Type DOMAIN
To view the source code for org.apache.commons.vfs2 UserAuthenticationData DOMAIN.
Click Source Link
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 . ja va 2 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();/*w w w .j a v a2 s . co 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();// ww w .j a v a2 s .c o m } } } return data; }
From source file:maspack.fileutil.vfs.SimpleUserAuthenticator.java
public boolean equals(UserAuthenticator obj) { UserAuthenticationData data = obj.requestAuthentication(ALL_AUTH_DATA); try {/* w ww.j a va 2 s. c om*/ String str = new String(data.getData(UserAuthenticationData.DOMAIN)); if (!equals(str, domain)) { return false; } } catch (NullPointerException e) { // no domain if (domain != null) { return false; } } try { String str = new String(data.getData(UserAuthenticationData.USERNAME)); if (!equals(str, username)) { return false; } } catch (NullPointerException e) { // no username if (username != null) { return false; } } try { String str = new String(data.getData(UserAuthenticationData.PASSWORD)); if (!equals(str, password)) { return false; } } catch (Exception e) { // no password if (password != null) { return false; } } return true; }
From source file:maspack.fileutil.vfs.EncryptedUserAuthenticator.java
public boolean equals(UserAuthenticator obj) { UserAuthenticationData data = obj.requestAuthentication(ALL_AUTH_DATA); String str = new String(data.getData(UserAuthenticationData.DOMAIN)); if (!equals(str, domain)) { return false; }// w ww . ja v a2 s. com str = new String(data.getData(UserAuthenticationData.USERNAME)); if (!equals(str, username)) { return false; } str = new String(data.getData(UserAuthenticationData.PASSWORD)); try { // encrypt password str = getCryptor().encrypt(str); if (!equals(str, encryptedPassword)) { return false; } } catch (Exception e) { } return true; }
From source file:org.esupportail.portlet.filemanager.services.vfs.auth.DynamicUserAuthenticator.java
public UserAuthenticationData requestAuthentication(Type[] types) { UserPassword userPassword = null;/* w w w . j a v a 2 s .c om*/ 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.AuthStoreUtilsTest.java
@Test public void testSave() throws Exception { //given/*from ww w. j ava 2s . co m*/ AuthStore authStore = new MemoryAuthStore(); UserAuthenticationDataWrapper authenticationData1 = new UserAuthenticationDataWrapper(); authenticationData1.setData(UserAuthenticationData.USERNAME, "Stefan".toCharArray()); authenticationData1.setData(UserAuthenticationData.PASSWORD, "Password".toCharArray()); authenticationData1.setData(new UserAuthenticationData.Type("path"), "c:\\file".toCharArray()); UserAuthenticationDataWrapper authenticationData2 = new UserAuthenticationDataWrapper(); authenticationData2.setData(UserAuthenticationData.USERNAME, "Stefaan".toCharArray()); authenticationData2.setData(UserAuthenticationData.PASSWORD, "Passwodrd".toCharArray()); authenticationData2.setData(UserAuthenticationData.DOMAIN, "MS".toCharArray()); UserAuthenticationDataWrapper authenticationData3 = new UserAuthenticationDataWrapper(); authenticationData3.setData(UserAuthenticationData.USERNAME, "Stefan".toCharArray()); authenticationData3.setData(UserAuthenticationData.PASSWORD, "Passwo@rd".toCharArray()); authenticationData3.setData(UserAuthenticationData.DOMAIN, "MSzx!X%a".toCharArray()); authStore.add(new UserAuthenticationInfo("ftp", "host1", "stefan"), authenticationData1); authStore.add(new UserAuthenticationInfo("ftp", "host1", "stefan9"), authenticationData1); authStore.add(new UserAuthenticationInfo("sftp", "host1a", "astefan"), authenticationData1); ByteArrayOutputStream bout = new ByteArrayOutputStream(); String expected = IOUtils.toString(this.getClass().getResourceAsStream("credentials.xml")); expected = expected.replaceAll(">\\s+", ">").replaceAll("\\s+<", "<") .replaceAll("<Type>password</Type><Data>.*?<", "<Type>password</Type><Data><").trim(); //when authStoreUtils.save(authStore, bout); //then System.out.println(new String(bout.toByteArray())); String result = new String(bout.toByteArray()).replaceAll(">\\s+", ">").replaceAll("\\s+<", "<") .replaceAll("<Type>password</Type><Data>.*?<", "<Type>password</Type><Data><").trim(); assertEquals(result, expected); }
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.SmbUserAuthenticator.java
@Override protected void userSelectedHook(UserAuthenticationData userAuthenticationData) { char[] domain = new char[0]; if (userAuthenticationData != null) { domain = userAuthenticationData.getData(UserAuthenticationData.DOMAIN); }//w w w. ja va2 s .c o m fieldTf.setText(new String(domain)); }