@Test public void testLoadValidRawPublicKey() throws IOException, GeneralSecurityException { byte[] authSecret = Random.randBytes(16); byte[] ecPublicKeyBytes = TestUtils.getBytes("ec_public_key.dat"); byte[] rawPublicKey = WrappedWebPushPublicKey.newBuilder() .setAuthSecret(ByteString.copyFrom(authSecret)) .setKeyBytes(ByteString.copyFrom(ecPublicKeyBytes)) .build().toByteArray(); encrypterManager.rawLoadPublicKey(rawPublicKey); }
@Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedWebPushPublicKey wrappedWebPushPublicKey; try { wrappedWebPushPublicKey = WrappedWebPushPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } return new WebPushHybridEncrypt.Builder() .withAuthSecret(wrappedWebPushPublicKey.getAuthSecret().toByteArray()) .withRecipientPublicKey(wrappedWebPushPublicKey.getKeyBytes().toByteArray()) .build(); }
WebPushEncrypterManager extends EncrypterManager { @Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedWebPushPublicKey wrappedWebPushPublicKey; try { wrappedWebPushPublicKey = WrappedWebPushPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } return new WebPushHybridEncrypt.Builder() .withAuthSecret(wrappedWebPushPublicKey.getAuthSecret().toByteArray()) .withRecipientPublicKey(wrappedWebPushPublicKey.getKeyBytes().toByteArray()) .build(); } }
WebPushEncrypterManager extends EncrypterManager { @Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedWebPushPublicKey wrappedWebPushPublicKey; try { wrappedWebPushPublicKey = WrappedWebPushPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } return new WebPushHybridEncrypt.Builder() .withAuthSecret(wrappedWebPushPublicKey.getAuthSecret().toByteArray()) .withRecipientPublicKey(wrappedWebPushPublicKey.getKeyBytes().toByteArray()) .build(); }  }
WebPushEncrypterManager extends EncrypterManager { @Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedWebPushPublicKey wrappedWebPushPublicKey; try { wrappedWebPushPublicKey = WrappedWebPushPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } return new WebPushHybridEncrypt.Builder() .withAuthSecret(wrappedWebPushPublicKey.getAuthSecret().toByteArray()) .withRecipientPublicKey(wrappedWebPushPublicKey.getKeyBytes().toByteArray()) .build(); }   }
WebPushEncrypterManager extends EncrypterManager { @Override HybridEncrypt rawLoadPublicKey(byte[] publicKey) throws GeneralSecurityException { WrappedWebPushPublicKey wrappedWebPushPublicKey; try { wrappedWebPushPublicKey = WrappedWebPushPublicKey.parseFrom(publicKey); } catch (InvalidProtocolBufferException e) { throw new GeneralSecurityException("unable to parse public key", e); } return new WebPushHybridEncrypt.Builder() .withAuthSecret(wrappedWebPushPublicKey.getAuthSecret().toByteArray()) .withRecipientPublicKey(wrappedWebPushPublicKey.getKeyBytes().toByteArray()) .build(); }    }