Package javax.crypto

Examples of javax.crypto.CipherInputStream


            try {
                Cipher cipher = Cipher.getInstance(algorithm);
                cipher.init(Cipher.DECRYPT_MODE, skeySpec);

                InputStream in = encrypted.getInputStream();
                return new CipherInputStream(in, cipher);
            } catch (GeneralSecurityException e) {
                throw (IOException) new IOException().initCause(e);
            }
        }
View Full Code Here


    public Object unmarshal(Exchange exchange, InputStream encryptedStream) throws Exception {
        Object unmarshalled = null;
        if (encryptedStream != null) {
            byte[] iv = getInlinedInitializationVector(exchange, encryptedStream);
            Key key = getKey(exchange);
            CipherInputStream cipherStream = null;
            ByteArrayOutputStream plaintextStream = null;
            try {
                cipherStream = new CipherInputStream(encryptedStream, initializeCipher(DECRYPT_MODE, key, iv));
                plaintextStream = new ByteArrayOutputStream(bufferSize);
                HMACAccumulator hmac = getMessageAuthenticationCode(key);
                byte[] buffer = new byte[bufferSize];
                hmac.attachStream(plaintextStream);
                int read;
                while ((read = cipherStream.read(buffer)) >= 0) {
                    hmac.decryptUpdate(buffer, read);
                }
                hmac.validate();
                unmarshalled = plaintextStream.toByteArray();
            } finally {
View Full Code Here

        }

        try {
            inStreamCipher.init(Cipher.DECRYPT_MODE, key);

            return new CipherInputStream(in, inStreamCipher);
        } catch (java.security.InvalidKeyException e) {
            throw Error.error(ErrorCode.X_S0531, e);
        }
    }
View Full Code Here

      try {
        InputStream in = new FileInputStream(sFile);
        GZIPInputStream gzipin = new GZIPInputStream(in);
        InputStream in2 = gzipin;
        if (SetupInfo.getBoolProperty(SetupInfo.REQUIRE_BACKUP_PASSWORD)) {
          in2 = new CipherInputStream(gzipin, myCipher);
        }
        DataInputStream doIn = new DataInputStream(in2);

        //make sure file and descriptions are right
        String sFileDesc = doIn.readUTF();
View Full Code Here

   *
   * @param  in  Description of the Parameter
   * @return     Description of the Return Value
   */
  public static InputStream createEncryptedInputStream(InputStream in) {
    return new CipherInputStream(in, createCipher(Cipher.DECRYPT_MODE));
  }//}}}
View Full Code Here

  private void tryConvertLastLogin() {
    try {
      File lastLogin = new File(PlatformUtils.getWorkingDirectory(), "lastlogin");
      Cipher cipher = getCipher(2, "passwordfile");
      DataInputStream dis;
      if (cipher != null) dis = new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher));
      else dis = new DataInputStream(new FileInputStream(lastLogin));
      String userName = dis.readUTF();
      String password = dis.readUTF();

      dis.close();
View Full Code Here

      if (!lastLogin.exists()) { return; }
      Cipher cipher = getCipher(2, "passwordfile");

      DataInputStream dis;
      if (cipher != null) {
        dis = new DataInputStream(new CipherInputStream(new FileInputStream(lastLogin), cipher));
      } else {
        dis = new DataInputStream(new FileInputStream(lastLogin));
      }

      try {
View Full Code Here

     */
    public CipherInputStream encrypt(InputStream is) throws InvalidKeyException,
        InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchPaddingException
    {
        Cipher cipher = initEncryptModeCipher();
        return new CipherInputStream(is, cipher);
    }
View Full Code Here

     */
    public CipherInputStream decrypt(InputStream is) throws InvalidKeyException,
        InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchPaddingException
    {
        Cipher cipher = initDecryptModeCipher();
        return new CipherInputStream(is, cipher);
    }
View Full Code Here

                    byte [] iv  = new byte[len];
                    is.read(iv,0,len);
                    ivSpec = new IvParameterSpec(iv);
                    cipher.init(mode,key,ivSpec);
                }
                return new CipherInputStream(is,cipher);
            } else {
               logger.log(Level.SEVERE, LogStringsMessages.WSS_1914_INVALID_CIPHER_MODE(mode),"Invalid Cipher mode:"+mode);
               throw new IOException("Invalid Cipher mode:"+mode);
            }
           
View Full Code Here

TOP

Related Classes of javax.crypto.CipherInputStream

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.