AuthStoreUtils { public void load(AuthStore authStore, InputStream in) throws IOException { try { XMLReader xmlReader = XMLReaderFactory.createXMLReader(); xmlReader.setContentHandler(new AuthStoreHandler(authStore)); xmlReader.parse(new InputSource(in)); } catch (SAXException e) { throw new IOException(e); } } AuthStoreUtils(PasswordProvider passwordProvider); void save(AuthStore authStore, OutputStream out); void load(AuthStore authStore, InputStream in); PasswordProvider getPasswordProvider(); void setPasswordProvider(PasswordProvider passwordProvider); static final String USER; static final String HOST; static final String PROTOCOL; static final String ENTRY; static final String USER_AUTHENTICATION_DATA; static final String TYPE; static final String DATA; static final String ALGORITHM_BLOW_FISH; static final int SALT_LENGTH; }
@Test public void testLoad() throws Exception { MemoryAuthStore memoryAuthStore = new MemoryAuthStore(); InputStream resourceAsStream = this.getClass().getResourceAsStream("credentials.xml"); authStoreUtils.load(memoryAuthStore, resourceAsStream); assertEquals(memoryAuthStore.getAll().size(), 3); UserAuthenticationDataWrapper userAuthenticationData1 = memoryAuthStore.getUserAuthenticationData(new UserAuthenticationInfo("ftp", "host1", "stefan")); assertEquals(userAuthenticationData1.getData(UserAuthenticationData.USERNAME), "Stefan".toCharArray()); LOGGER.info("Password for stefan:" + new String(userAuthenticationData1.getData(UserAuthenticationData.PASSWORD))); assertEquals(userAuthenticationData1.getData(UserAuthenticationData.PASSWORD), "Password".toCharArray()); assertEquals(userAuthenticationData1.getData(new UserAuthenticationData.Type("path")), "c:\\file".toCharArray()); }