本文整理汇总了Java中com.yahoo.athenz.auth.util.Crypto.convertToPEMFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Crypto.convertToPEMFormat方法的具体用法?Java Crypto.convertToPEMFormat怎么用?Java Crypto.convertToPEMFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.yahoo.athenz.auth.util.Crypto
的用法示例。
在下文中一共展示了Crypto.convertToPEMFormat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testX509CertificateToPem
import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@Test
public void testX509CertificateToPem() {
X509Certificate cert = Crypto.loadX509Certificate(ecPublicX509Cert);
String pem = Crypto.convertToPEMFormat(cert);
assertNotNull(pem);
assertTrue(pem.contains("BEGIN CERTIFICATE"), pem);
assertTrue(pem.contains("END CERTIFICATE"), pem);
}
示例2: loadServerPublicKeys
import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
void loadServerPublicKeys() {
// initialize our public key map
serverPublicKeyMap = new ConcurrentHashMap<String, String>();
// retrieve our zms service identity object
ServiceIdentity identity = dbService.getServiceIdentity(SYS_AUTH, ZMSConsts.ZMS_SERVICE);
if (identity != null) {
// process all the public keys and add them to the map
List<PublicKeyEntry> publicKeyList = identity.getPublicKeys();
if (publicKeyList != null) {
for (PublicKeyEntry entry : publicKeyList) {
serverPublicKeyMap.put(entry.getId(), entry.getKey());
}
}
}
// this should never happen but just in case we'll just
// use the public key we retrieved ourselves to the map
if (serverPublicKeyMap.isEmpty() && privateKey != null) {
final String publicKey = Crypto.convertToPEMFormat(Crypto.extractPublicKey(privateKey));
serverPublicKeyMap.put(privateKeyId, Crypto.ybase64EncodeString(publicKey));
}
}
示例3: generateX509Certificate
import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@Override
public String generateX509Certificate(String csr, String keyUsage, int expiryTime) {
int certExpiryTime = expiryTime == 0 ? certValidityTime : expiryTime;
PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(csr);
X509Certificate cert = Crypto.generateX509Certificate(certReq, caPrivateKey,
caCertificate, certExpiryTime, false);
return Crypto.convertToPEMFormat(cert);
}
示例4: initObjectStore
import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
void initObjectStore() {
final String caller = "initstore";
List<String> domains = dbService.listDomains(null, 0);
if (domains.size() > 0) {
return;
}
String adminUserList = System.getProperty(ZMSConsts.ZMS_PROP_DOMAIN_ADMIN);
if (adminUserList == null) {
throw ZMSUtils.internalServerError("init: No ZMS admin user specified", caller);
}
String[] users = adminUserList.split(",");
ArrayList<String> adminUsers = new ArrayList<String>();
for (int i = 0; i < users.length; i++) {
String adminUser = users[i].trim();
if (!adminUser.startsWith(userDomainPrefix)) {
throw ZMSUtils.internalServerError("init: Bad domain user name(" + adminUser +
"), must begin with (" + userDomainPrefix + ")", caller);
}
adminUsers.add(adminUser);
}
createTopLevelDomain(null, userDomain, "The reserved domain for user authentication",
null, null, adminUsers, null, 0, null, null, null);
if (!ZMSConsts.USER_DOMAIN.equals(userDomain)) {
createTopLevelDomain(null, ZMSConsts.USER_DOMAIN, "The reserved domain for user authentication",
null, null, adminUsers, null, 0, null, null, null);
}
if (!homeDomain.equals(userDomain)) {
createTopLevelDomain(null, homeDomain, "The reserved domain for personal user domains",
null, null, adminUsers, null, 0, null, null, null);
}
createTopLevelDomain(null, "sys", "The reserved domain for system related information",
null, null, adminUsers, null, 0, null, null, null);
createSubDomain(null, "sys", "auth", "The Athenz domain", null, null, adminUsers,
null, 0, null, null, null, caller);
if (privateKey != null) {
List<PublicKeyEntry> pubKeys = new ArrayList<>();
final String publicKey = Crypto.convertToPEMFormat(Crypto.extractPublicKey(privateKey));
pubKeys.add(new PublicKeyEntry().setId(privateKeyId).setKey(Crypto.ybase64EncodeString(publicKey)));
ServiceIdentity id = new ServiceIdentity().setName("sys.auth.zms").setPublicKeys(pubKeys);
dbService.executePutServiceIdentity(null, SYS_AUTH, ZMSConsts.ZMS_SERVICE, id, null, caller);
} else {
if (LOG.isWarnEnabled()) {
LOG.warn("init: Warning: no public key, cannot register sys.auth.zms identity");
}
}
}
示例5: getCACertificate
import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@Override
public String getCACertificate() {
return Crypto.convertToPEMFormat(caCertificate);
}