private ArrayList<AliasInfo> mapPrivateKeys(ArrayList<byte[]> pkeyIDs,HashMap<String,HashSet<AliasInfo>> certMap) throws PKCS11Exception, CertificateException {
  aliasMap=new HashMap<String,AliasInfo>();
  ArrayList<AliasInfo> matchedCerts=new ArrayList<AliasInfo>();
  for (  byte[] pkeyID : pkeyIDs) {
    boolean foundMatch=false;
    Set<String> certLabels=certMap.keySet();
    for (    String certLabel : certLabels) {
      HashSet<AliasInfo> infoSet=certMap.get(certLabel);
      for (      AliasInfo aliasInfo : infoSet) {
        if (Arrays.equals(pkeyID,aliasInfo.id)) {
          if (infoSet.size() == 1) {
            aliasInfo.matched=true;
            aliasMap.put(certLabel,aliasInfo);
          }
 else {
            aliasInfo.matched=true;
            aliasMap.put(getID(certLabel,aliasInfo.cert),aliasInfo);
          }
          matchedCerts.add(aliasInfo);
          foundMatch=true;
          break;
        }
      }
      if (foundMatch) {
        break;
      }
    }
    if (!foundMatch) {
      if (debug != null) {
        debug.println("did not find match for private key with CKA_ID [" + getID(pkeyID) + "] (ignoring entry)");
      }
    }
  }
  return matchedCerts;
}

private ArrayList < AliasInfo > mapPrivateKeys ( ArrayList < byte [ ] > pkeyIDs , HashMap < String , HashSet < AliasInfo > > certMap ) throws PKCS11Exception , CertificateException { aliasMap = new HashMap < String , AliasInfo > ( ) ; ArrayList < AliasInfo > matchedCerts = new ArrayList < AliasInfo > ( ) ; for ( byte [ ] pkeyID : pkeyIDs ) { boolean foundMatch = false ; Set < String > certLabels = certMap . keySet ( ) ; for ( String certLabel : certLabels ) { HashSet < AliasInfo > infoSet = certMap . get ( certLabel ) ; for ( AliasInfo aliasInfo : infoSet ) { if ( Arrays . equals ( pkeyID , aliasInfo . id ) ) { if ( infoSet . size ( ) == 1 ) { aliasInfo . matched = true ; aliasMap . put ( certLabel , aliasInfo ) ; } else { aliasInfo . matched = true ; aliasMap . put ( getID ( certLabel , aliasInfo . cert ) , aliasInfo ) ; } matchedCerts . add ( aliasInfo ) ; foundMatch = true ; break ; } } if ( foundMatch ) { break ; } } if ( ! foundMatch ) { if ( debug != null ) { debug . println ( "did not find match for private key with CKA_ID [" + getID ( pkeyID ) + "] (ignoring entry)" ) ; } } } return matchedCerts ; }
for each private key cka_id , find corresponding cert with same cka_id . if found cert , see if cert cka_label is unique . if cka_label unique , map private key / cert alias to that cka_label . if cka_label not unique , map private key / cert alias to : cka_label + alias_sep + issuer + alias_sep + serial if cert not found , ignore private key ( don ' t support private key entries without a cert chain yet )
