mirror of https://github.com/apache/jclouds.git
corrected keystone parsing and default url for hp cloud storage
This commit is contained in:
parent
ad724de243
commit
567f845444
|
@ -18,6 +18,8 @@
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.keystone.v2_0.functions;
|
package org.jclouds.openstack.keystone.v2_0.functions;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@ -27,8 +29,6 @@ import org.jclouds.openstack.keystone.v2_0.domain.Access;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials;
|
import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class AuthenticateApiAccessKeyCredentials implements Function<Credentials, Access> {
|
public class AuthenticateApiAccessKeyCredentials implements Function<Credentials, Access> {
|
||||||
|
@ -41,10 +41,10 @@ public class AuthenticateApiAccessKeyCredentials implements Function<Credentials
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Access apply(Credentials input) {
|
public Access apply(Credentials input) {
|
||||||
// TODO: tenantID may not be present
|
checkArgument(input.identity.indexOf(':') != -1, "format is tenantId:accesskey");
|
||||||
Iterable<String> tenantIdUsernameOrAccessKey = Splitter.on(':').split(input.identity);
|
|
||||||
String tenantId = Iterables.get(tenantIdUsernameOrAccessKey, 0);
|
String tenantId = input.identity.substring(0, input.identity.indexOf(':'));
|
||||||
String usernameOrAccessKey = Iterables.get(tenantIdUsernameOrAccessKey, 1);
|
String usernameOrAccessKey = input.identity.substring(input.identity.indexOf(':') + 1);
|
||||||
String passwordOrSecretKey = input.credential;
|
String passwordOrSecretKey = input.credential;
|
||||||
|
|
||||||
ApiAccessKeyCredentials apiAccessKeyCredentials = ApiAccessKeyCredentials.createWithAccessKeyAndSecretKey(
|
ApiAccessKeyCredentials apiAccessKeyCredentials = ApiAccessKeyCredentials.createWithAccessKeyAndSecretKey(
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
package org.jclouds.openstack.keystone.v2_0.functions;
|
package org.jclouds.openstack.keystone.v2_0.functions;
|
||||||
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -26,8 +27,6 @@ import org.jclouds.openstack.keystone.v2_0.domain.Access;
|
||||||
import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials;
|
import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials;
|
||||||
|
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.base.Splitter;
|
|
||||||
import com.google.common.collect.Iterables;
|
|
||||||
|
|
||||||
public class AuthenticatePasswordCredentials implements Function<Credentials, Access> {
|
public class AuthenticatePasswordCredentials implements Function<Credentials, Access> {
|
||||||
private final ServiceClient client;
|
private final ServiceClient client;
|
||||||
|
@ -39,10 +38,10 @@ public class AuthenticatePasswordCredentials implements Function<Credentials, Ac
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Access apply(Credentials input) {
|
public Access apply(Credentials input) {
|
||||||
// TODO: tenantID may not be present
|
checkArgument(input.identity.indexOf(':') != -1, "format is tenantId:accesskey");
|
||||||
Iterable<String> tenantIdUsernameOrAccessKey = Splitter.on(':').split(input.identity);
|
|
||||||
String tenantId = Iterables.get(tenantIdUsernameOrAccessKey, 0);
|
String tenantId = input.identity.substring(0, input.identity.indexOf(':'));
|
||||||
String usernameOrAccessKey = Iterables.get(tenantIdUsernameOrAccessKey, 1);
|
String usernameOrAccessKey = input.identity.substring(input.identity.indexOf(':') + 1);
|
||||||
String passwordOrSecretKey = input.credential;
|
String passwordOrSecretKey = input.credential;
|
||||||
|
|
||||||
PasswordCredentials passwordCredentials = PasswordCredentials.createWithUsernameAndPassword(usernameOrAccessKey,
|
PasswordCredentials passwordCredentials = PasswordCredentials.createWithUsernameAndPassword(usernameOrAccessKey,
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<test.initializer>org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration.HPCloudObjectStorageLasVegasTestInitializer</test.initializer>
|
<test.initializer>org.jclouds.hpcloud.objectstorage.lvs.blobstore.integration.HPCloudObjectStorageLasVegasTestInitializer</test.initializer>
|
||||||
<test.hpcloud-objectstorage-lvs.endpoint>https://region-a.geo-1.objects.hpcloudsvc.com/auth</test.hpcloud-objectstorage-lvs.endpoint>
|
<test.hpcloud-objectstorage-lvs.endpoint>https://region-a.geo-1.identity.hpcloudsvc.com:35357</test.hpcloud-objectstorage-lvs.endpoint>
|
||||||
<test.hpcloud-objectstorage-lvs.api-version>1.0</test.hpcloud-objectstorage-lvs.api-version>
|
<test.hpcloud-objectstorage-lvs.api-version>1.0</test.hpcloud-objectstorage-lvs.api-version>
|
||||||
<test.hpcloud-objectstorage-lvs.build-version></test.hpcloud-objectstorage-lvs.build-version>
|
<test.hpcloud-objectstorage-lvs.build-version></test.hpcloud-objectstorage-lvs.build-version>
|
||||||
<test.hpcloud-objectstorage-lvs.identity>FIXME_IDENTITY</test.hpcloud-objectstorage-lvs.identity>
|
<test.hpcloud-objectstorage-lvs.identity>FIXME_IDENTITY</test.hpcloud-objectstorage-lvs.identity>
|
||||||
|
|
Loading…
Reference in New Issue