@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); }
/** * Register with the CallbackHandler * @param userPrincipal * @param username * @param password */ protected void registerWithCallbackHandler(Principal userPrincipal, String username, String password) { if(this.callbackHandler instanceof TomcatJASPICallbackHandler) { TomcatJASPICallbackHandler cbh = (TomcatJASPICallbackHandler) callbackHandler; PasswordValidationCallback passwordValidationCallback = new PasswordValidationCallback(null,username,password.toCharArray()); cbh.setPasswordValidationCallback(passwordValidationCallback); cbh.setCallerPrincipalCallback(new CallerPrincipalCallback(null,userPrincipal)); } else throw new RuntimeException(" Unsupported Callback handler " + this.callbackHandler.getClass().getCanonicalName()); } }
PasswordValidationCallback pvCallback = new PasswordValidationCallback( this.getRequesterSubject(context),username, pwd); Callback[] callbacks = new Callback[] { pvCallback };
char[] pwd = (password == null) ? null : password.toCharArray(); PasswordValidationCallback pvCallback = new PasswordValidationCallback(callerSubject,username, pwd); Callback[] callbacks = new Callback[] { pvCallback }; try {