mirror of
https://github.com/bisq-network/bisq.git
synced 2024-11-19 09:52:23 +01:00
Polish BisqCallCredentials style
See https://github.com/bisq-network/style/issues/12
This commit is contained in:
parent
bc88080df1
commit
24c245c2ea
@ -24,32 +24,27 @@ public class BisqCallCredentials extends CallCredentials {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyRequestMetadata(
|
||||
RequestInfo requestInfo,
|
||||
Executor appExecutor,
|
||||
MetadataApplier metadataApplier) {
|
||||
|
||||
public void applyRequestMetadata(RequestInfo requestInfo, Executor appExecutor, MetadataApplier metadataApplier) {
|
||||
appExecutor.execute(() -> {
|
||||
try {
|
||||
Metadata headers = new Metadata();
|
||||
Key<String> creds = Key.of("bisqd-creds", ASCII_STRING_MARSHALLER);
|
||||
headers.put(creds, encodeCredentials());
|
||||
metadataApplier.apply(headers);
|
||||
} catch (Throwable e) {
|
||||
metadataApplier.fail(UNAUTHENTICATED.withCause(e));
|
||||
} catch (Throwable ex) {
|
||||
metadataApplier.fail(UNAUTHENTICATED.withCause(ex));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String encodeCredentials() {
|
||||
if (!credentials.containsKey(RPC_USER) || !credentials.containsKey(RPC_PASSWORD))
|
||||
throw new ConfigException("Cannot call rpc service without username:password credentials");
|
||||
|
||||
return credentials.get(RPC_USER) + ":" + credentials.get(RPC_PASSWORD);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void thisUsesUnstableApi() {
|
||||
}
|
||||
|
||||
private String encodeCredentials() {
|
||||
if (!credentials.containsKey(RPC_USER) || !credentials.containsKey(RPC_PASSWORD)) {
|
||||
throw new ConfigException("Cannot call rpc service without username:password credentials");
|
||||
} else {
|
||||
return credentials.get(RPC_USER) + ":" + credentials.get(RPC_PASSWORD);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user