Package com.fathomdb.crypto

Examples of com.fathomdb.crypto.CryptoKey


    } 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,
View Full Code Here


      List<String> projectTokens = Lists.newArrayList(Splitter.on(':').limit(3).split(authKey));
      if (projectTokens.size() == 3) {
        final String projectKey = projectTokens.get(2);
        final int projectId = Integer.parseInt(projectTokens.get(1));

        final CryptoKey secret;
        try {
          secret = FathomdbCrypto.deserializeKey(Base64.decode(authSecret));
        } catch (Exception e) {
          log.debug("Error while deserializing user provided secret", e);
          return null;
View Full Code Here

    DbHelper db = new DbHelper();
    try {
      byte[] secretData;
      byte[] publicKeyHash = null;

      CryptoKey userSecretKey = FathomdbCrypto.generateKey();

      try {
        byte[] userSecret = FathomdbCrypto.serialize(userSecretKey);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

      ProjectEntity project;

      byte[] secretData;
      byte[] metadata;
      try {
        CryptoKey projectSecret = FathomdbCrypto.generateKey();
        byte[] plaintext = FathomdbCrypto.serialize(projectSecret);

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        SecretStore.Writer writer = new SecretStore.Writer(baos);
View Full Code Here

  // }

  public CryptoKey getSecret(byte[] secret) {
    SecretStore secretStore = new SecretStore(secret);

    CryptoKey secretKey = null;

    for (ProjectAuthorization project : OpsContext.get().getEncryptingProjects()) {
      secretKey = secretStore.getSecretFromProject(project);
      if (secretKey != null) {
        break;
View Full Code Here

    }

    // This isn't ideal, but it needs to be consistent
    byte[] salt = CryptoUtils.sha1(secret).toByteArray();

    CryptoKey authSecret = FathomdbCrypto.deriveKeyRaw(1000, salt, secret);
    secrets.put(this.currentTokenId, authSecret);
  }
View Full Code Here

    if (tokenSecret.length <= 2) {
      return null;
    }

    byte tokenId = tokenSecret[0];
    CryptoKey secret = secrets.get(tokenId);
    if (secret == null) {
      return null;
    }

    byte[] ciphertext = Arrays.copyOfRange(tokenSecret, 1, tokenSecret.length);
    byte[] plaintext = secret.decrypt(ciphertext);
    return FathomdbCrypto.deserializeKey(plaintext);
  }
View Full Code Here

  }

  @Override
  public byte[] buildToken(CryptoKey userSecret) {
    byte tokenId = currentTokenId;
    CryptoKey secret = secrets.get(tokenId);
    if (secret == null) {
      throw new IllegalStateException();
    }

    byte[] plaintext = FathomdbCrypto.serialize(userSecret);
    byte[] ciphertext = secret.encrypt(plaintext);

    byte[] header = new byte[1];
    header[0] = tokenId;
    return Bytes.concat(header, ciphertext);
  }
View Full Code Here

    if (tokenSecret.length < 1) {
      throw new IllegalArgumentException();
    }

    CryptoKey userSecret = authenticationSecrets.decryptSecretFromToken(tokenSecret);
    if (userSecret == null) {
      throw new AuthenticatorException("Authentication timed out");
    }

    UserEntity user;
View Full Code Here

    return new PlatformLayerHelpers(client, serviceProviderHelpers);
  }

  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;
  }
View Full Code Here

TOP

Related Classes of com.fathomdb.crypto.CryptoKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.