-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/release/1.0.2.0'
* origin/release/1.0.2.0: release 1.0.2.0 update dependencies add proxy password with *** to debug log if set adds comment why preemptive authorization header is needed rename method to encodeCredentials use oauth2 instead of only oauth change log level for coinfuguration when using proxy to debug add logging for proxy rename buffer to include length fix typo check for proxy variables before setting authentication remove indirection via constants, more precise comments for preemptive authoization headers enable proxy auth for java.net.HttpClient replace strings with constants use TLS context, fox typo log configuration of oauth provider, throw exception if token could not be retrieved client credentials workflow implementation publish artefact on release remove not needed whitespace start new development cylve and fix mvn action for publish
- Loading branch information
Showing
10 changed files
with
418 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...izininformatik_initiative/processes/common/fhir/client/interceptor/OAuth2Interceptor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.medizininformatik_initiative.processes.common.fhir.client.interceptor; | ||
|
||
import java.util.Objects; | ||
|
||
import org.springframework.beans.factory.InitializingBean; | ||
|
||
import ca.uhn.fhir.rest.api.Constants; | ||
import ca.uhn.fhir.rest.client.api.IClientInterceptor; | ||
import ca.uhn.fhir.rest.client.api.IHttpRequest; | ||
import ca.uhn.fhir.rest.client.api.IHttpResponse; | ||
import de.medizininformatik_initiative.processes.common.fhir.client.token.TokenProvider; | ||
|
||
public class OAuth2Interceptor implements IClientInterceptor, InitializingBean | ||
{ | ||
private final TokenProvider tokenProvider; | ||
|
||
public OAuth2Interceptor(TokenProvider tokenProvider) | ||
{ | ||
this.tokenProvider = tokenProvider; | ||
} | ||
|
||
@Override | ||
public void afterPropertiesSet() | ||
{ | ||
Objects.requireNonNull(tokenProvider, "tokenProvider"); | ||
} | ||
|
||
@Override | ||
public void interceptRequest(IHttpRequest theRequest) | ||
{ | ||
theRequest.addHeader(Constants.HEADER_AUTHORIZATION, | ||
Constants.HEADER_AUTHORIZATION_VALPREFIX_BEARER + tokenProvider.getToken()); | ||
} | ||
|
||
@Override | ||
public void interceptResponse(IHttpResponse theResponse) | ||
{ | ||
// do not intercept response | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
.../java/de/medizininformatik_initiative/processes/common/fhir/client/token/AccessToken.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package de.medizininformatik_initiative.processes.common.fhir.client.token; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class AccessToken | ||
{ | ||
private static final int BUFFER_10 = 10; | ||
|
||
private final String token; | ||
|
||
private final LocalDateTime expiresAt; | ||
|
||
@JsonCreator | ||
public AccessToken(@JsonProperty("access_token") String token, @JsonProperty("expires_in") int expiresIn) | ||
{ | ||
this.token = token; | ||
this.expiresAt = LocalDateTime.now().plusSeconds(expiresIn); | ||
} | ||
|
||
public String get() | ||
{ | ||
return token; | ||
} | ||
|
||
public boolean isExpired() | ||
{ | ||
return LocalDateTime.now().plusSeconds(BUFFER_10).isAfter(expiresAt); | ||
} | ||
} |
Oops, something went wrong.