blob: 8bffc67145fd0fea9d22cc03b266e7e4405db012 (
plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package org.bouncycastle.cert.jcajce;
import java.security.cert.X509Certificate;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x500.X500NameStyle;
import org.bouncycastle.jce.PrincipalUtil;
public class JcaX500NameUtil
{
public static X500Name getIssuer(X509Certificate certificate)
{
try
{
return X500Name.getInstance(PrincipalUtil.getIssuerX509Principal(certificate).getEncoded());
}
catch (Exception e)
{
throw new IllegalStateException(e.toString());
}
}
public static X500Name getSubject(X509Certificate certificate)
{
try
{
return X500Name.getInstance(PrincipalUtil.getSubjectX509Principal(certificate).getEncoded());
}
catch (Exception e)
{
throw new IllegalStateException(e.toString());
}
}
public static X500Name getIssuer(X500NameStyle style, X509Certificate certificate)
{
try
{
return X500Name.getInstance(style, PrincipalUtil.getIssuerX509Principal(certificate).getEncoded());
}
catch (Exception e)
{
throw new IllegalStateException(e.toString());
}
}
public static X500Name getSubject(X500NameStyle style, X509Certificate certificate)
{
try
{
return X500Name.getInstance(style, PrincipalUtil.getSubjectX509Principal(certificate).getEncoded());
}
catch (Exception e)
{
throw new IllegalStateException(e.toString());
}
}
}
|