/** * Copy the properties of the given FileURL into this FileURL. * * @param url FileURL instance whose properties should be imported into this one. */ public void importProperties(FileURL url) { // Slight optimization to avoid creating an enumeration if the FileURL doesn't have any property if(url.properties==null) return; Enumeration<String> propertyKeys = url.getPropertyNames(); String key; while(propertyKeys.hasMoreElements()) { key = propertyKeys.nextElement(); setProperty(key, url.getProperty(key)); } }
String passiveModeProperty = location.getProperty(PASSIVE_MODE_PROPERTY_NAME); this.encoding = location.getProperty(ENCODING_PROPERTY_NAME); if(encoding==null || encoding.equals("")) encoding = DEFAULT_ENCODING; String prop = location.getProperty(NB_CONNECTION_RETRIES_PROPERTY_NAME); if(prop==null) { nbConnectionRetries = DEFAULT_NB_CONNECTION_RETRIES; prop = location.getProperty(CONNECTION_RETRY_DELAY_PROPERTY_NAME); if(prop==null) { connectionRetryDelay = DEFAULT_CONNECTION_RETRY_DELAY;
/** * Use the credentials and realm properties of the specified <code>CredentialsMapping</code> to authenticate the * given {@link FileURL}. * <p>Any credentials contained by the <code>FileURL</code> will be lost and replaced with the new ones. * If properties with the same key are defined both in the realm and the given FileURL, the ones from the FileURL * will be preserved.</p> * * @param location the FileURL to authenticate * @param credentialsMapping the credentials to use to authenticate the given FileURL */ public static void authenticate(FileURL location, CredentialsMapping credentialsMapping) { location.setCredentials(credentialsMapping.getCredentials()); FileURL realm = credentialsMapping.getRealm(); Enumeration<String> propertyKeys = realm.getPropertyNames(); String key; while(propertyKeys.hasMoreElements()) { key = propertyKeys.nextElement(); if(location.getProperty(key)==null) location.setProperty(key, realm.getProperty(key)); } }
vmIdentifier = url2.getHost(); String guestCred = fileURL.getProperty(GUEST_CREDENTIALS); if ((guestCred != null) && (!guestCred.isEmpty())) { uinfo = guestCred;
attributes = new XmlAttributes(); attributes.add(ATTRIBUTE_NAME, name); attributes.add(ATTRIBUTE_VALUE, realm.getProperty(name)); out.startElement(ELEMENT_PROPERTY, attributes); out.endElement(ELEMENT_PROPERTY);
String nfsVersion = fileURL.getProperty(NFS_VERSION_PROPERTY_NAME); if(nfsVersion==null) nfsVersion = DEFAULT_NFS_VERSION; String nfsProtocol = fileURL.getProperty(NFS_PROTOCOL_PROPERTY_NAME); nfsProtocol = NFS_PROTOCOL_TCP.equals(nfsProtocol)?"t":NFS_PROTOCOL_UDP.equals(nfsProtocol)?"u":"";
port = 22; String privateKeyPath = realm.getProperty(SFTPFile.PRIVATE_KEY_PATH_PROPERTY_NAME); if (privateKeyPath != null) { LOGGER.info("Using {} authentication method", PUBLIC_KEY_AUTH_METHOD);
/** * Tests {@link FileURL#clone()}. * * @throws MalformedURLException should not happen */ @Test public void testClone() throws MalformedURLException { FileURL url = getURL("login", "password", "host", 10000, "/path/to", "query"); url.setProperty("name", "value"); FileURL clonedURL = (FileURL)url.clone(); // Assert that both instances are equal according to FileURL#equals assertEquals(url, clonedURL); // Assert that both URL's string representations (with credentials) are equal assert url.toString(true).equals(clonedURL.toString(true)); // Assert that both instances are not one and the same assert url!=clonedURL; // Assert that the property has survived the cloning assert "value".equals(clonedURL.getProperty("name")); }
assert query.equals(url.getQuery()); assert "to".equals(url.getFilename()); assert "value".equals(url.getProperty("name")); assert url.getQuery() == null; assert url.getFilename() == null; assert url.getProperty("name") == null; assert (scheme+"://").equals(url.toString(true, false));
assert "value".equals(parentURL.getProperty("key"));