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


Java Identity.getName方法代码示例

本文整理汇总了Java中java.security.Identity.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Identity.getName方法的具体用法?Java Identity.getName怎么用?Java Identity.getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.security.Identity的用法示例。


在下文中一共展示了Identity.getName方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: addIdentity

import java.security.Identity; //导入方法依赖的package包/类
/**
 * @see java.security.IdentityScope#addIdentity(java.security.Identity)
 */
public synchronized void addIdentity(Identity identity) throws KeyManagementException {
    if (identity == null) {
        throw new NullPointerException("identity == null");
    }

    String name = identity.getName();
    if (names.containsKey(name)) {
        throw new KeyManagementException("name '" + name + "' is already used");
    }

    PublicKey key = identity.getPublicKey();
    if (key != null && keys.containsKey(key)) {
        throw new KeyManagementException("key '" + key + "' is already used");
    }

    names.put(name, identity);
    if (key != null) {
        keys.put(key, identity);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:SystemScope.java

示例2: addIdentity

import java.security.Identity; //导入方法依赖的package包/类
/**
 * @see java.security.IdentityScope#addIdentity(java.security.Identity)
 */
public synchronized void addIdentity(Identity identity)
        throws KeyManagementException {
    if (identity == null) {
        throw new NullPointerException(Messages.getString("security.92")); //$NON-NLS-1$
    }

    String name = identity.getName();
    if (names.containsKey(name)) {
        throw new KeyManagementException(Messages.getString("security.93", name)); //$NON-NLS-1$
    }

    PublicKey key = identity.getPublicKey();
    if (key != null && keys.containsKey(key)) {
        throw new KeyManagementException(Messages.getString("security.94", key)); //$NON-NLS-1$
    }

    names.put(name, identity);
    if (key != null) {
        keys.put(key, identity);
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:SystemScope.java

示例3: addIdentity

import java.security.Identity; //导入方法依赖的package包/类
/**
 * @see IdentityScope#addIdentity(Identity)
 */
public synchronized void addIdentity(Identity identity)
        throws KeyManagementException {
    if (identity == null) {
        throw new NullPointerException(Messages.getString("security.92")); //$NON-NLS-1$
    }

    String name = identity.getName();
    if (names.containsKey(name)) {
        throw new KeyManagementException(Messages.getString("security.93", name)); //$NON-NLS-1$
    }

    PublicKey key = identity.getPublicKey();
    if (key != null && keys.containsKey(key)) {
        throw new KeyManagementException(Messages.getString("security.94", key)); //$NON-NLS-1$
    }

    names.put(name, identity);
    if (key != null) {
        keys.put(key, identity);
    }
}
 
开发者ID:nextopio,项目名称:nextop-client,代码行数:25,代码来源:SystemScope.java

示例4: removeIdentity

import java.security.Identity; //导入方法依赖的package包/类
/**
 * @see java.security.IdentityScope#removeIdentity(java.security.Identity)
 */
public synchronized void removeIdentity(Identity identity)
        throws KeyManagementException {

    //Exception caught = null;
    if (identity == null) {
        throw new NullPointerException("identity == null");
    }

    String name = identity.getName();
    if (name == null) {
        throw new NullPointerException("name == null");
    }

    boolean contains = names.containsKey(name);
    names.remove(name);

    PublicKey key = identity.getPublicKey();

    if (key != null) {
        contains = contains || keys.containsKey(key);
        keys.remove(key);
    }

    if (!contains) {
        throw new KeyManagementException("identity not found");
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:31,代码来源:SystemScope.java

示例5: removeIdentity

import java.security.Identity; //导入方法依赖的package包/类
/**
 * @see java.security.IdentityScope#removeIdentity(java.security.Identity)
 */
public synchronized void removeIdentity(Identity identity)
        throws KeyManagementException {

    //Exception caught = null;
    if (identity == null) {
        throw new NullPointerException(Messages.getString("security.92")); //$NON-NLS-1$
    }

    String name = identity.getName();
    if (name == null) {
        throw new NullPointerException(Messages.getString("security.95")); //$NON-NLS-1$
    }

    boolean contains = names.containsKey(name);
    names.remove(name);

    PublicKey key = identity.getPublicKey();
    
    if (key != null) {
        contains = contains || keys.containsKey(key);
        keys.remove(key);
    }
    
    if (!contains) {
        throw new KeyManagementException(Messages.getString("security.96")); //$NON-NLS-1$
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:31,代码来源:SystemScope.java

示例6: removeIdentity

import java.security.Identity; //导入方法依赖的package包/类
/**
 * @see IdentityScope#removeIdentity(Identity)
 */
public synchronized void removeIdentity(Identity identity)
        throws KeyManagementException {

    //Exception caught = null;
    if (identity == null) {
        throw new NullPointerException(Messages.getString("security.92")); //$NON-NLS-1$
    }

    String name = identity.getName();
    if (name == null) {
        throw new NullPointerException(Messages.getString("security.95")); //$NON-NLS-1$
    }

    boolean contains = names.containsKey(name);
    names.remove(name);

    PublicKey key = identity.getPublicKey();
    
    if (key != null) {
        contains = contains || keys.containsKey(key);
        keys.remove(key);
    }
    
    if (!contains) {
        throw new KeyManagementException(Messages.getString("security.96")); //$NON-NLS-1$
    }
}
 
开发者ID:nextopio,项目名称:nextop-client,代码行数:31,代码来源:SystemScope.java

示例7: doImportIdentityDatabase

import java.security.Identity; //导入方法依赖的package包/类
private void doImportIdentityDatabase(InputStream inputstream)
throws Exception {
    java.security.cert.Certificate acertificate[] = null;
    boolean flag = false;
    IdentityDatabase identitydatabase = IdentityDatabase.fromStream(inputstream);
    Enumeration enumeration = identitydatabase.identities();
    do
    {
        if(!enumeration.hasMoreElements())
            break;
        Identity identity = (Identity)enumeration.nextElement();
        X509Certificate x509certificate = null;
        if((!(identity instanceof SystemSigner) || !((SystemSigner)identity).isTrusted()) && (!(identity instanceof SystemIdentity) || !((SystemIdentity)identity).isTrusted()))
            continue;
        if(keyStore.containsAlias(identity.getName())) {
            MessageFormat messageformat = new MessageFormat(rb.getString("Keystore entry for <id.getName()> already exists"));
            Object aobj[] = {
                identity.getName()
            };
            System.err.println(messageformat.format(((Object) (aobj))));
            continue;
        }
        Certificate acertificate1[] = identity.certificates();
        if(acertificate1 == null || acertificate1.length <= 0)
            continue;
        DerOutputStream deroutputstream = new DerOutputStream();
        acertificate1[0].encode(deroutputstream);
        byte abyte0[] = deroutputstream.toByteArray();
        ByteArrayInputStream bytearrayinputstream = new ByteArrayInputStream(abyte0);
        x509certificate = (X509Certificate)cf.generateCertificate(bytearrayinputstream);
        bytearrayinputstream.close();
        if(isSelfSigned(x509certificate)) {
            java.security.PublicKey publickey = x509certificate.getPublicKey();
            try {
                x509certificate.verify(publickey);
            } catch(Exception exception) {
                continue;
            }
        }
        if(identity instanceof SystemSigner) {
            MessageFormat messageformat1 = new MessageFormat(rb.getString("Creating keystore entry for <id.getName()> ..."));
            Object aobj1[] = {
                identity.getName()
            };
            System.err.println(messageformat1.format(((Object) (aobj1))));
            if(acertificate == null)
                acertificate = new java.security.cert.Certificate[1];
            acertificate[0] = x509certificate;
            PrivateKey privatekey = ((SystemSigner)identity).getPrivateKey();
            keyStore.setKeyEntry(identity.getName(), privatekey, storePass, acertificate);
        } else {
            keyStore.setCertificateEntry(identity.getName(), x509certificate);
        }
        kssave = true;
    } while(true);
    if(!kssave)
        System.err.println(rb.getString("No entries from identity database added"));
}
 
开发者ID:bernhardhuber,项目名称:netbeansplugins,代码行数:59,代码来源:KeyTool.java


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