forked from auth0/java-jwt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPemWriter.java
More file actions
34 lines (27 loc) · 1.13 KB
/
PemWriter.java
File metadata and controls
34 lines (27 loc) · 1.13 KB
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
33
34
package com.auth0.jwt.pem;
import org.apache.commons.lang3.Validate;
import java.io.IOException;
import java.security.Key;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
/**
* Write operations for PEM files
*/
public class PemWriter {
public static void writePrivateKey(final RSAPrivateKey privateKey, final String description, final String filename) throws IOException {
Validate.notNull(privateKey);
Validate.notNull(filename);
writePemFile(privateKey, description, filename);
}
public static void writePublicKey(final RSAPublicKey publicKey, final String description, final String filename) throws IOException {
Validate.notNull(publicKey);
Validate.notNull(filename);
writePemFile(publicKey, description, filename);
}
public static void writePemFile(final Key key, final String description, final String filename) throws IOException {
Validate.notNull(key);
Validate.notNull(filename);
final PemFileWriter pemFileWriter = new PemFileWriter(key, description);
pemFileWriter.write(filename);
}
}