简体   繁体   中英

Apache jClouds - Can we use authentication keystone v3 with application_credential?

Is the application_credential kesytone V3 supported by jClouds?

I am using OpenStack and I want to use application credential authentication with jClouds 2.2.1 ( https://specs.openstack.org/openstack/keystone-specs/specs/keystone/queens/application-credentials.html ).

Keystone module have an auth method called application_credential . Here is an example for the POST request for application_credential:

$ curl -i -H "Content-Type: application/json" -d \
'{
    "auth": {
        "identity": {
            "methods": [
                "application_credential"
            ],
            "application_credential": {
                "id": "50916383859f4d2f919c86315ffa17ba",
                "secret": "demo"
            }
        }
    }
}' \
"http://192.168.190.1:5000/v3/auth/tokens"

With Java, I have the code:

Properties overrides = new Properties();

overrides.put(KeystoneProperties.KEYSTONE_VERSION, "3");
overrides.put(KeystoneProperties.CREDENTIAL_TYPE,
              CredentialTypes.API_ACCESS_KEY_CREDENTIALS);
    
String accessKey = "accessKey";
String accessSecret = "accessSecret";
     
KeystoneApi keystone = ContextBuilder.newBuilder("openstack-keystone-3")
        .endpoint("https://keystone.domain/v3")
        .credentials(accessKey, accessSecret)
        .overrides(overrides)
        .modules(ImmutableSet.of(new SLF4JLoggingModule(),
                                 new OkHttpCommandExecutorServiceModule()))
        .buildApi(KeystoneApi.class);
     
keystone.getProjectApi().list();

It throws an exception:

lException in thread "main" java.lang.IllegalStateException: Optional.get() cannot be called on an absent value
        at com.google.common.base.Absent.get(Absent.java:47)
        at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:227)
        at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:137)
        at org.jclouds.rest.internal.InvokeHttpMethod.toCommand(InvokeHttpMethod.java:189)
        at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:85)
        at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
        at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
        at org.jclouds.rest.internal.DelegatesToInvocationFunction.handle(DelegatesToInvocationFunction.java:156)
        at org.jclouds.rest.internal.DelegatesToInvocationFunction.invoke(DelegatesToInvocationFunction.java:123)
        at com.sun.proxy.$Proxy52.authenticateAccessKey(Unknown Source)
        at org.jclouds.openstack.keystone.auth.functions.AuthenticateApiAccessKeyCredentials.authenticate(AuthenticateApiAccessKeyCredentials.java:48)
        at org.jclouds.openstack.keystone.auth.functions.BaseAuthenticator.apply(BaseAuthenticator.java:99)
        at org.jclouds.openstack.keystone.auth.functions.BaseAuthenticator.apply(BaseAuthenticator.java:40)
        at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(CacheLoader.java:151)
        at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3527)
        at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2319)
        at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2282)
        at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2197)
        at com.google.common.cache.LocalCache.get(LocalCache.java:3937)
        at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
        at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
        at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4830)
        at org.jclouds.openstack.keystone.auth.config.AuthenticationModule$2.get(AuthenticationModule.java:138)
        at org.jclouds.openstack.keystone.auth.config.AuthenticationModule$2.get(AuthenticationModule.java:135)
        at org.jclouds.openstack.keystone.v3.catalog.V3ServiceCatalog.get(V3ServiceCatalog.java:50)
        at org.jclouds.openstack.keystone.v3.catalog.V3ServiceCatalog.get(V3ServiceCatalog.java:35)
        at org.jclouds.openstack.keystone.catalog.suppliers.LocationIdToURIFromServiceEndpointsForTypeAndVersion.get(LocationIdToURIFromServiceEndpointsForTypeAndVersion.java:76)
        at org.jclouds.openstack.keystone.catalog.suppliers.LocationIdToURIFromServiceEndpointsForTypeAndVersion.get(LocationIdToURIFromServiceEndpointsForTypeAndVersion.java:46)
        at org.jclouds.util.Suppliers2$1.get(Suppliers2.java:35)
        at org.jclouds.util.Suppliers2$5.get(Suppliers2.java:110)
        at org.jclouds.util.Suppliers2$5.get(Suppliers2.java:110)
        at org.jclouds.util.Suppliers2$4.get(Suppliers2.java:86)
        at org.jclouds.rest.internal.RestAnnotationProcessor.getEndpointFor(RestAnnotationProcessor.java:562)
        at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:204)
        at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:137)
        at org.jclouds.rest.internal.InvokeHttpMethod.toCommand(InvokeHttpMethod.java:189)
        at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:85)
        at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
        at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
        at org.jclouds.reflect.FunctionalReflection$FunctionalInvocationHandler.handleInvocation(FunctionalReflection.java:117)
        at com.google.common.reflect.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:87)
        at com.sun.proxy.$Proxy56.list(Unknown Source)
        at com.docaposte.ese.document.manager.service.config.JCloudsSwift.main(JCloudsSwift.java:57)
    
    Process finished with exit code 1

Thank you in advance.

you still have [https://jclouds.apache.org/guides/openstack/][1]

For it's not working maybe I missed something [1]: https://jclouds.apache.org/guides/openstack/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM