-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cb3996
commit 80723a1
Showing
20 changed files
with
286 additions
and
213 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
23 changes: 12 additions & 11 deletions
23
...g/wildfly/security/http/client/mechanism/bearer/ElytronHttpClientBearerAuthMechanism.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 |
---|---|---|
@@ -1,26 +1,27 @@ | ||
package org.wildfly.security.http.client.mechanism.bearer; | ||
|
||
import org.wildfly.security.http.client.utils.ElytronHttpClientConstants; | ||
import org.wildfly.security.http.client.utils.ElytronHttpClientCredentialUtils; | ||
import org.wildfly.security.http.client.utils.ElytronHttpClientRequestBuilder; | ||
|
||
import java.net.URI; | ||
import java.net.http.HttpRequest; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ElytronHttpClientBearerAuthMechanism { | ||
|
||
private static final String AUTHORIZATION = "Authorization"; | ||
private static ElytronHttpClientCredentialUtils elytronHttpClientCredentialProvider = new ElytronHttpClientCredentialUtils(); | ||
|
||
public static HttpRequest evaluateMechanism(URI uri) { | ||
String token = elytronHttpClientCredentialProvider.getToken(uri); | ||
HttpRequest request = HttpRequest | ||
.newBuilder() | ||
.uri(uri) | ||
.header(AUTHORIZATION, getBearerHeader(token)) | ||
.build(); | ||
public static HttpRequest evaluateMechanism(URI uri, String method, String body, Map<String, String> headers) { | ||
String token = ElytronHttpClientCredentialUtils.getToken(uri); | ||
if(headers == null){ | ||
headers = new HashMap<>(); | ||
} | ||
headers.put(ElytronHttpClientConstants.AUTHORIZATION, getBearerHeader(token)); | ||
HttpRequest request = ElytronHttpClientRequestBuilder.buildRequest(uri, method, body, headers); | ||
return request; | ||
} | ||
|
||
private static String getBearerHeader(String token){ | ||
private static String getBearerHeader(String token) { | ||
return "Bearer " + token; | ||
} | ||
} |
33 changes: 0 additions & 33 deletions
33
...a/org/wildfly/security/http/client/mechanism/cert/ElytronHttpClientCertAuthMechanism.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.