Examples of PasswordSaveException


Examples of net.east301.keyring.PasswordSaveException

        try {
            serviceBytes = service.getBytes("UTF-8");
            accountBytes = account.getBytes("UTF-8");
            passwordBytes = password.getBytes("UTF-8");
        } catch (UnsupportedEncodingException ex) {
            throw new PasswordSaveException("Unsupported encoding 'UTF-8' specified");
        }

        //
        Pointer[] itemRef = new Pointer[1];

        //
        int status = NativeLibraryManager.Security.SecKeychainFindGenericPassword(
                    null, serviceBytes.length, serviceBytes,
                    accountBytes.length, accountBytes,
                    null, null, itemRef);

        if (status != SecurityLibrary.ERR_SEC_SUCCESS
                && status != SecurityLibrary.ERR_SEC_ITEM_NOT_FOUND) {
            throw new PasswordSaveException(convertErrorCodeToMessage(status));
        }

        //
        if (itemRef[0] != null) {
            status = NativeLibraryManager.Security.SecKeychainItemModifyContent(
                    itemRef[0], null, passwordBytes.length, passwordBytes);

            // TODO: add code to release itemRef[0]
        } else {
            status = NativeLibraryManager.Security.SecKeychainAddGenericPassword(
                    Pointer.NULL, serviceBytes.length, serviceBytes,
                    accountBytes.length, accountBytes,
                    passwordBytes.length, passwordBytes, null);
        }

        if (status != 0) {
            throw new PasswordSaveException(convertErrorCodeToMessage(status));
        }
    }
View Full Code Here

Examples of net.east301.keyring.PasswordSaveException

            byte[] encryptedBytes;

            try {
                encryptedBytes = Crypt32Util.cryptProtectData(password.getBytes("UTF-8"));
            } catch (UnsupportedEncodingException ex) {
                throw new PasswordSaveException("Unsupported encoding 'UTF-8' specified");
            } catch (Exception ex) {
                throw new PasswordSaveException("Failed to encrypt password");
            }

            //
            ArrayList<PasswordEntry> entries = loadPasswordEntries();
            PasswordEntry targetEntry = null;
View Full Code Here

Examples of net.east301.keyring.PasswordSaveException

            ObjectOutputStream oout = new ObjectOutputStream(fout);

            oout.writeObject(entries.toArray(new PasswordEntry[0]));
        } catch (Exception ex) {
            Logger.getLogger(WindowsDPAPIBackend.class.getName()).log(Level.SEVERE, null, ex);
            throw new PasswordSaveException("Failed to save password entries to a file");
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.