@Override public void setupSecurityContext(final CallbackHandler handler, final Subject executionSubject, final Subject serviceSubject) { List<Callback> callbacks = new ArrayList<Callback>(); final PasswordValidationCallback pvc = new PasswordValidationCallback(executionSubject, username, password.toCharArray()); callbacks.add(pvc); Callback callbackArray[] = new Callback[callbacks.size()]; try { handler.handle(callbacks.toArray(callbackArray)); } catch (UnsupportedCallbackException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } this.authenticated = pvc.getResult(); System.out.println("Authenticated: " + this.authenticated); }
@Override public void setupSecurityContext(final CallbackHandler handler, final Subject executionSubject, final Subject serviceSubject) { List<Callback> callbacks = new ArrayList<Callback>(); final PasswordValidationCallback pvc = new PasswordValidationCallback(executionSubject, username, password.toCharArray()); callbacks.add(pvc); Callback callbackArray[] = new Callback[callbacks.size()]; try { handler.handle(callbacks.toArray(callbackArray)); } catch (UnsupportedCallbackException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } this.authenticated = pvc.getResult(); System.out.println("Authenticated: " + this.authenticated); }
public boolean login() throws LoginException { if (debug) { logger.debug("DemoLoginModule login called."); for (String key : sharedState.keySet()) { String value = sharedState.get(key).toString(); logger.debug(key + ": " + value); } } Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("username"); callbacks[1] = new PasswordCallback("password", false); try { handler.handle(callbacks); username = ((NameCallback) callbacks[0]).getName(); char[] passwordCharArray = ((PasswordCallback) callbacks[1]).getPassword(); String password = new String(passwordCharArray); successLogin = username.equals(password); } catch (IOException ioe) { ioe.printStackTrace(); throw new LoginException("IOException occured: " + ioe.getMessage()); } catch (UnsupportedCallbackException ucbe) { ucbe.printStackTrace(); throw new LoginException("UnsupportedCallbackException encountered: " + ucbe.getMessage()); } return successLogin; }
throw new LoginException("IOException occured: " + ioe.getMessage()); } catch (UnsupportedCallbackException ucbe) { ucbe.printStackTrace(); throw new LoginException("UnsupportedCallbackException encountered: " + ucbe.getMessage());
throw new LoginException("IOException occured: " + ioe.getMessage()); } catch (UnsupportedCallbackException ucbe) { ucbe.printStackTrace(); throw new LoginException("UnsupportedCallbackException encountered: " + ucbe.getMessage());
/** * Eventmethod called by SWT every time a widget is selcted. * This method is intended to by called by SWT only! * @param e the event object passed by SWT. */ public void widgetSelected(SelectionEvent e) { if(e.widget==ok) { try { readBack(); } catch (UnsupportedCallbackException exc) { exc.printStackTrace(); } exitStatus=true; shell.dispose(); } else if(e.widget==cancel) { exitStatus=false; shell.dispose(); } }
/** * Eventmethod called by SWT every time a widget is selcted. * This method is intended to by called by SWT only! * @param e the event object passed by SWT. */ public void widgetSelected(SelectionEvent e) { if(e.widget==ok) { try { readBack(); } catch (UnsupportedCallbackException exc) { exc.printStackTrace(); } exitStatus=true; shell.dispose(); } else if(e.widget==cancel) { exitStatus=false; shell.dispose(); } }