public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { SSLConnection sslConnection; if (! once.compareAndSet(true, false) || (sslConnection = sslConnectionSupplier.get()) == null) { delegate.handle(callbacks); return; } final int length = callbacks.length; final Callback[] newCallbacks = new Callback[length + 1]; newCallbacks[0] = new SSLCallback(sslConnection); System.arraycopy(callbacks, 0, newCallbacks, 1, length); try { delegate.handle(newCallbacks); } catch (UnsupportedCallbackException e) { if (e.getCallback() instanceof SSLCallback) { delegate.handle(callbacks); return; } throw e; } }
delegate.handle(newCallbacks); } catch (UnsupportedCallbackException e) { if (e.getCallback() instanceof SocketAddressCallback) { delegate.handle(callbacks); return;
if (e.getCallback() == realmChoiceCallBack) { realmChoiceCallBack = null; } else if (e.getCallback() == nameCallback) { throw log.mechCallbackHandlerDoesNotSupportUserName(e); } else if (e.getCallback() == passwordCallback) { throw log.mechCallbackHandlerDoesNotSupportCredentialAcquisition(e); } else { if (realmCallback.getText() != null) realm = realmCallback.getText(); } catch (UnsupportedCallbackException e) { if (e.getCallback() == realmCallback) { realmCallback = null; } else if (e.getCallback() == nameCallback) { throw log.mechCallbackHandlerDoesNotSupportUserName(e); } else if (e.getCallback() == passwordCallback) { throw log.mechCallbackHandlerDoesNotSupportCredentialAcquisition(e); } else { callbackHandler.handle(new Callback[]{ nameCallback, passwordCallback }); } catch (UnsupportedCallbackException e) { if (e.getCallback() == nameCallback) { throw log.mechCallbackHandlerDoesNotSupportUserName(e); } else if (e.getCallback() == passwordCallback) { throw log.mechCallbackHandlerDoesNotSupportCredentialAcquisition(e); } else {
); } catch (UnsupportedCallbackException e) { if (e.getCallback() == nameCallback) { throw log.mechCallbackHandlerDoesNotSupportUserName(e); } else if (credentialCallback == null || e.getCallback() != credentialCallback) { throw log.mechCallbackHandlerFailedForUnknownReason(e);
if (e.getCallback() == nameCallback) { throw log.mechCallbackHandlerDoesNotSupportUserName(e); } else if (e.getCallback() != credentialCallback) { throw log.mechCallbackHandlerFailedForUnknownReason(e);
password = factory.getKeySpec(factory.translate(twoWayPassword), ClearPasswordSpec.class).getEncodedPassword(); } catch (UnsupportedCallbackException e) { if (e.getCallback() == credentialCallback) {
if (e.getCallback() != credentialCallback) { throw log.mechCallbackHandlerFailedForUnknownReason(e); if (e.getCallback() != credentialCallback) { throw log.mechCallbackHandlerFailedForUnknownReason(e); if (e.getCallback() != passwordCallback) { throw log.mechCallbackHandlerFailedForUnknownReason(e);
public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { SSLConnection sslConnection; if (! once.compareAndSet(true, false) || (sslConnection = sslConnectionSupplier.get()) == null) { delegate.handle(callbacks); return; } final int length = callbacks.length; final Callback[] newCallbacks = new Callback[length + 1]; newCallbacks[0] = new SSLCallback(sslConnection); System.arraycopy(callbacks, 0, newCallbacks, 1, length); try { delegate.handle(newCallbacks); } catch (UnsupportedCallbackException e) { if (e.getCallback() instanceof SSLCallback) { delegate.handle(callbacks); return; } throw e; } }
public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { SSLConnection sslConnection; if (! once.compareAndSet(true, false) || (sslConnection = sslConnectionSupplier.get()) == null) { delegate.handle(callbacks); return; } final int length = callbacks.length; final Callback[] newCallbacks = new Callback[length + 1]; newCallbacks[0] = new SSLCallback(sslConnection); System.arraycopy(callbacks, 0, newCallbacks, 1, length); try { delegate.handle(newCallbacks); } catch (UnsupportedCallbackException e) { if (e.getCallback() instanceof SSLCallback) { delegate.handle(callbacks); return; } throw e; } }
public void handle(final Callback[] callbacks) throws IOException, UnsupportedCallbackException { SSLConnection sslConnection; if (! once.compareAndSet(true, false) || (sslConnection = sslConnectionSupplier.get()) == null) { delegate.handle(callbacks); return; } final int length = callbacks.length; final Callback[] newCallbacks = new Callback[length + 1]; newCallbacks[0] = new SSLCallback(sslConnection); System.arraycopy(callbacks, 0, newCallbacks, 1, length); try { delegate.handle(newCallbacks); } catch (UnsupportedCallbackException e) { if (e.getCallback() instanceof SSLCallback) { delegate.handle(callbacks); return; } throw e; } }
@Override public boolean login() throws LoginException { if (callbackHandler == null) { throw new LoginException("CallbackHandler not registered"); } Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("Username"); callbacks[1] = new PasswordCallback("Password", false); try { callbackHandler.handle(callbacks); } catch (IOException ie) { throw new LoginException("IOException: " + ie.toString()); } catch (UnsupportedCallbackException uce) { throw new LoginException("UnsupportedCallbackException: " + uce.getCallback().toString()); } String username = ((NameCallback)callbacks[0]).getName(); if (options.containsKey(PLAIN_TEXT_USER_PREFIX + username)) { String expectedPassword = (String) options.get(PLAIN_TEXT_USER_PREFIX + username); String password = new String(((PasswordCallback)callbacks[1]).getPassword()); if (!expectedPassword.equals(password)) { throw new LoginException("Incorrect password for: " + username); } } else { throw new LoginException("User: " + username + " not found"); } return true; }
/** * Handle callbacks, wrapping exceptions as needed (including unsupported callbacks). * * @param callbacks the callbacks to handle * @throws SaslException if a callback failed */ protected void handleCallbacks(Callback... callbacks) throws SaslException { try { tryHandleCallbacks(callbacks); } catch (UnsupportedCallbackException e) { throw new SaslException("Callback handler cannot support callback " + e.getCallback().getClass(), e); } }
throw new LoginException(ioe.toString()); } catch (final UnsupportedCallbackException uce) { throw new LoginException("Error: " + uce.getCallback().toString() + " not available to garner authentication information " + "from the user");
throw new LoginException(ioe.toString()); } catch (UnsupportedCallbackException uce) { throw new LoginException("Error: " + uce.getCallback() + " not available to garner authentication information " + "from the user");
throw new LoginException(ioe.toString()); } catch (UnsupportedCallbackException uce) { throw new LoginException("Error: " + uce.getCallback() + " not available to garner authentication information " + "from the user");
delegate.handle(newCallbacks); } catch (UnsupportedCallbackException e) { if (e.getCallback() instanceof SocketAddressCallback) { delegate.handle(callbacks); return;
@Override public boolean login() throws LoginException { // get username and password Callback[] callbacks = new Callback[2]; callbacks[0] = new NameCallback("username"); callbacks[1] = new PasswordCallback("password", false); try { callbackHandler.handle(callbacks); String username = ((NameCallback) callbacks[0]).getName(); char[] tmpPassword = ((PasswordCallback) callbacks[1]).getPassword(); String password = new String(tmpPassword); ((PasswordCallback) callbacks[1]).clearPassword(); Auth auth = doAuth(username, password); if (auth != null) { this.auth = auth; return true; } else { return false; } } catch (UnsupportedCallbackException uce) { getLogger().warn("Error: " + uce.getCallback().toString() + " not available to gather authentication information from the user"); return false; } catch (Exception e) { LoginException le = new LoginException(e.toString()); le.initCause(e); throw le; } }
/** * Method tries to acquire an Impersonator in the following order: * <ul> * <li> Try to access it from the {@link Credentials} via {@link SimpleCredentials#getAttribute(String)}</li> * <li> Ask CallbackHandler for Impersonator with use of {@link ImpersonationCallback}.</li> * </ul> * * @param credentials which, may contain an impersonation Subject * @return impersonation subject or null if non contained * @see #login() * @see #impersonate(java.security.Principal, javax.jcr.Credentials) */ protected Subject getImpersonatorSubject(Credentials credentials) { Subject impersonator = null; if (credentials == null) { try { ImpersonationCallback impers = new ImpersonationCallback(); callbackHandler.handle(new Callback[]{impers}); impersonator = impers.getImpersonator(); } catch (UnsupportedCallbackException e) { log.warn(e.getCallback().getClass().getName() + " not supported: Unable to perform Impersonation."); } catch (IOException e) { log.error("Impersonation-Callback failed: " + e.getMessage() + ": Unable to perform Impersonation."); } } else if (credentials instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials) credentials; impersonator = (Subject) sc.getAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE); } return impersonator; }
/** * Method tries to acquire an Impersonator in the following order: * <ul> * <li> Try to access it from the {@link Credentials} via {@link SimpleCredentials#getAttribute(String)}</li> * <li> Ask CallbackHandler for Impersonator with use of {@link ImpersonationCallback}.</li> * </ul> * * @param credentials which, may contain an impersonation Subject * @return impersonation subject or null if non contained * @see #login() * @see #impersonate(java.security.Principal, javax.jcr.Credentials) */ protected Subject getImpersonatorSubject(Credentials credentials) { Subject impersonator = null; if (credentials == null) { try { ImpersonationCallback impers = new ImpersonationCallback(); callbackHandler.handle(new Callback[]{impers}); impersonator = impers.getImpersonator(); } catch (UnsupportedCallbackException e) { log.warn(e.getCallback().getClass().getName() + " not supported: Unable to perform Impersonation."); } catch (IOException e) { log.error("Impersonation-Callback failed: " + e.getMessage() + ": Unable to perform Impersonation."); } } else if (credentials instanceof SimpleCredentials) { SimpleCredentials sc = (SimpleCredentials) credentials; impersonator = (Subject) sc.getAttribute(SecurityConstants.IMPERSONATOR_ATTRIBUTE); } return impersonator; }
throw le; } catch (UnsupportedCallbackException e) { LoginException le = new LoginException("Error: " + e.getCallback() + ", not available to use this callback."); le.initCause(e); throw le;