You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
944 B
35 lines
944 B
package com.fr.plugin.utils; |
|
|
|
import com.fr.base.Base64; |
|
|
|
import java.io.ByteArrayInputStream; |
|
import java.io.InputStream; |
|
import java.security.PublicKey; |
|
import java.security.cert.CertificateException; |
|
import java.security.cert.CertificateFactory; |
|
|
|
public class SertUtils { |
|
final static String str = "xxxxB64"; |
|
static byte[] bs; |
|
static PublicKey statePublicKey = null; |
|
|
|
static { |
|
bs = Base64.decode(str); |
|
} |
|
|
|
public static PublicKey getSert() { |
|
if (statePublicKey != null) { |
|
return statePublicKey; |
|
} |
|
CertificateFactory cf; |
|
InputStream in2; |
|
java.security.cert.Certificate c2 = null; |
|
try { |
|
cf = CertificateFactory.getInstance("X.509"); |
|
c2 = cf.generateCertificate(new ByteArrayInputStream(bs)); |
|
} catch (CertificateException e) { |
|
} |
|
statePublicKey = c2.getPublicKey(); |
|
return statePublicKey; |
|
} |
|
}
|
|
|