Search in sources :

Example 1 with DirectAuthenticator

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

the class OpsContextBuilder method buildClient.

private TypedPlatformLayerClient buildClient(ProjectAuthorization project) throws OpsException {
    ProjectId projectId = new ProjectId(project.getName());
    DirectAuthenticator directAuthenticator = buildDirectAuthenticator(project);
    // TODO: Introduce a direct client for "loopback" (normal) calls?
    String platformLayerUrl = OpsSystem.getPlatformLayerUrlBase();
    List<String> trustKeys = opsSystem.getServerTrustKeys();
    PlatformLayerClient client;
    // client = HttpPlatformLayerClient.build(httpStrategy, platformLayerUrl,
    // directAuthenticator, projectId, trustKeys);
    DirectAuthentication auth = new DirectAuthentication(project);
    TypedItemMapper mapper = null;
    client = new DirectPlatformLayerClient(mapper, opsSystem, projectId, auth);
    return new PlatformLayerHelpers(client, serviceProviderHelpers);
}
Also used : DirectPlatformLayerClient(org.platformlayer.ops.DirectPlatformLayerClient) FederatedPlatformLayerClient(org.platformlayer.federation.FederatedPlatformLayerClient) PlatformLayerClient(org.platformlayer.PlatformLayerClient) TypedPlatformLayerClient(org.platformlayer.TypedPlatformLayerClient) PlatformLayerHelpers(org.platformlayer.ops.machines.PlatformLayerHelpers) DirectPlatformLayerClient(org.platformlayer.ops.DirectPlatformLayerClient) ProjectId(org.platformlayer.ids.ProjectId) DirectAuthenticator(org.platformlayer.auth.DirectAuthenticator) PlatformLayerTypedItemMapper(org.platformlayer.ops.machines.PlatformLayerTypedItemMapper) TypedItemMapper(org.platformlayer.TypedItemMapper) DirectAuthentication(org.platformlayer.ops.DirectAuthentication)

Example 2 with DirectAuthenticator

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

Example 3 with DirectAuthenticator

use of org.platformlayer.auth.DirectAuthenticator 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 4 with DirectAuthenticator

use of org.platformlayer.auth.DirectAuthenticator 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

DirectAuthenticator (org.platformlayer.auth.DirectAuthenticator)4 DirectAuthenticationToken (org.platformlayer.auth.DirectAuthenticationToken)3 CryptoKey (com.fathomdb.crypto.CryptoKey)2 Authenticator (org.platformlayer.auth.Authenticator)2 ProjectId (org.platformlayer.ids.ProjectId)2 PlatformLayerClient (org.platformlayer.PlatformLayerClient)1 PlatformLayerEndpointInfo (org.platformlayer.PlatformLayerEndpointInfo)1 TypedItemMapper (org.platformlayer.TypedItemMapper)1 TypedPlatformLayerClient (org.platformlayer.TypedPlatformLayerClient)1 FederatedPlatformLayerClient (org.platformlayer.federation.FederatedPlatformLayerClient)1 DirectAuthentication (org.platformlayer.ops.DirectAuthentication)1 DirectPlatformLayerClient (org.platformlayer.ops.DirectPlatformLayerClient)1 PlatformLayerHelpers (org.platformlayer.ops.machines.PlatformLayerHelpers)1 PlatformLayerTypedItemMapper (org.platformlayer.ops.machines.PlatformLayerTypedItemMapper)1