Examples of PasswordRetrievalException


Examples of net.east301.keyring.PasswordRetrievalException

                    return entries.getValue();
                }
            }

            //
            throw new PasswordRetrievalException(
                    "Password related to the specified service and account is not found");
        } // synchronized
    }
View Full Code Here

Examples of net.east301.keyring.PasswordRetrievalException

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

        //
        int[] dataLength = new int[1];
        Pointer[] data = new Pointer[1];

        //
        int status = NativeLibraryManager.Security.SecKeychainFindGenericPassword(
                null, serviceBytes.length, serviceBytes,
                accountBytes.length, accountBytes,
                dataLength, data, null);
        if (status != 0) {
            throw new PasswordRetrievalException(convertErrorCodeToMessage(status));
        }

        //
        byte[] passwordBytes = data[0].getByteArray(0, dataLength[0]);

        //
        NativeLibraryManager.Security.SecKeychainItemFreeContent(null, data[0]);

        //
        try {
            return new String(passwordBytes, "UTF-8");
        } catch (UnsupportedEncodingException ex) {
            throw new PasswordRetrievalException("Unsupported encoding 'UTF-8' specified");
        }
    }
View Full Code Here

Examples of net.east301.keyring.PasswordRetrievalException

                    break;
                }
            }

            if (targetEntry == null) {
                throw new PasswordRetrievalException(
                        "Password related to the specified service and account is not found");
            }

            //
            byte[] decryptedBytes;

            try {
                decryptedBytes = Crypt32Util.cryptUnprotectData(targetEntry.getPassword());
            } catch (Exception ex) {
                throw new PasswordRetrievalException("Failed to decrypt password");
            }

            //
            try {
                return new String(decryptedBytes, "UTF-8");
            } catch (UnsupportedEncodingException ex) {
                throw new PasswordRetrievalException("Unsupported encoding 'UTF-8' specified");
            }

        } finally {
            try {
                fileLock.release();
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.