log.finest("+++ signer private key = " + signerKey);
if (Configuration.DEBUG) log.fine("+++ signer private key = " + signerKey);
  void writeDSA(JarOutputStream jar, PrivateKey signerKey,                Certificate[] certificates, boolean internalSF)      throws IOException, CertificateEncodingException, CRLException  {    if (this.state != SF_GENERATED)      throw new IllegalStateException(Messages.getString("SFHelper.4")); //$NON-NLS-1$    log.finest("+++ signer private key = " + signerKey); //$NON-NLS-1$    ISignature signatureAlgorithm;    ISignatureCodec signatureCodec;    OID digestEncryptionAlgorithmOID;    if (signerKey instanceof DSAPrivateKey)      {        signatureAlgorithm = new DSSSignature();        signatureCodec = new DSSSignatureX509Codec();        digestEncryptionAlgorithmOID = Main.DSA_SIGNATURE_OID;      }    else if (signerKey instanceof RSAPrivateKey)      {        signatureAlgorithm = new RSAPKCS1V1_5Signature(Registry.MD5_HASH);        signatureCodec = new RSAPKCS1V1_5SignatureX509Codec();        digestEncryptionAlgorithmOID = Main.RSA_SIGNATURE_OID;      }    else      throw new SecurityException(Messages.getString("SFHelper.6")); //$NON-NLS-1$    Map signatureAttributes = new HashMap();    signatureAttributes.put(ISignature.SIGNER_KEY, signerKey);    signatureAlgorithm.setupSign(signatureAttributes);    signatureAlgorithm.update(sfBytes, 0, sfBytes.length);    Object signature = signatureAlgorithm.sign();    byte[] signedSFBytes = signatureCodec.encodeSignature(signature);    log.finest("\n" + Util.dumpString(signedSFBytes, "+++ signedSFBytes ")); //$NON-NLS-1$ //$NON-NLS-2$    Set digestAlgorithms = new HashSet();    List digestAlgorithm = new ArrayList(2);    DERValue derDigestAlgorithmOID = new DERValue(DER.OBJECT_IDENTIFIER,                                                  hashAlgorithmIdentifierSHA1);    DERValue derDigestAlgorithmParams = new DERValue(DER.NULL, null);    digestAlgorithm.add(derDigestAlgorithmOID);    digestAlgorithm.add(derDigestAlgorithmParams);    DERValue derDigestAlgorithm = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,                                               digestAlgorithm);    digestAlgorithms.add(derDigestAlgorithm);    // TODO (rsn): test with internalsf == true    PKCS7Data data = internalSF ? new PKCS7Data(sfBytes) : null;    X509CRL[] crls = null;    Set signerInfos = new HashSet();    X509Certificate cert = (X509Certificate) certificates[0];    X500Principal issuer = cert.getIssuerX500Principal();    BigInteger serialNumber = cert.getSerialNumber();    byte[] authenticatedAttributes = null;    byte[] encryptedDigest = signedSFBytes;    byte[] unauthenticatedAttributes = null;    SignerInfo signerInfo = new SignerInfo(issuer,                                           serialNumber,                                           hashAlgorithmIdentifierSHA1,                                           authenticatedAttributes,                                           digestEncryptionAlgorithmOID,                                           encryptedDigest,                                           unauthenticatedAttributes);    signerInfos.add(signerInfo);    PKCS7SignedData dsaContents = new PKCS7SignedData(digestAlgorithms,                                                      data,                                                      certificates,                                                      crls,                                                      signerInfos);    dsaContents.encode(jar);    jar.flush();    this.state = DSA_GENERATED;  }