mirror of https://github.com/apache/jclouds.git
switch bad identity to AuthorizationException as it helps ensure we don't retry
This commit is contained in:
parent
2a4bcf83b0
commit
e1f64356d9
|
@ -18,8 +18,6 @@
|
|||
*/
|
||||
package org.jclouds.openstack.keystone.v2_0.functions;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
|
@ -27,6 +25,7 @@ import org.jclouds.domain.Credentials;
|
|||
import org.jclouds.openstack.keystone.v2_0.ServiceClient;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.Access;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.ApiAccessKeyCredentials;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -41,7 +40,10 @@ public class AuthenticateApiAccessKeyCredentials implements Function<Credentials
|
|||
|
||||
@Override
|
||||
public Access apply(Credentials input) {
|
||||
checkArgument(input.identity.indexOf(':') != -1, "format is tenantId:accesskey");
|
||||
if (input.identity.indexOf(':') == -1) {
|
||||
throw new AuthorizationException(String.format("Identity %s does not match format tenantId:accesskey",
|
||||
input.identity), null);
|
||||
}
|
||||
|
||||
String tenantId = input.identity.substring(0, input.identity.indexOf(':'));
|
||||
String usernameOrAccessKey = input.identity.substring(input.identity.indexOf(':') + 1);
|
||||
|
|
|
@ -17,14 +17,13 @@
|
|||
* under the License.
|
||||
*/
|
||||
package org.jclouds.openstack.keystone.v2_0.functions;
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.openstack.keystone.v2_0.ServiceClient;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.Access;
|
||||
import org.jclouds.openstack.keystone.v2_0.domain.PasswordCredentials;
|
||||
import org.jclouds.rest.AuthorizationException;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
|
@ -38,8 +37,11 @@ public class AuthenticatePasswordCredentials implements Function<Credentials, Ac
|
|||
|
||||
@Override
|
||||
public Access apply(Credentials input) {
|
||||
checkArgument(input.identity.indexOf(':') != -1, "format is tenantId:accesskey");
|
||||
|
||||
if (input.identity.indexOf(':') == -1) {
|
||||
throw new AuthorizationException(String.format("Identity %s does not match format tenantId:username",
|
||||
input.identity), null);
|
||||
}
|
||||
|
||||
String tenantId = input.identity.substring(0, input.identity.indexOf(':'));
|
||||
String usernameOrAccessKey = input.identity.substring(input.identity.indexOf(':') + 1);
|
||||
String passwordOrSecretKey = input.credential;
|
||||
|
|
Loading…
Reference in New Issue