fixed problem where passwords in the vapptemplate were being exposed. these are always reset on instantiate, so no use exposing them. in this case they were masking the real vapp pass

This commit is contained in:
Adrian Cole 2011-12-22 03:19:08 -08:00
parent 3a8ea09fb9
commit 4bbb9a9cc1
3 changed files with 3 additions and 24 deletions

View File

@ -40,7 +40,6 @@ import org.jclouds.functions.IdentityFunction;
import org.jclouds.vcloud.compute.functions.HardwareForVApp;
import org.jclouds.vcloud.compute.functions.HardwareForVAppTemplate;
import org.jclouds.vcloud.compute.functions.ImageForVAppTemplate;
import org.jclouds.vcloud.compute.functions.VAppTemplatesInOrg;
import org.jclouds.vcloud.compute.functions.VAppToNodeMetadata;
import org.jclouds.vcloud.compute.internal.VCloudTemplateBuilderImpl;
import org.jclouds.vcloud.compute.options.VCloudTemplateOptions;
@ -49,6 +48,7 @@ import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.Status;
import org.jclouds.vcloud.domain.VApp;
import org.jclouds.vcloud.domain.VAppTemplate;
import org.jclouds.vcloud.functions.VAppTemplatesInOrg;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;

View File

@ -38,7 +38,6 @@ import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeMetadataBuilder;
import org.jclouds.compute.domain.NodeState;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.logging.Logger;
import org.jclouds.util.InetAddresses2.IsPrivateIPAddress;
import org.jclouds.vcloud.domain.Status;
@ -87,8 +86,6 @@ public class VAppToNodeMetadata implements Function<VApp, NodeMetadata> {
Credentials fromApi = getCredentialsFrom(from);
if (fromApi != null && !credentialStore.containsKey("node#" + from.getHref().toASCIIString()))
credentialStore.put("node#" + from.getHref().toASCIIString(), fromApi);
builder.credentials(LoginCredentials.fromCredentials(credentialStore
.get("node#" + from.getHref().toASCIIString())));
return builder.build();
}
}

View File

@ -16,9 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.jclouds.vcloud.compute.functions;
import static org.jclouds.vcloud.compute.util.VCloudComputeUtils.getCredentialsFrom;
package org.jclouds.vcloud.functions;
import java.util.Map;
@ -26,7 +24,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import org.jclouds.domain.Credentials;
import org.jclouds.domain.LoginCredentials;
import org.jclouds.vcloud.domain.CatalogItem;
import org.jclouds.vcloud.domain.Org;
import org.jclouds.vcloud.domain.VAppTemplate;
@ -44,7 +41,6 @@ public class VAppTemplatesInOrg implements Function<Org, Iterable<VAppTemplate>>
private final AllCatalogItemsInOrg allCatalogItemsInOrg;
private final Function<Iterable<CatalogItem>, Iterable<VAppTemplate>> vAppTemplatesForCatalogItems;
private final Map<String, Credentials> credentialStore;
@Inject
VAppTemplatesInOrg(AllCatalogItemsInOrg allCatalogItemsInOrg,
@ -52,27 +48,13 @@ public class VAppTemplatesInOrg implements Function<Org, Iterable<VAppTemplate>>
Map<String, Credentials> credentialStore) {
this.allCatalogItemsInOrg = allCatalogItemsInOrg;
this.vAppTemplatesForCatalogItems = vAppTemplatesForCatalogItems;
this.credentialStore = credentialStore;
}
@Override
public Iterable<VAppTemplate> apply(Org from) {
Iterable<CatalogItem> catalogs = allCatalogItemsInOrg.apply(from);
Iterable<VAppTemplate> vAppTemplates = vAppTemplatesForCatalogItems.apply(catalogs);
return Iterables.transform(Iterables.filter(vAppTemplates, Predicates.notNull()),
new Function<VAppTemplate, VAppTemplate>() {
@Override
public VAppTemplate apply(VAppTemplate arg0) {
LoginCredentials creds = getCredentialsFrom(arg0);
if (creds == null)
credentialStore.remove("image#" + arg0.getHref().toASCIIString());
else
credentialStore.put("image#" + arg0.getHref().toASCIIString(), creds);
return arg0;
}
});
return Iterables.filter(vAppTemplates, Predicates.notNull());
}
}