public static void main(String[] args) { try { // First , we create a new Xenon using the XenonFactory (without providing any properties). Xenon xenon = XenonFactory.newXenon(null); // Next, we retrieve the Files and Credentials interfaces Files files = xenon.files(); Credentials credentials = xenon.credentials(); // To create a new FileSystem we need a Credential that enable us to access the location. Credential c = credentials.getDefaultCredential("file"); // We need to know the OS to determine the root of the file system String root; if (Utils.isWindows()) { root = "C:"; } else { root = "/"; } // Now we can create a FileSystem (we don't provide any properties). FileSystem fs = files.newFileSystem("file", root, c, null); // We can now uses the FileSystem to access files! // .... // If we are done we need to close the FileSystem and the credential credentials.close(c); files.close(fs); // Finally, we end Xenon to release all resources XenonFactory.endXenon(xenon); } catch (XenonException e) { System.out.println("CreateLocalFileSystem example failed: " + e.getMessage()); e.printStackTrace(); } }
@Override public Credential getInvalidCredential(Credentials credentials) throws Exception { return credentials.newPasswordCredential( "ssh", username, "wrongpassword".toCharArray(), new HashMap<String, String>()); }
@Override public Credential getPasswordCredential(Credentials credentials) throws Exception { return credentials.newPasswordCredential( "ssh", username, passwd, new HashMap<String, String>()); }
@Override public Credential getDefaultCredential(Credentials credentials) throws Exception { return credentials.getDefaultCredential("ssh"); }