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
|
@Override
|
||||||
public void applyRequestMetadata(
|
public void applyRequestMetadata(RequestInfo requestInfo, Executor appExecutor, MetadataApplier metadataApplier) {
|
||||||
RequestInfo requestInfo,
|
|
||||||
Executor appExecutor,
|
|
||||||
MetadataApplier metadataApplier) {
|
|
||||||
|
|
||||||
appExecutor.execute(() -> {
|
appExecutor.execute(() -> {
|
||||||
try {
|
try {
|
||||||
Metadata headers = new Metadata();
|
Metadata headers = new Metadata();
|
||||||
Key<String> creds = Key.of("bisqd-creds", ASCII_STRING_MARSHALLER);
|
Key<String> creds = Key.of("bisqd-creds", ASCII_STRING_MARSHALLER);
|
||||||
headers.put(creds, encodeCredentials());
|
headers.put(creds, encodeCredentials());
|
||||||
metadataApplier.apply(headers);
|
metadataApplier.apply(headers);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable ex) {
|
||||||
metadataApplier.fail(UNAUTHENTICATED.withCause(e));
|
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
|
@Override
|
||||||
public void thisUsesUnstableApi() {
|
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