Package org.waveprotocol.wave.crypto

Examples of org.waveprotocol.wave.crypto.SignerInfo


  }

  @Override
  public SignerInfo getSignerInfo(byte[] signerId) throws SignatureException {
    synchronized(certPathStore) {
      SignerInfo signerInfo = certPathStore.getSignerInfo(signerId);
      File signerFile = new File(signerIdToFileName(signerId));
      if (signerInfo == null) {
        if (signerFile.exists()) {
          FileInputStream file = null;
          try {
            file = new FileInputStream(signerFile);
            ProtocolSignerInfo data = ProtocolSignerInfo.newBuilder().mergeFrom(file).build();
            signerInfo = new SignerInfo(data);
          } catch (SignatureException e) {
            throw new SignatureException("Failed to parse signer info from file: "
                + signerFile.getAbsolutePath(), e);
          } catch (IOException e) {
            throw new SignatureException("Failed to parse signer info from file: "
View Full Code Here


  }

  @Override
  public void putSignerInfo(ProtocolSignerInfo protoSignerInfo) throws SignatureException {
    synchronized(certPathStore) {
      SignerInfo signerInfo = new SignerInfo(protoSignerInfo);
      File signerFile = new File(signerIdToFileName(signerInfo.getSignerId()));
      FileOutputStream file = null;
      try {
        file = new FileOutputStream(signerFile);
        file.write(protoSignerInfo.toByteArray());
        file.flush();
View Full Code Here

    LOG.info("Wave Server configured to host local domains: "
        + certificateManager.getLocalDomains());

    // Preemptively add our own signer info to the certificate manager
    SignerInfo signerInfo = certificateManager.getLocalSigner().getSignerInfo();
    if (signerInfo != null) {
      try {
        certificateManager.storeSignerInfo(signerInfo.toProtoBuf());
      } catch (SignatureException e) {
        LOG.severe("Failed to add our own signer info to the certificate store", e);
      }
    }
  }
View Full Code Here

    X509Certificate realCert = (X509Certificate) factory.generateCertificate(
        new ByteArrayInputStream(REAL_CERTIFICATE.getBytes()));
    X509Certificate startCom = (X509Certificate) factory.generateCertificate(
        new ByteArrayInputStream(STARTCOM_CERT.getBytes()));

    return new SignerInfo(HashAlgorithm.SHA256,
        ImmutableList.of(realCert, startCom), REAL_DOMAIN);
  }
View Full Code Here

   */
  public static SignerInfo getExampleSignerInfo() throws Exception {
    CertificateFactory factory = CertificateFactory.getInstance("X.509");
    X509Certificate exampleCert = (X509Certificate) factory.generateCertificate(
        new ByteArrayInputStream(EXAMPLE_CERTIFICATE.getBytes()));
    return new SignerInfo(HashAlgorithm.SHA256,
        ImmutableList.of(exampleCert), EXAMPLE_DOMAIN);
  }
View Full Code Here

    DBObject query = getDBObjectForSignerId(signerId);
    DBCollection signerInfoCollection = getSignerInfoCollection();
    DBObject signerInfoDBObject = signerInfoCollection.findOne(query);

    // Sub-class contract specifies return null when not found
    SignerInfo signerInfo = null;

    if (signerInfoDBObject != null) {
      byte[] protobuff = (byte[]) signerInfoDBObject.get("protoBuff");
      try {
        signerInfo = new SignerInfo(ProtocolSignerInfo.parseFrom(protobuff));
      } catch (InvalidProtocolBufferException e) {
        LOG.log(Level.SEVERE, "Couldn't parse the protobuff stored in MongoDB: " + protobuff, e);
      } catch (SignatureException e) {
        LOG.log(Level.SEVERE, "Couldn't parse the certificate chain or domain properly", e);
      }
View Full Code Here

    return signerInfo;
  }

  @Override
  public void putSignerInfo(ProtocolSignerInfo protocolSignerInfo) throws SignatureException {
    SignerInfo signerInfo = new SignerInfo(protocolSignerInfo);
    byte[] signerId = signerInfo.getSignerId();

    // Not using a modifier here because rebuilding the object is not a lot of
    // work. Doing implicit upsert by using save with a DBOBject that has an _id
    // set.
    DBObject signerInfoDBObject = getDBObjectForSignerId(signerId);
View Full Code Here

  }

  @Override
  public synchronized void storeSignerInfo(ProtocolSignerInfo signerInfo)
      throws SignatureException {
    verifier.verifySignerInfo(new SignerInfo(signerInfo));
    certPathStore.putSignerInfo(signerInfo);
  }
View Full Code Here

    certPathStore.putSignerInfo(signerInfo);
  }

  @Override
  public synchronized ProtocolSignerInfo retrieveSignerInfo(ByteString signerId) {
    SignerInfo signerInfo;
    try {
      signerInfo = certPathStore.getSignerInfo(signerId.toByteArray());
      // null is acceptable for retrieveSignerInfo.  The user of the certificate manager should call
      // prefetchDeltaSignerInfo for the mechanism to actually populate the certificate manager.
      return signerInfo == null ? null : signerInfo.toProtoBuf();
    } catch (SignatureException e) {
      /*
       * TODO: This may result in the server endlessly requesting the signer info from the
       * remote server, a more graceful failure needs to be implemented.
       */
 
View Full Code Here

  }

  @Override
  public SignerInfo getSignerInfo(byte[] signerId) throws SignatureException {
    synchronized(certPathStore) {
      SignerInfo signerInfo = certPathStore.getSignerInfo(signerId);
      File signerFile = new File(signerIdToFileName(signerId));
      if (signerInfo == null) {
        if (signerFile.exists()) {
          FileInputStream file = null;
          try {
            file = new FileInputStream(signerFile);
            ProtocolSignerInfo data = ProtocolSignerInfo.newBuilder().mergeFrom(file).build();
            signerInfo = new SignerInfo(data);
          } catch (SignatureException e) {
            throw new SignatureException("Failed to parse signer info from file: "
                + signerFile.getAbsolutePath(), e);
          } catch (IOException e) {
            throw new SignatureException("Failed to parse signer info from file: "
View Full Code Here

TOP

Related Classes of org.waveprotocol.wave.crypto.SignerInfo

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.