use of org.platformlayer.auth.DirectAuthenticationToken in project platformlayer by platformlayer.
the class OpsContextBuilder method buildDirectAuthenticator.
private DirectAuthenticator buildDirectAuthenticator(ProjectAuthorization project) {
String auth = DirectAuthenticationToken.encodeToken(project.getId(), project.getName());
CryptoKey secret = project.getProjectSecret();
DirectAuthenticationToken token = new DirectAuthenticationToken(auth, secret);
DirectAuthenticator directAuthenticator = new DirectAuthenticator(token);
return directAuthenticator;
}
use of org.platformlayer.auth.DirectAuthenticationToken in project platformlayer by platformlayer.
the class ActionScheduler method map.
private EndpointRecord map(PlatformLayerEndpointInfo in) {
EndpointRecord out = new EndpointRecord();
out.url = in.getPlatformlayerBaseUrl();
out.project = in.getProjectId().getKey();
List<String> trustKeys = in.getTrustKeys();
if (trustKeys != null && !trustKeys.isEmpty()) {
out.trustKeys = Joiner.on(",").join(trustKeys);
}
Authenticator authenticator = in.getAuthenticator();
if (authenticator instanceof DirectAuthenticator) {
DirectAuthenticator directAuthenticator = (DirectAuthenticator) authenticator;
DirectAuthenticationToken token = directAuthenticator.getAuthenticationToken();
out.secret = Secret.build(Hex.toHex(FathomdbCrypto.serialize(token.getSecret())));
out.token = token.getToken();
} else {
throw new UnsupportedOperationException();
}
return out;
}
use of org.platformlayer.auth.DirectAuthenticationToken in project platformlayer by platformlayer.
the class SchedulerImpl method rehydrateEndpoint.
private static PlatformLayerEndpointInfo rehydrateEndpoint(final EndpointRecord in) {
final Authenticator authenticator;
final String platformlayerBaseUrl = in.url;
final ProjectId projectId = new ProjectId(in.project);
final List<String> trustKeys;
if (Strings.isNullOrEmpty(in.trustKeys)) {
trustKeys = Collections.emptyList();
} else {
trustKeys = Lists.newArrayList(Splitter.on(",").split(in.trustKeys));
}
{
String token = in.token;
CryptoKey secret = FathomdbCrypto.deserializeKey(Hex.fromHex(in.secret.plaintext()));
DirectAuthenticationToken authenticationToken = new DirectAuthenticationToken(token, secret);
authenticator = new DirectAuthenticator(authenticationToken);
}
PlatformLayerEndpointInfo out = new PlatformLayerEndpointInfo(authenticator, platformlayerBaseUrl, projectId, trustKeys);
return out;
}
Aggregations