Refine search
protected Object getCredential() throws LoginException { NameCallback nc = new NameCallback("Alias: "); ObjectCallback oc = new ObjectCallback("Credential: "); Callback[] callbacks = { nc, oc }; try { callbackHandler.handle(callbacks); return oc.getCredential(); } catch (IOException ioe) { LoginException le = new LoginException(); le.initCause(ioe); throw le; } catch (UnsupportedCallbackException uce) { LoginException le = new LoginException(); le.initCause(uce); throw le; } }
/** * Retrieves the user name by querying the property of * {@link PropertyKey#SECURITY_LOGIN_USERNAME} through {@link AppCallbackHandler}. * * @return true if user name provided by application is set and not empty * @throws LoginException when the login fails */ @Override public boolean login() throws LoginException { Callback[] callbacks = new Callback[1]; callbacks[0] = new NameCallback("user name: "); try { mCallbackHandler.handle(callbacks); } catch (IOException | UnsupportedCallbackException e) { throw new LoginException(e.getMessage()); } String userName = ((NameCallback) callbacks[0]).getName(); if (!userName.isEmpty()) { mUser = new User(userName); return true; } return false; }
userEntry = new User(user.getName(), authMethod, null); } catch (Exception e) { throw (LoginException)(new LoginException(e.toString()).initCause(e)); throw new LoginException("Can't find user name");
@Override public boolean login() throws LoginException { Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("User name"); callbacks[1] = new PasswordCallback("Password", false); try { handler.handle(callbacks); } catch (IOException ioe) { throw (LoginException)new LoginException().initCause(ioe); } catch (UnsupportedCallbackException uce) { throw (LoginException)new LoginException().initCause(uce); } String password; String username = ((NameCallback)callbacks[0]).getName(); if (username == null) return false; if (((PasswordCallback)callbacks[1]).getPassword() != null) password = new String(((PasswordCallback)callbacks[1]).getPassword()); else password=""; // authenticate will throw LoginException // in case of failed authentication authenticate(username, password); user = new UserPrincipal(username); succeeded = true; return true; }
callbacks[1] = new PasswordCallback("Password: ", false); try { callbackHandler.handle(callbacks); } catch (IOException ioe) { throw new LoginException(ioe.getMessage()); } catch (UnsupportedCallbackException uce) { throw new LoginException(uce.getMessage() + " not available to obtain information from user");
@Override public LoginException authLoginError(Throwable t) { LoginException loginException = new LoginException("Error during login/authentication"); loginException.initCause(t); return loginException; }
identity = createIdentity(name); } catch (Exception e) { LoginException le = new LoginException(); le.initCause(e); throw le; throw new LoginException(); final String username; try { callbackHandler.handle(callbacks); username = callback.getPrincipal().getName(); final Object c = callback.getCredential(); LoginException le = new LoginException(); le.initCause(e); throw le; } catch (UnsupportedCallbackException e) { LoginException le = new LoginException(); le.initCause(e); throw le; identity = createIdentity(username); } catch (Exception e) { LoginException le = new LoginException(); le.initCause(e); throw le;
/** * Overriding to allow for certificate-based login. Standard JAAS. */ @Override public boolean login() throws LoginException { Callback[] callbacks = new Callback[1]; callbacks[0] = new CertificateCallback(); try { callbackHandler.handle(callbacks); } catch (IOException ioe) { throw new LoginException(ioe.getMessage()); } catch (UnsupportedCallbackException uce) { throw new LoginException(uce.getMessage() + " Unable to obtain client certificates."); } X509Certificate[] certificates = ((CertificateCallback)callbacks[0]).getCertificates(); username = getUserNameForCertificates(certificates); if (username == null) { throw new FailedLoginException("No user for client certificate: " + getDistinguishedName(certificates)); } if (debug) { LOG.debug("Certificate for user: " + username); } succeeded = true; return true; }
private void throwWith(String error, Exception cause) throws LoginException { LoginException le = new LoginException(error); le.initCause(cause); throw le; } }
public boolean login() throws LoginException { Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("name"); callbacks[1] = new PasswordCallback("password", false); try { callbackHandler.handle(callbacks); } catch (java.io.IOException e) { throw (LoginException) new LoginException("Could not determine username and password").initCause(e); } catch (UnsupportedCallbackException e) { throw (LoginException) new LoginException("Unlikely UnsupportedCallbackException").initCause(e); } geronimoPasswordCredential = new GeronimoPasswordCredential(((NameCallback) callbacks[0]).getName(), ((PasswordCallback) callbacks[1]).getPassword()); return false; }
/** * Issues the specified callbacks to acquire login information. * @param callbacks The collection of callbacks to issue. * @throws IOException If an I/O exception was thrown by the callback * handler. * @throws UnsupportedCallbackException If a requested callback is not * supported by the callback handler. * @throws LoginException If a callback handler is required (see * {@link #AbstractLoginModule(boolean)}) but was not provided. */ protected void callback(Callback... callbacks) throws IOException, UnsupportedCallbackException, LoginException { if (callbackHandler != null) { callbackHandler.handle(callbacks); } else if (requireCallbackHandler) { throw new LoginException("Login module requires a callback handler"); } }
@Override public LoginException authAssertionValidationError(Throwable t) { LoginException loginException = new LoginException("Failed to validate assertion using STS"); loginException.initCause(t); return loginException; }
public boolean login() throws LoginException { if (managedConnectionFactory == null) { return false; } Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("User name"); callbacks[1] = new PasswordCallback("Password", false); try { callbackHandler.handle(callbacks); } catch (IOException ioe) { throw (LoginException) new LoginException().initCause(ioe); } catch (UnsupportedCallbackException uce) { throw (LoginException) new LoginException().initCause(uce); } resourcePrincipalName = ((NameCallback) callbacks[0]).getName(); userName = ((NameCallback) callbacks[0]).getName(); password = ((PasswordCallback) callbacks[1]).getPassword(); return false; }
public boolean login() throws LoginException { final Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("Username:"); callbacks[1] = new PasswordCallback("Password:", false); try { callbackHandler.handle(callbacks); } catch (final Exception e) { throw new LoginException("Failed to perform emulated login: " + e.getMessage()); } user = ((NameCallback) callbacks[0]).getName(); return true; }
/** * Create a LoginException with the given message and set the cause to the given Exception * @param msg Exception message * @param e Root cause * @return LoginException the chained LoginException */ private static LoginException createChainedLoginException(String msg, Exception e) { LoginException le = new LoginException(msg); le.initCause(e); return le; }
public boolean login() throws LoginException { Callback[] callbacks = new Callback[1]; callbacks[0] = new NameCallback("User name"); try { callbackHandler.handle(callbacks); } catch (java.io.IOException e) { throw (LoginException) new LoginException("Unlikely IOException").initCause(e); } catch (UnsupportedCallbackException e) { throw (LoginException) new LoginException("Unlikely UnsupportedCallbackException").initCause(e); } String userName = ((NameCallback) callbacks[0]).getName(); String unparsedCredentials = credentials.getProperty(userName); if (unparsedCredentials != null) { parseCredentials(unparsedCredentials, passwordCredentials); } return false; }
protected void setUsernameAndPassword(boolean shared) throws LoginException{ if(shared){ username = (String) sharedState.get(SHARED_NAME); password = (char[]) sharedState.get(SHARED_PWD); return; } if(callbackHandler == null) throw new LoginException("Callback handler needed."); Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("username: "); callbacks[1] = new PasswordCallback("password: ",false); try{ callbackHandler.handle(callbacks); username = ((NameCallback) callbacks[0]).getName(); password = ((PasswordCallback) callbacks[1]).getPassword(); }catch(IOException ioe){ throw new LoginException("login failed cased by " + ioe.getLocalizedMessage()); }catch(UnsupportedCallbackException uce){ throw new LoginException("login failed caused by " + uce.getLocalizedMessage()); } }
@Override public LoginException authAssertionValidationError(Throwable t) { LoginException loginException = new LoginException("Failed to validate assertion using STS"); loginException.initCause(t); return loginException; }
public boolean login() throws LoginException { Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("User name"); callbacks[1] = new PasswordCallback("Password", false); try { callbackHandler.handle(callbacks); } catch (IOException ioe) { throw (LoginException) new LoginException().initCause(ioe); } catch (UnsupportedCallbackException uce) { throw (LoginException) new LoginException().initCause(uce); } String username = ((NameCallback) callbacks[0]).getName(); char[] password = ((PasswordCallback) callbacks[1]).getPassword(); if (username == null || password == null) return false; nupCredential = new NamedUsernamePasswordCredential(username, password, name); return false; }
public boolean login() throws LoginException { logger.trace("login.enter;"); // Setup default callback handlers. Callback[] callbacks = new Callback[] { new NameCallback("Username: "), new PasswordCallback("Password: ", false) }; try { callbackHandler.handle(callbacks); } catch (Exception ex) { //_succeeded = false; logger.error("login.error: " + ex.getMessage(), ex); throw new LoginException(ex.getMessage()); } String username = ((NameCallback)callbacks[0]).getName(); String password = new String(((PasswordCallback)callbacks[1]).getPassword()); logger.debug("login; user: {}; password: {}", username, password); return true; }