@Override public char[] getPassword(String prompt, String testToken) throws PasswordResolverException { if (password == null) { throw new PasswordResolverException("please initialize me first"); } return password; }
} catch (PasswordResolverException ex) { throw new IllegalArgumentException("invalid masterPasswordCallback configuration " + masterPasswordCallback + ", " + ex.getClass().getName() + ": " + ex.getMessage());
pwd = moduleConf.passwordRetriever().getPassword(slotId); } catch (PasswordResolverException ex) { throw new P11TokenException("PasswordResolverException: " + ex.getMessage(), ex);
pwd = moduleConf.getPasswordRetriever().getPassword(slotId); } catch (PasswordResolverException ex) { throw new P11TokenException("PasswordResolverException: " + ex.getMessage(), ex);
@Override public String protectPassword(String protocol, char[] password) throws PasswordResolverException { Objects.requireNonNull(protocol, "protocol may not be null"); Objects.requireNonNull(password, "password may not be null"); for (SinglePasswordResolver resolver : resolvers) { if (resolver.canResolveProtocol(protocol)) { return resolver.protectPassword(password); } } throw new PasswordResolverException("could not find password resolver to protect password " + "of protocol '" + protocol + "'"); }
pwd = moduleConf.passwordRetriever().getPassword(slotId); } catch (PasswordResolverException ex) { throw new P11TokenException("PasswordResolverException: " + ex.getMessage(), ex);
@Override public char[] resolvePassword(String passwordHint) throws PasswordResolverException { Objects.requireNonNull(passwordHint, "passwordHint may not be null"); int index = passwordHint.indexOf(':'); if (index == -1) { return passwordHint.toCharArray(); } String protocol = passwordHint.substring(0, index); for (SinglePasswordResolver resolver : resolvers) { if (resolver.canResolveProtocol(protocol)) { return resolver.resolvePassword(passwordHint); } } throw new PasswordResolverException("could not find password resolver to resolve password " + "of protocol '" + protocol + "'"); }
pwd = moduleConf.getPasswordRetriever().getPassword(slotId); } catch (PasswordResolverException ex) { throw new P11TokenException("PasswordResolverException: " + ex.getMessage(), ex);
protected char[] getMasterPassword(String encryptedPassword) throws PasswordResolverException { synchronized (masterPasswordLock) { init(); if (masterPassword == null) { if (masterPwdCallback == null) { throw new PasswordResolverException("masterPasswordCallback is not initialized"); } this.masterPassword = masterPwdCallback.getPassword("Please enter the master password", encryptedPassword); } return masterPassword; } }
throw new CaMgmtException("KeyStoreException: " + ex.getMessage(), ex); } catch (PasswordResolverException ex) { throw new CaMgmtException("PasswordResolverException: " + ex.getMessage(), ex);
@Override public char[] getPassword(String prompt, String testToken) throws PasswordResolverException { if (passwordFile == null) { throw new PasswordResolverException("please initialize me first"); throw new PasswordResolverException("could not read file " + passwordFile, ex); } finally { if (reader != null) { throw new PasswordResolverException("no password is specified in file " + passwordFile);
} catch (PasswordResolverException ex) { throw new ObjectCreationException( "could not resolve password. Message: " + ex.getMessage());
int len = bytes.length; if (len <= 16 && len != 0) { throw new PasswordResolverException("invalid length of the encrypted password"); PBEAlgo algo = PBEAlgo.forCode(algoCode); if (algo == null) { throw new PasswordResolverException("unknown algorithm code " + algoCode); pwd = PasswordBasedEncryption.decrypt(algo, cipherText, masterPassword, iterationCount, salt); } catch (GeneralSecurityException ex) { throw new PasswordResolverException("could not decrypt the password: " + ex.getMessage());
} catch (PasswordResolverException ex) { throw new ObjectCreationException( "could not resolve password. Message: " + ex.getMessage());
@Override public char[] getPassword(String prompt, String testToken) throws PasswordResolverException { String tmpPrompt = prompt; if (StringUtil.isBlank(tmpPrompt)) { tmpPrompt = "Password required"; } for (int i = 0; i < tries; i++) { char[] password; if (quorum == 1) { password = SecurePasswordInputPanel.readPassword(tmpPrompt); if (password == null) { throw new PasswordResolverException("user has cancelled"); } } else { char[][] passwordParts = new char[quorum][]; for (int j = 0; j < quorum; j++) { String promptPart = tmpPrompt + " (part " + (j + 1) + "/" + quorum + ")"; passwordParts[j] = SecurePasswordInputPanel.readPassword(promptPart); if (passwordParts[j] == null) { throw new PasswordResolverException("user has cancelled"); } } password = StringUtil.merge(passwordParts); } if (isPasswordValid(password, testToken)) { return password; } } throw new PasswordResolverException("Could not get the password after " + tries + " tries"); }
masterPassword, iterationCount, salt); } catch (GeneralSecurityException ex) { throw new PasswordResolverException("could not encrypt the password: " + ex.getMessage());
@Override public void init(String conf) throws PasswordResolverException { if (StringUtil.isBlank(conf)) { quorum = 1; return; } ConfPairs pairs = new ConfPairs(conf); String str = pairs.value("quorum"); quorum = Integer.valueOf(str); if (quorum < 1 || quorum > 10) { throw new PasswordResolverException("quorum " + quorum + " is not in [1,10]"); } str = pairs.value("tries"); if (StringUtil.isNotBlank(str)) { int intValue = Integer.parseInt(str); if (intValue > 0) { this.tries = intValue; } } }
@Override public void init(String conf) throws PasswordResolverException { Args.notBlank(conf, "conf"); ConfPairs pairs = new ConfPairs(conf); passwordFile = pairs.value("file"); if (StringUtil.isBlank(passwordFile)) { throw new PasswordResolverException("invalid configuration " + conf + ", no file is specified"); } passwordFile = IoUtil.expandFilepath(passwordFile); }