@In(required = true) private String username; @In Identity identity; public boolean authenticate() { //... throw new AuthorizationException("login failed"); //... return true; }
@Override public String get() { throw new AuthorizationException(); } }, authException).get();
public Void createOrPropagate(Throwable t) throws Exception { AuthorizationException ex = returnValueOnCodeOrNull(t, new AuthorizationException(t.getMessage(), t), new Predicate<Integer>() { @Override public boolean apply(Integer input) { return input >= 400 && input < 500; } }); throw ex != null ? ex : propagate(t); } }
public Void createOrPropagate(Throwable t) throws Exception { AuthorizationException ex = returnValueOnCodeOrNull(t, new AuthorizationException(t.getMessage(), t), new Predicate<Integer>() { @Override public boolean apply(Integer input) { return input >= 400 && input < 500; } }); throw ex != null ? ex : propagate(t); } }
public Void createOrPropagate(Throwable t) throws Exception { AuthorizationException ex = returnValueOnCodeOrNull(t, new AuthorizationException(t.getMessage(), t), new Predicate<Integer>() { @Override public boolean apply(Integer input) { return input >= 400 && input < 500; } }); throw ex != null ? ex : propagate(t); } }
SshException propagate(Exception e, String message) { message += ": " + e.getMessage(); if (e.getMessage() != null && e.getMessage().indexOf("Auth fail") != -1) throw new AuthorizationException("(" + toString() + ") " + message, e); throw e instanceof SshException ? SshException.class.cast(e) : new SshException( "(" + toString() + ") " + message, e); }
@Override public String get() { throw new RuntimeException(new ExecutionException(new AuthorizationException())); } }, authException).get();
@Provides @Named("exception") Set<String> exception() { throw new AuthorizationException(); }
public String get() { throw new UncheckedExecutionException(new AuthorizationException()); } }, authException).load("KEY");
@VisibleForTesting SshException propagate(Exception e, String message) { message += ": " + e.getMessage(); logger.error(e, "<< " + message); if (e instanceof UserAuthException) throw new AuthorizationException("(" + toString() + ") " + message, e); throw e instanceof SshException ? SshException.class.cast(e) : new SshException( "(" + toString() + ") " + message, e); }
@VisibleForTesting SshException propagate(Exception e, String message) { message += ": " + e.getMessage(); logger.error(e, "<< " + message); if (e instanceof UserAuthException) throw new AuthorizationException("(" + toString() + ") " + message, e); throw e instanceof SshException ? SshException.class.cast(e) : new SshException( "(" + toString() + ") " + message, e); }
@VisibleForTesting SshException propagate(Exception e, String message) { message += ": " + e.getMessage(); logger.error(e, "<< " + message); if (e instanceof UserAuthException) throw new AuthorizationException("(" + toString() + ") " + message, e); throw e instanceof SshException ? SshException.class.cast(e) : new SshException( "(" + toString() + ") " + message, e); }
@VisibleForTesting SshException propagate(Exception e, String message) { message += ": " + e.getMessage(); logger.error(e, "<< " + message); if (e instanceof UserAuthException) throw new AuthorizationException("(" + toString() + ") " + message, e); throw e instanceof SshException ? SshException.class.cast(e) : new SshException( "(" + toString() + ") " + message, e); }
public ListenableFuture<String> apply(String input) { counter.incrementAndGet(); return immediateFailedFuture(new AuthorizationException()); } }, sameThreadExecutor(), null, Logger.NULL, "");
@Test(expectedExceptions = AuthorizationException.class) public void testPropagateStandardExceptionAuthorizationException() throws Throwable { Exception e = new AuthorizationException(); propagateIfPossible(new RuntimeException(e), ImmutableSet.<TypeToken<? extends Throwable>> of()); }
public void testOnlyRetryAuthWhenSetViaProperties() throws UnknownHostException { Properties props = new Properties(); props.setProperty("jclouds.ssh.retry-auth", "true"); JschSshClient ssh1 = createClient(props); assert ssh1.shouldRetry(new AuthorizationException("problem", null)); }
public void testOnlyRetryAuthWhenSet() throws UnknownHostException { JschSshClient ssh1 = createClient(); assert !ssh1.shouldRetry(new AuthorizationException("problem", null)); ssh1.retryAuth = true; assert ssh1.shouldRetry(new AuthorizationException("problem", null)); }
@Test(expectedExceptions = AuthorizationException.class) public void testPropagateProvisionExceptionAuthorizationException() throws Throwable { Exception e = new AuthorizationException(); propagateIfPossible( new ProvisionException(ImmutableSet.of(new Message(ImmutableList.of(), "Error in custom provider", e))), ImmutableSet.<TypeToken<? extends Throwable>> of()); }
@Test(expectedExceptions = AuthorizationException.class) public void testPropagateCreationExceptionAuthorizationException() throws Throwable { Exception e = new AuthorizationException(); propagateIfPossible( new CreationException(ImmutableSet.of(new Message(ImmutableList.of(), "Error in custom provider", e))), ImmutableSet.<TypeToken<? extends Throwable>> of()); }
@Test(expectedExceptions = AuthorizationException.class) public void testPropagateStandardExceptionAuthorizationExceptionNestedInHttpResponseException() throws Throwable { Exception e = new AuthorizationException(); propagateIfPossible(new HttpResponseException("goo", createNiceMock(HttpCommand.class), null, e), ImmutableSet.<TypeToken<? extends Throwable>> of()); }