当前位置: 首页>>代码示例>>Java>>正文


Java Crypto.convertToPEMFormat方法代码示例

本文整理汇总了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);
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:9,代码来源:CryptoTest.java

示例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));
    }
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:30,代码来源:ZMSImpl.java

示例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);
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:9,代码来源:SelfCertSigner.java

示例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");
        }
    }
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:53,代码来源:ZMSImpl.java

示例5: getCACertificate

import com.yahoo.athenz.auth.util.Crypto; //导入方法依赖的package包/类
@Override
public String getCACertificate() {
    return Crypto.convertToPEMFormat(caCertificate);
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:5,代码来源:SelfCertSigner.java


注:本文中的com.yahoo.athenz.auth.util.Crypto.convertToPEMFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。