private void analyseSingleKey(SecretKey secretKey, P11SlotRefreshResult refreshResult) { byte[] id = secretKey.getId().getByteArrayValue(); char[] label = secretKey.getLabel().getCharArrayValue(); if (id == null || label == null) { return; } P11ObjectIdentifier objectId = new P11ObjectIdentifier(id, new String(label)); IaikP11Identity identity = new IaikP11Identity(this, new P11IdentityId(slotId, objectId, null, null), secretKey); refreshResult.addIdentity(identity); }
new P11IdentityId(slotId, p11ObjId, null, null), key, maxSessions, random); LOG.info("added PKCS#11 secret key {}", p11ObjId); ret.addIdentity(identity); new P11IdentityId(slotId, p11ObjId, label, label), privateKey, publicKey, certs, maxSessions, random); LOG.info("added PKCS#11 key {}", p11ObjId);
private void analyseSingleKey(Session session, PrivateKey privKey, P11SlotRefreshResult refreshResult) throws P11TokenException, XiSecurityException { byte[] id = privKey.getId().getByteArrayValue(); char[] label = privKey.getLabel().getCharArrayValue(); if (id == null || label == null) { return; } String pubKeyLabel = null; PublicKey p11PublicKey = getPublicKeyObject(session, id, null); if (p11PublicKey != null) { pubKeyLabel = new String(p11PublicKey.getLabel().getCharArrayValue()); } String certLabel = null; java.security.PublicKey pubKey = null; X509Cert cert = refreshResult.getCertForId(id); if (cert != null) { certLabel = refreshResult.getCertLabelForId(id); pubKey = cert.getCert().getPublicKey(); } else if (p11PublicKey != null) { pubKey = generatePublicKey(p11PublicKey); } else { LOG.info("neither certificate nor public key for the key (" + hex(id) + " is available"); return; } P11ObjectIdentifier objectId = new P11ObjectIdentifier(id, new String(label)); X509Certificate[] certs = (cert == null) ? null : new X509Certificate[]{cert.getCert()}; IaikP11Identity identity = new IaikP11Identity(this, new P11IdentityId(slotId, objectId, pubKeyLabel, certLabel), privKey, pubKey, certs); refreshResult.addIdentity(identity); }
P11IdentityId identityId = new P11IdentityId(slotId, new P11ObjectIdentifier(id, keyLabel), pubKeyLabel, certLabel); try {
private P11Identity saveP11Entity(SecretKey key, P11NewObjectControl control) throws P11TokenException { byte[] id = control.getId(); if (id == null) { id = generateId(); } assertValidId(id); String label = control.getLabel(); savePkcs11SecretKey(id, label, key); P11IdentityId identityId = new P11IdentityId(slotId, new P11ObjectIdentifier(id, label), null, null); return new EmulatorP11Identity(this,identityId, key, maxSessions, random); }
P11IdentityId entityId = new P11IdentityId(slotId, objId, publicKeyLabel, certLabel); IaikP11Identity ret = new IaikP11Identity(this, entityId, privateKey2, jcePublicKey, certs); succ = true;
private IdentityId(ASN1Sequence seq) throws BadAsn1ObjectException { requireRange(seq, 2, 4); P11SlotIdentifier slotId = SlotIdentifier.getInstance(seq.getObjectAt(0)).getValue(); P11ObjectIdentifier keyId = ObjectIdentifier.getInstance(seq.getObjectAt(1)).getValue(); String publicKeyLabel = null; String certLabel = null; final int n = seq.size(); for (int i = 2; i < n; i++) { ASN1Encodable asn1 = seq.getObjectAt(i); if (asn1 instanceof ASN1TaggedObject) { ASN1TaggedObject tagAsn1 = (ASN1TaggedObject) asn1; int tag = tagAsn1.getTagNo(); if (tag == 1) { publicKeyLabel = DERUTF8String.getInstance(tagAsn1.getObject()).getString(); } else if (tag == 1) { certLabel = DERUTF8String.getInstance(tagAsn1.getObject()).getString(); } } } this.value = new P11IdentityId(slotId, keyId, publicKeyLabel, certLabel); }
private Asn1P11IdentityId(ASN1Sequence seq) throws BadAsn1ObjectException { Asn1Util.requireRange(seq, 2, 4); P11SlotIdentifier slotId = Asn1P11SlotIdentifier.getInstance(seq.getObjectAt(0)).getValue(); P11ObjectIdentifier keyId = Asn1P11ObjectIdentifier.getInstance(seq.getObjectAt(1)).getValue(); String publicKeyLabel = null; String certLabel = null; final int n = seq.size(); for (int i = 2; i < n; i++) { ASN1Encodable asn1 = seq.getObjectAt(i); if (asn1 instanceof ASN1TaggedObject) { ASN1TaggedObject tagAsn1 = (ASN1TaggedObject) asn1; int tag = tagAsn1.getTagNo(); if (tag == 1) { publicKeyLabel = DERUTF8String.getInstance(tagAsn1.getObject()).getString(); } else if (tag == 1) { certLabel = DERUTF8String.getInstance(tagAsn1.getObject()).getString(); } } } this.value = new P11IdentityId(slotId, keyId, publicKeyLabel, certLabel); }
P11IdentityId entityId = new P11IdentityId(slotId, keyId, (pubkeyid == null ? null : pubkeyid.getLabel()), refreshResult.getCertLabelForId(id));
P11IdentityId entityId = new P11IdentityId(slotId, objId, null, null);
P11IdentityId entityId = new P11IdentityId(slotId, objId, null, null);