Search in sources :

Example 1 with Authenticator

use of org.platformlayer.auth.Authenticator 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;
}
Also used : DirectAuthenticationToken(org.platformlayer.auth.DirectAuthenticationToken) DirectAuthenticator(org.platformlayer.auth.DirectAuthenticator) Authenticator(org.platformlayer.auth.Authenticator) DirectAuthenticator(org.platformlayer.auth.DirectAuthenticator)

Example 2 with Authenticator

use of org.platformlayer.auth.Authenticator in project platformlayer by platformlayer.

the class HttpPlatformLayerClient method buildUsingConfiguration.

public static HttpPlatformLayerClient buildUsingConfiguration(HttpStrategy httpStrategy, PlatformLayerConnectionConfiguration config) {
    String project = config.tenant;
    String server = config.authenticationEndpoint;
    String username = config.username;
    String secret = config.secret;
    List<String> authTrustKeys = config.authTrustKeys;
    Authenticator authenticator = new PlatformlayerAuthenticator(httpStrategy, username, secret, server, authTrustKeys);
    ProjectId projectId = new ProjectId(project);
    return build(httpStrategy, config.platformlayerEndpoint, authenticator, projectId, config.platformlayerTrustKeys);
}
Also used : ProjectId(org.platformlayer.ids.ProjectId) PlatformlayerAuthenticator(org.platformlayer.auth.PlatformlayerAuthenticator) Authenticator(org.platformlayer.auth.Authenticator) PlatformlayerAuthenticator(org.platformlayer.auth.PlatformlayerAuthenticator)

Example 3 with Authenticator

use of org.platformlayer.auth.Authenticator 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;
}
Also used : PlatformLayerEndpointInfo(org.platformlayer.PlatformLayerEndpointInfo) DirectAuthenticationToken(org.platformlayer.auth.DirectAuthenticationToken) ProjectId(org.platformlayer.ids.ProjectId) CryptoKey(com.fathomdb.crypto.CryptoKey) DirectAuthenticator(org.platformlayer.auth.DirectAuthenticator) Authenticator(org.platformlayer.auth.Authenticator) DirectAuthenticator(org.platformlayer.auth.DirectAuthenticator)

Aggregations

Authenticator (org.platformlayer.auth.Authenticator)3 DirectAuthenticationToken (org.platformlayer.auth.DirectAuthenticationToken)2 DirectAuthenticator (org.platformlayer.auth.DirectAuthenticator)2 ProjectId (org.platformlayer.ids.ProjectId)2 CryptoKey (com.fathomdb.crypto.CryptoKey)1 PlatformLayerEndpointInfo (org.platformlayer.PlatformLayerEndpointInfo)1 PlatformlayerAuthenticator (org.platformlayer.auth.PlatformlayerAuthenticator)1