Skip to content
This repository has been archived by the owner on Oct 22, 2024. It is now read-only.

Commit

Permalink
feat: simple authentication and refactor logging
Browse files Browse the repository at this point in the history
(cherry picked from commit a7600ee)
  • Loading branch information
1nb0und committed Dec 25, 2023
1 parent 149f7e3 commit 4f0f91b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private String retrieveToken(Product product, JwtCredential jwtCredential) {
TokenResponse tokenResponse = jsonMapper.fromJson(EntityUtils.toString(response.getEntity()), TokenResponse.class);
tokens.put(product, tokenResponse.getAccessToken());
} catch (Exception e) {
LOG.warn("Authenticating for " + product + " failed due to " + e);
LOG.error("Authenticating for " + product + " failed due to " + e);
throw new RuntimeException("Unable to authenticate", e);
}
return tokens.get(product);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private String retrieveToken(Product product, JwtCredential jwtCredential) {
TokenResponse tokenResponse = jsonMapper.fromJson(EntityUtils.toString(response.getEntity()), TokenResponse.class);
tokens.put(product, tokenResponse.getAccessToken());
} catch (Exception e) {
LOG.warn("Authenticating for " + product + " failed due to " + e);
LOG.error("Authenticating for " + product + " failed due to " + e);
throw new RuntimeException("Unable to authenticate", e);
}
return tokens.get(product);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ public Authentication build() {
private void retrieveToken(Product product, SimpleCredential simpleCredential) {
try {
HttpPost httpPost = new HttpPost(authUrl);
httpPost.addHeader("Content-Type", "application/json");
List<NameValuePair> params = new ArrayList<NameValuePair>();
List<NameValuePair> params = new ArrayList<>();
params.add(new BasicNameValuePair("username", simpleCredential.user));
params.add(new BasicNameValuePair("password", simpleCredential.password));
httpPost.setEntity(new UrlEncodedFormEntity(params));
Expand All @@ -58,14 +57,14 @@ private void retrieveToken(Product product, SimpleCredential simpleCredential) {
String cookie = response.getHeader("Set-Cookie").getValue();
tokens.put(product, cookie);
} catch (Exception e) {
LOG.warn("Authenticating for " + product + " failed due to " + e);
throw new RuntimeException("Unable to authenticate");
LOG.error("Authenticating for " + product + " failed due to " + e);
throw new RuntimeException("Unable to authenticate", e);
}
}


@Override
public Map.Entry<String, String> getTokenHeader(Product product) {
return new AbstractMap.SimpleEntry<>("Authorization", "Cookie " + tokens.get(product));
return new AbstractMap.SimpleEntry<>("Cookie", tokens.get(product));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public class OperateClientConfiguration {
@Bean
@ConditionalOnMissingBean
public CamundaOperateClient camundaOperateClient(OperateClientConfigurationProperties props) {
LOG.warn("Using a deprecated operate properties");
CamundaOperateClient client;
try {
client = new CamundaOperateClientBuilder()
Expand Down

0 comments on commit 4f0f91b

Please sign in to comment.