Package net.suberic.crypto

Examples of net.suberic.crypto.EncryptionUtils


        }
      }

      return false;
    } else {
      EncryptionUtils utils = getEncryptionUtils();
      if (utils != null) {
        return (utils.getEncryptionStatus((MimeMessage) mMsgInfo.getMessage()) == EncryptionUtils.SIGNED);
      } else
        return false;
    }
  }
View Full Code Here


          return true;
        }
      }
      return false;
    } else {
      EncryptionUtils utils = getEncryptionUtils();
      if (utils != null) {
        return (utils.getEncryptionStatus((MimeMessage) mMsgInfo.getMessage()) == EncryptionUtils.ENCRYPTED);
      } else
        return false;
    }
  }
View Full Code Here

   */
  public boolean checkSignature(
      java.security.Key key, boolean recheck, boolean changeStatusOnFailure)
  throws MessagingException, java.io.IOException, java.security.GeneralSecurityException {
    if (recheck || ! hasCheckedSignature()) {
      EncryptionUtils cryptoUtils = getEncryptionUtils();

      //mSignatureValid =  cryptoUtils.checkSignature((MimeMessage)mMsgInfo.getMessage(), key);
      // List attachments = mMsgInfo.getAttachments();
      List attachments = mMsgInfo.getAttachmentBundle().getAttachmentsAndTextPart();

View Full Code Here

          if (o instanceof CryptoAttachment) {
            CryptoAttachment ca = (CryptoAttachment) o;

            if (! ca.decryptedSuccessfully()) {
              // FIXME
              EncryptionUtils cryptoUtils = getEncryptionUtils();

              BodyPart bp = ca.decryptAttachment(cryptoUtils, key);
              MailUtilities.handlePart((MimeBodyPart) bp, bundle);
            }
          }
View Full Code Here

      AttachmentBundle bundle = mMsgInfo.getAttachmentBundle();
      List attachmentList = bundle.getAttachmentsAndTextPart();
      for (int i = 0; i < attachmentList.size(); i++) {
        Object o = attachmentList.get(i);
        if (o instanceof KeyAttachment) {
          EncryptionUtils utils = getEncryptionUtils();
          return ((KeyAttachment) o).extractKeys(utils);
        }
      }
    }
View Full Code Here

    List attachKeys = getAttachKeys();
    if (attachKeys != null) {
      for (int i = 0; i < attachKeys.size(); i++) {
        EncryptionKey currentKey = (EncryptionKey)attachKeys.get(i);
        try {
          EncryptionUtils utils = currentKey.getEncryptionUtils();
          keyParts.add(utils.createPublicKeyPart(new Key[] { currentKey }));
        } catch (Exception e) {
          // FIXME ignore for now.
          System.out.println("caught exception adding key to message:  " + e);
          e.printStackTrace();
        }
View Full Code Here

    }

    // if either store is configured, try loading.
    if (! (pgpPrivateFilename.equals("") && pgpPublicFilename.equals(""))) {
      try {
    EncryptionUtils pgpUtils = EncryptionManager.getEncryptionUtils(EncryptionManager.PGP);
    if (pgpUtils != null) {
      pgpKeyMgr = pgpUtils.createKeyManager();
      try {
          pgpKeyMgr.loadPrivateKeystore(new FileInputStream(new File(pgpPrivateFilename)), null);
      } catch (java.io.IOException fnfe) {
          System.out.println("Error loading PGP private keystore from file " + pgpPrivateFilename + ":  " + fnfe.getMessage());
      } catch (java.security.GeneralSecurityException gse) {
          System.out.println("Error loading PGP private keystore from file " + pgpPrivateFilename + ":  " + gse.getMessage());
      }
      try {
        pgpKeyMgr.loadPublicKeystore(new FileInputStream(new File(pgpPublicFilename)), null);
      } catch (java.io.IOException fnfe) {
        System.out.println("Error loading PGP public keystore from file " + pgpPublicFilename + ":  " + fnfe.getMessage());
      } catch (java.security.GeneralSecurityException gse) {
        System.out.println("Error loading PGP public keystore from file " + pgpPublicFilename + ":  " + gse.getMessage());
      }
    }
      } catch (java.security.NoSuchProviderException nspe) {
        System.out.println("Error loading PGP key store:  " + nspe.getMessage());
      } catch (Exception e) {
        System.out.println("Error loading PGP key store:  " + e.getMessage());
      }
    }

    String smimePublicFilename = sourceBundle.getProperty(key + ".smime.keyStore.public.filename", "");
    if(!smimePublicFilename.equals(""))
      smimePublicFilename = rm.translateName(smimePublicFilename);

    String smimePrivateFilename = sourceBundle.getProperty(key + ".smime.keyStore.private.filename", "");
    if(!smimePrivateFilename.equals(""))
      smimePrivateFilename = rm.translateName(smimePrivateFilename);
   
    String smimePrivatePwString = sourceBundle.getProperty(key + ".smime.keyStore.private.password", "");
    if (!smimePrivatePwString.equals("")){
      smimePrivatePwString = net.suberic.util.gui.propedit.PasswordEditorPane.descrambleString(smimePrivatePwString);
      smimePassphrase = smimePrivatePwString.toCharArray();
    }

    // if either store is configured, try loading.
    if (! (smimePrivateFilename.equals("") && smimePublicFilename.equals(""))) {
      try {
  EncryptionUtils smimeUtils = EncryptionManager.getEncryptionUtils(EncryptionManager.SMIME);
  if (smimeUtils != null) {
    smimeKeyMgr = smimeUtils.createKeyManager();
    try {
      smimeKeyMgr.loadPrivateKeystore(new FileInputStream(new File(smimePrivateFilename)), smimePrivatePwString.toCharArray());
    } catch (java.security.GeneralSecurityException gse) {
      System.out.println("Error loading S/MIME private keystore from file " + smimePrivateFilename + ":  " + gse.getMessage());
    } catch (java.io.IOException fnfe) {
View Full Code Here

   */
  public static void handlePart(MimePart mp, AttachmentBundle bundle) throws MessagingException, java.io.IOException {
   
    String encryptionType = EncryptionManager.checkEncryptionType(mp);
   
    EncryptionUtils utils = null;
    if (encryptionType != null) {
      try {
        utils = EncryptionManager.getEncryptionUtils(encryptionType);
      } catch (java.security.NoSuchProviderException nspe) {
      }
    }
   
    if (utils != null) {
     
      int encryptionStatus = utils.getEncryptionStatus(mp);

      if (encryptionStatus == EncryptionUtils.ENCRYPTED) {
        Attachment newAttach = new net.suberic.pooka.crypto.CryptoAttachment(mp);
        bundle.addAttachment(newAttach);
      } else if (encryptionStatus == EncryptionUtils.SIGNED) {
View Full Code Here

TOP

Related Classes of net.suberic.crypto.EncryptionUtils

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.