private String passwordAlgorithm(final String mechanismName) { switch (mechanismName) { case SaslMechanismInformation.Names.DIGEST_SHA: return DigestPassword.ALGORITHM_DIGEST_SHA; case SaslMechanismInformation.Names.DIGEST_SHA_256: return DigestPassword.ALGORITHM_DIGEST_SHA_256; case SaslMechanismInformation.Names.DIGEST_SHA_384: return DigestPassword.ALGORITHM_DIGEST_SHA_384; case SaslMechanismInformation.Names.DIGEST_SHA_512: return DigestPassword.ALGORITHM_DIGEST_SHA_512; case SaslMechanismInformation.Names.DIGEST_SHA_512_256: return DigestPassword.ALGORITHM_DIGEST_SHA_512_256; case SaslMechanismInformation.Names.DIGEST_MD5: return DigestPassword.ALGORITHM_DIGEST_MD5; default: throw Assert.impossibleSwitchCase(mechanismName); } }
private String getAction(final int bit) { switch (bit) { case ACTION_BIND: return "bind"; case ACTION_REBIND: return "rebind"; case ACTION_UNBIND: return "unbind"; case ACTION_LOOKUP: return "lookup"; case ACTION_LIST: return "list"; case ACTION_LIST_BINDINGS: return "listBindings"; case ACTION_CREATE_SUBCONTEXT: return "createSubcontext"; case ACTION_DESTROY_SUBCONTEXT: return "destroySubcontext"; case ACTION_ADD_NAMING_LISTENER: return "addNamingListener"; default: throw Assert.impossibleSwitchCase(bit); } } }
@Override public synchronized Object get() throws InterruptedException, ExecutionException { for (;;) switch (status) { case ST_RUNNING: wait(); break; case ST_CANCELLED: throw EjbLogger.ROOT_LOGGER.taskWasCancelled(); case ST_FAILED: throw new ExecutionException(failed); case ST_DONE: return result; default: throw Assert.impossibleSwitchCase(status); } }
void addDependent(Dependency task) { synchronized (lock) { switch (state) { case WAITING: case RUNNING: runner.dependents.add(task); return; case FAILED: return; case DONE: break; // fall out of lock default: throw Assert.impossibleSwitchCase(state); } } task.dependencyFinished(); }
void join(final AtomicReference<State> stateRef, final URI location, final SimpleTransactionControl control) throws IllegalStateException { State newState; switch (status) { case Status.STATUS_ACTIVE: newState = new Active(location, control); break; case Status.STATUS_MARKED_ROLLBACK: newState = new RollbackOnly(location, control); break; default: throw Assert.impossibleSwitchCase(status); } if (stateRef.compareAndSet(this, newState)) { return; } else { stateRef.get().join(stateRef, location, control); } }
/** {@inheritDoc} */ @SuppressWarnings({ "unchecked" }) public final T get() throws InterruptedException, ExecutionException { synchronized (AsyncFutureTask.this) { final Status status = await(); switch (status) { case CANCELLED: throw Messages.msg.operationCancelled(); case FAILED: throw Messages.msg.operationFailed((Throwable) result); case COMPLETE: return (T) result; default: throw Assert.impossibleSwitchCase(status); } } }
/** {@inheritDoc} */ @SuppressWarnings({ "unchecked" }) public final T getUninterruptibly() throws CancellationException, ExecutionException { synchronized (AsyncFutureTask.this) { final Status status = awaitUninterruptibly(); switch (status) { case CANCELLED: throw Messages.msg.operationCancelled(); case FAILED: throw Messages.msg.operationFailed((Throwable) result); case COMPLETE: return (T) result; default: throw Assert.impossibleSwitchCase(status); } } }
/** {@inheritDoc} */ @SuppressWarnings({ "unchecked" }) public final T get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { synchronized (AsyncFutureTask.this) { final Status status = await(timeout, unit); switch (status) { case CANCELLED: throw Messages.msg.operationCancelled(); case FAILED: throw Messages.msg.operationFailed((Throwable) result); case COMPLETE: return (T) result; case WAITING: throw Messages.msg.operationTimedOut(); default: throw Assert.impossibleSwitchCase(status); } } }
/** {@inheritDoc} */ @SuppressWarnings({ "unchecked" }) public final T getUninterruptibly(final long timeout, final TimeUnit unit) throws CancellationException, ExecutionException, TimeoutException { synchronized (AsyncFutureTask.this) { final Status status = awaitUninterruptibly(timeout, unit); switch (status) { case CANCELLED: throw Messages.msg.operationCancelled(); case FAILED: throw Messages.msg.operationFailed((Throwable) result); case COMPLETE: return (T) result; case WAITING: throw Messages.msg.operationTimedOut(); default: throw Assert.impossibleSwitchCase(status); } } }
@Override protected byte[] evaluateMessage(int state, final byte[] message) throws SaslException { switch (state) { case INITIAL_STATE: int length = message.length; if (length == 0) { // need initial challenge return NO_BYTES; } else { // sanity check if (length > 1020) { throw saslAnonymous.mechAuthenticationNameTooLong().toSaslException(); } String name = new String(message, StandardCharsets.UTF_8); if (name.length() > 255) { throw saslAnonymous.mechAuthenticationNameTooLong().toSaslException(); } final AnonymousAuthorizationCallback callback = new AnonymousAuthorizationCallback(name); handleCallbacks(callback); if (! callback.isAuthorized()) { throw saslAnonymous.mechAnonymousAuthorizationDenied().toSaslException(); } negotiationComplete(); return null; } } throw Assert.impossibleSwitchCase(state); } }
return b.toArray(); throw Assert.impossibleSwitchCase(state);
@Override protected byte[] evaluateMessage(int state, final byte[] message) throws SaslException { HashMap<String, byte[]> parsedChallenge; try { parsedChallenge = parseResponse(message, charset, true, saslDigest); } catch (AuthenticationMechanismException e) { throw e.toSaslException(); } while(true) { switch (state) { case STEP_TWO: noteChallengeData(parsedChallenge); setNegotiationState(STEP_FOUR); return createResponse(parsedChallenge); case STEP_FOUR: if (parsedChallenge.containsKey("nonce")) { saslDigest.trace("Server requested re-authentication"); state = STEP_TWO; continue; } checkResponseAuth(parsedChallenge); negotiationComplete(); return null; } throw Assert.impossibleSwitchCase(state); } } }
return getNullReference(); default: throw Assert.impossibleSwitchCase(type);
return getNullReference(); default: throw Assert.impossibleSwitchCase(type);
return getNullReference(); default: throw Assert.impossibleSwitchCase(type);
throw Assert.impossibleSwitchCase(state); } catch (AuthenticationMechanismException e) { throw e.toSaslException();
@Override protected byte[] evaluateMessage(int state, final byte[] message) throws SaslException { switch (state) { case STEP_ONE: if (message != null && message.length != 0) { throw saslDigest.mechInitialChallengeMustBeEmpty().toSaslException(); } setNegotiationState(STEP_THREE); return generateChallenge(); case STEP_THREE: if (message == null || message.length == 0) { throw saslDigest.mechClientRefusesToInitiateAuthentication().toSaslException(); } // parse digest response HashMap<String, byte[]> parsedDigestResponse; try { parsedDigestResponse = parseResponse(message, charset, false, saslDigest); } catch (AuthenticationMechanismException e) { throw e.toSaslException(); } noteDigestResponseData(parsedDigestResponse); // validate byte[] response = validateDigestResponse(parsedDigestResponse); negotiationComplete(); return response; } throw Assert.impossibleSwitchCase(state); }
throw Assert.impossibleSwitchCase(state); } catch (AuthenticationMechanismException e) { throw e.toSaslException();
throw Assert.impossibleSwitchCase(state); } catch (AuthenticationMechanismException e) { throw e.toSaslException();
throw Assert.impossibleSwitchCase(state);