Package javax.crypto

Examples of javax.crypto.SealedObject


     */
    public SealedObject seal(Serializable object) {
        try {
            Cipher cipher = Cipher.getInstance(_sealAlgorithm);
            cipher.init(Cipher.ENCRYPT_MODE, _secretKey);
            return new SealedObject(object, cipher);
        } catch (Exception e) {
            throw new SwitchYardException(e);
        }
    }
View Full Code Here


  
   public static SealedObject sealObject(Serializable ser)
   throws Exception
   {
      Cipher ci = EncryptionManager.getCipher(Cipher.ENCRYPT_MODE, algo);
      return new SealedObject(ser,ci);
   }
View Full Code Here

     */
    public static String encrypt(Serializable source) {
        try {
            Cipher c = Cipher.getInstance("AES");
            c.init(Cipher.ENCRYPT_MODE, SECRET_KEY);
            SealedObject so = new SealedObject(source, c);
            ByteArrayOutputStream store = new ByteArrayOutputStream();
            ObjectOutputStream out = new ObjectOutputStream(store);
            out.writeObject(so);
            out.close();
            byte[] data = store.toByteArray();
View Full Code Here

        try {
            byte[] data = Base64.decode(source);
            Cipher c = Cipher.getInstance("AES");
            c.init(Cipher.DECRYPT_MODE, SECRET_KEY);
            ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(data));
            SealedObject so = (SealedObject) in.readObject();
            return so.getObject(c);
        } catch (Exception e) {
            log.error("Unable to decrypt", e);
            return null;
        }
    }
View Full Code Here

  
   public static SealedObject sealObject(Serializable ser)
   throws Exception
   {
      Cipher ci = EncryptionManager.getCipher(Cipher.ENCRYPT_MODE, algo);
      return new SealedObject(ser,ci);
   }
View Full Code Here

                SecureRandom random = new SecureRandom();
                keyGen.init(random);
                SecretKey key = keyGen.generateKey();
                Cipher cipher = Cipher.getInstance("DES");
                cipher.init(Cipher.ENCRYPT_MODE,key);
                encryedData = new SealedObject(row, cipher);
               
                cixKey = new CIXKey();
                cipher = Cipher.getInstance("RSA");
                cipher.init(Cipher.WRAP_MODE, privateKey);
                getCixKey().wrappedKey = cipher.wrap(key);  
View Full Code Here

               
                int cixFileStat = 4;
                Vector noEncryData = new Vector();
                byte[] wrappedKey = null;
                Vector encryData = new Vector();
                SealedObject sealedEncryData = null;
               
                Cell nsCell = ObjectUtil.findNewCell(mainRow, "T", "NS");
                String ns = (String)nsCell.getColumnValue();
                Cell pCell = ObjectUtil.findNewCell(mainRow, "T", "P");
                String p = (String)pCell.getColumnValue();
                Cell paCell = ObjectUtil.findNewCell(mainRow, "T", "PA");
                String pa = (String)paCell.getColumnValue();
               
                String urns = null;
                String urp = null;
                DAO dao = DAO.getInstance();
                dao.query(Resources.SELECT_URNS_URP_FORM_P_SQL);
                dao.setObject(1, ns);
                dao.setObject(2, p);
                ResultSet rs = dao.executeQuery();
                try {
                    if (rs.next()) {
                        urns = rs.getString("URNS");
                        urp = rs.getString("URP");
                    }
                    rs.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
               
                String urpa = null;
                dao.query(Resources.SELECT_URPA_FROM_PA_SQL);
                dao.setObject(1, ns);
                dao.setObject(2, p);
                dao.setObject(3, pa);
                rs = dao.executeQuery();
                try {
                    if (rs.next()) {
                        urpa = rs.getString("URPA");
                    }
                    rs.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
               
                noEncryData.add(urns);
                noEncryData.add(urp);
                noEncryData.add(urpa);
               
                encryData.add(mainRow);
               
                PrivateKey priKey = getPriKey(ns, p, pa);
                try {
                    KeyGenerator keyGen = KeyGenerator.getInstance("DES");
                    SecureRandom random = new SecureRandom();
                    keyGen.init(random);
                    SecretKey key = keyGen.generateKey();
                    Cipher cipher = Cipher.getInstance("DES");
                    cipher.init(Cipher.ENCRYPT_MODE,key);
                    sealedEncryData = new SealedObject(encryData, cipher);                      
                    cipher = Cipher.getInstance("RSA");
                    cipher.init(Cipher.WRAP_MODE, priKey);
                    wrappedKey = cipher.wrap(key);
                } catch (Exception e) {
                    e.printStackTrace();
View Full Code Here

       
    }
   
    private SealedObject encryDatas(Vector datas, PrivateKey privateKey) {
       
            SealedObject encryedDatas = null;       
            try {
                KeyGenerator keyGen = KeyGenerator.getInstance("DES");
                SecureRandom random = new SecureRandom();
                keyGen.init(random);
                SecretKey key = keyGen.generateKey();
                Cipher cipher = Cipher.getInstance("DES");
                cipher.init(Cipher.ENCRYPT_MODE,key);
                encryedDatas = new SealedObject(datas, cipher);
                cipher = Cipher.getInstance("RSA");
                cipher.init(Cipher.WRAP_MODE, privateKey);
                this.wrappedKey = cipher.wrap(key);
            } catch (Exception e) {
                e.printStackTrace();
View Full Code Here

                dao.query(Resources.SELECT_PASSWORD_FROM_RUSER);
                dao.setString(1, userId);
                ResultSet rs = dao.executeQuery();
                try {
                    if (rs.next()) {
                        SealedObject so = (SealedObject)rs.getObject(1);
                        try {
                            String oldPassword = PasswordManager.getPassword(so);
                            if (!oldPassword.equals(password))
                                result = false;
                        } catch (Exception e) {
View Full Code Here

        }
    }

    private void setApplicationValues() {
        if (validateForm()) {
            SealedObject password = showSuperPasswordDialog();                   
            StringBuffer sb = new StringBuffer(TxtManager.getTxt("INFORMATION.CREATEFAMILY1"));                   
            sb.append(ObjectUtil.findNewCell(currentRow, "FAMILY", "FAMILY").getColumnValue().toString() + " " +
                    TxtManager.getTxt("INFORMATION.CREATEFAMILY2"));
            DialogManager.showMessageDialog(this, sb.toString());
            String lang = ObjectUtil.findNewCell(currentRow, "FAMILY", "LANG").getColumnValue().toString();
View Full Code Here

TOP

Related Classes of javax.crypto.SealedObject

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.