BrightSide Workbench Full Report + Source Code
Encrypted.java
Go to the documentation of this file.
1 /*
2  * TurrĂ³ i Cutiller Foundation. License notice.
3  * Copyright (C) 2022 Lluis TurrĂ³ Cutiller <http://www.turro.org/>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Affero General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Affero General Public License for more details.
14  *
15  * You should have received a copy of the GNU Affero General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 package org.turro.push.service;
19 
20 import java.security.PublicKey;
21 
26 public class Encrypted {
27 
28  private final PublicKey publicKey;
29  private final byte[] salt;
30  private final byte[] ciphertext;
31 
32  public Encrypted(final PublicKey publicKey, final byte[] salt, final byte[] ciphertext) {
33  this.publicKey = publicKey;
34  this.salt = salt;
35  this.ciphertext = ciphertext;
36  }
37 
38  public PublicKey getPublicKey() {
39  return publicKey;
40  }
41 
42  public byte[] getSalt() {
43  return salt;
44  }
45 
46  public byte[] getCiphertext() {
47  return ciphertext;
48  }
49 
50  public static class Builder {
51 
52  private PublicKey publicKey;
53  private byte[] salt;
54  private byte[] ciphertext;
55 
56  public Builder withPublicKey(PublicKey publicKey) {
57  this.publicKey = publicKey;
58 
59  return this;
60  }
61 
62  public Builder withSalt(byte[] salt) {
63  this.salt = salt;
64 
65  return this;
66  }
67 
68  public Builder withCiphertext(byte[] ciphertext) {
69  this.ciphertext = ciphertext;
70 
71  return this;
72  }
73 
74  public Encrypted build() {
75  return new Encrypted(publicKey, salt, ciphertext);
76  }
77  }
78 
79 }
Encrypted(final PublicKey publicKey, final byte[] salt, final byte[] ciphertext)
Definition: Encrypted.java:32