blob: 2f8a0ea585c0adfbff123c4ad52b460dc6aadabb (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.hosted.controller.persistence;
import com.yahoo.slime.Cursor;
import com.yahoo.slime.Slime;
import com.yahoo.vespa.hosted.controller.api.integration.certificates.EndpointCertificate;
import com.yahoo.vespa.hosted.controller.certificate.UnassignedCertificate;
/**
* @author mpolden
*/
public class UnassignedCertificateSerializer {
private static final String stateKey = "state";
private static final String certificateKey = "certificate";
public Slime toSlime(UnassignedCertificate unassignedCertificate) {
Slime slime = new Slime();
Cursor root = slime.setObject();
root.setString(stateKey, unassignedCertificate.state().name());
EndpointCertificateSerializer.toSlime(unassignedCertificate.certificate(), root.setObject(certificateKey));
return slime;
}
public UnassignedCertificate fromSlime(Slime slime) {
Cursor root = slime.get();
UnassignedCertificate.State state = UnassignedCertificate.State.valueOf(root.field(stateKey).asString());
EndpointCertificate certificate = EndpointCertificateSerializer.fromSlime(root.field(certificateKey));
return new UnassignedCertificate(certificate, state);
}
}
|