本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}
示例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");
}
}
示例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$
}
}
示例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$
}
}
示例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"));
}