Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

remote authentication with anchore engine using java client API #72

Closed
SyCode7 opened this issue Jul 15, 2018 · 2 comments
Closed

remote authentication with anchore engine using java client API #72

SyCode7 opened this issue Jul 15, 2018 · 2 comments

Comments

@SyCode7
Copy link

SyCode7 commented Jul 15, 2018

I did like to integrate my java application with a remotely deployed anchore-engine. I have used the API Client specified here as a guide . I still encounter authentication errors as below :

Exception in thread "main" io.swagger.client.ApiException: Unauthorized at io.swagger.client.ApiClient.handleResponse(ApiClient.java:922) at io.swagger.client.ApiClient.execute(ApiClient.java:838) at io.swagger.client.api.VulnerabilitiesApi.getImageVulnerabilitiesByTypeWithHttpInfo(VulnerabilitiesApi.java:142) at io.swagger.client.api.VulnerabilitiesApi.getImageVulnerabilitiesByType(VulnerabilitiesApi.java:127) at io.cavasTest.CavasTest.main(CavasTest.java:28)

I tried authenticating via the code below -
// Setup authentications (key: authentication name, value: authentication). authentications = new HashMap<String, Authentication>(); authentications.put("basicAuth", new HttpBasicAuth()); HttpBasicAuth httpBasicAuth = new HttpBasicAuth(); httpBasicAuth.setUsername("xxxxx"); httpBasicAuth.setPassword("xxxxx");

@zhill
Copy link
Member

zhill commented Jul 17, 2018

hi @SyCode7 , looks like you're setting the username and password in a different HttpBasicAuth object than the one you added to the authentications map. I think you need:

authentications = new HashMap<String, Authentication>();
HttpBasicAuth httpBasicAuth = new HttpBasicAuth();
httpBasicAuth.setUsername("xxxxx");
httpBasicAuth.setPassword("xxxxx");
authentications.put("basicAuth", httpBasicAuth); 

@SyCode7
Copy link
Author

SyCode7 commented Jul 18, 2018

@zhill thank you very much. This works, you are right the credentials were set in the wrong object. 👍

@nurmi nurmi closed this as completed Jul 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants