Skip to content

Commit 53f4ef5

Browse files
committed
add EncryptableSubscription
1 parent 7617f8d commit 53f4ef5

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.microsoft.graph.core.models;
2+
3+
import java.security.cert.CertificateEncodingException;
4+
import java.security.cert.X509Certificate;
5+
import java.util.Base64;
6+
import java.util.Objects;
7+
8+
import jakarta.annotation.Nonnull;
9+
10+
/**
11+
* EncryptableSubscription interface
12+
*/
13+
public interface EncryptableSubscription {
14+
15+
/**
16+
* Sets the encryption certificate
17+
* @param certificate Base-64 encoded certificate to be used by Microsoft Graph to encrypt resource data
18+
*/
19+
public void setEncryptionCertificate(String certificate);
20+
21+
/**
22+
* Returns the encryption certificate
23+
* @return encryption certificate
24+
*/
25+
public String getEncryptionCertificate();
26+
27+
/**
28+
* Converts an X.509 Certificate object to Base-64 string and adds to the encryptableSubscription provided
29+
* @param subscription encryptable subscription
30+
* @param certificate X.509 Certificate
31+
* @throws CertificateEncodingException
32+
*/
33+
public static void addPublicEncryptionCertificate(@Nonnull final EncryptableSubscription subscription, @Nonnull final X509Certificate certificate) throws CertificateEncodingException {
34+
Objects.requireNonNull(subscription);
35+
Objects.requireNonNull(certificate);
36+
subscription.setEncryptionCertificate(
37+
Base64.getEncoder().encodeToString(certificate.getEncoded())
38+
);
39+
}
40+
41+
}

0 commit comments

Comments
 (0)