@Override public BackgroundException map(final TokenResponseException failure) { final StringBuilder buffer = new StringBuilder(); final TokenErrorResponse details = failure.getDetails(); if(null != details) { this.append(buffer, details.getErrorDescription()); } return new LoginFailureException(buffer.toString(), failure); } }
private <T> T authenticated(final Authenticated<T> run, final LoginCallback prompt) throws BackgroundException { final LoginOptions options = new LoginOptions(bookmark.getProtocol()); try { final LoginService login = new KeychainLoginService(PasswordStoreFactory.get()); login.validate(bookmark, LocaleFactory.localizedString("AWS Identity and Access Management", "S3"), prompt, options); return run.call(); } catch(LoginFailureException failure) { bookmark.setCredentials(prompt.prompt(bookmark, bookmark.getCredentials().getUsername(), LocaleFactory.localizedString("Login failed", "Credentials"), failure.getMessage(), options)); return this.authenticated(run, prompt); } }
LocaleFactory.localizedString("Login failed", "Credentials"), e.getDetail(), options); credentials.setUsername(input.getUsername()); credentials.setPassword(input.getPassword()); final StringAppender details = new StringAppender(); details.append(LocaleFactory.localizedString("Login failed", "Credentials")); details.append(e.getDetail()); this.prompt(bookmark, details.toString(), prompt, options);
private <T> T authenticated(final Authenticated<T> run, final LoginCallback prompt) throws BackgroundException { final LoginOptions options = new LoginOptions(bookmark.getProtocol()); try { final LoginService login = new KeychainLoginService(PasswordStoreFactory.get()); login.validate(bookmark, LocaleFactory.localizedString("AWS Key Management Service", "S3"), prompt, options); return run.call(); } catch(LoginFailureException failure) { bookmark.setCredentials(prompt.prompt(bookmark, bookmark.getCredentials().getUsername(), LocaleFactory.localizedString("Login failed", "Credentials"), failure.getMessage(), options)); return this.authenticated(run, prompt); } }
final StringAppender details = new StringAppender(); details.append(LocaleFactory.localizedString("Login failed", "Credentials")); details.append(e.getDetail()); service.prompt(bookmark, details.toString(), login, new LoginOptions(bookmark.getProtocol()));
@Override public BackgroundException map(final JargonException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(e instanceof CatNoAccessException) { return new AccessDeniedException(buffer.toString(), e); } if(e instanceof FileNotFoundException) { return new NotfoundException(buffer.toString(), e); } if(e instanceof DataNotFoundException) { return new NotfoundException(buffer.toString(), e); } if(e instanceof AuthenticationException) { return new LoginFailureException(buffer.toString(), e); } if(e instanceof InvalidUserException) { return new LoginFailureException(buffer.toString(), e); } if(e instanceof InvalidGroupException) { return new LoginFailureException(buffer.toString(), e); } return this.wrap(e, buffer); } }
private <T> T authenticated(final Authenticated<T> run, final LoginCallback prompt) throws BackgroundException { final LoginOptions options = new LoginOptions(bookmark.getProtocol()) .usernamePlaceholder(LocaleFactory.localizedString("Access Key ID", "S3")) .passwordPlaceholder(LocaleFactory.localizedString("Secret Access Key", "S3")); try { final LoginService login = new KeychainLoginService(PasswordStoreFactory.get()); login.validate(bookmark, LocaleFactory.localizedString("Amazon CloudFront", "S3"), prompt, options); return run.call(); } catch(LoginFailureException failure) { bookmark.setCredentials(prompt.prompt(bookmark, bookmark.getCredentials().getUsername(), LocaleFactory.localizedString("Login failed", "Credentials"), failure.getMessage(), options)); return this.authenticated(run, prompt); } }
return new AccessDeniedException(buffer.toString(), e); case "UnrecognizedClientException": return new LoginFailureException(buffer.toString(), e); return new LoginFailureException(buffer.toString(), e); case "InvalidAccessKeyId": return new LoginFailureException(buffer.toString(), e); case "InvalidClientTokenId": return new LoginFailureException(buffer.toString(), e); case "InvalidSecurity": return new LoginFailureException(buffer.toString(), e); case "MissingClientTokenId": return new LoginFailureException(buffer.toString(), e); case "MissingAuthenticationToken": return new LoginFailureException(buffer.toString(), e);
private BackgroundException handle(final FTPException e, final StringBuilder buffer) { final int status = e.getCode(); switch(status) { case FTPReply.INSUFFICIENT_STORAGE: case FTPReply.STORAGE_ALLOCATION_EXCEEDED: return new QuotaException(buffer.toString(), e); case FTPReply.NOT_LOGGED_IN: return new LoginFailureException(buffer.toString(), e); case FTPReply.FAILED_SECURITY_CHECK: case FTPReply.DENIED_FOR_POLICY_REASONS: case FTPReply.NEED_ACCOUNT: case FTPReply.NEED_ACCOUNT_FOR_STORING_FILES: case FTPReply.FILE_NAME_NOT_ALLOWED: case FTPReply.FILE_ACTION_NOT_TAKEN: case FTPReply.ACTION_ABORTED: return new AccessDeniedException(buffer.toString(), e); case FTPReply.UNAVAILABLE_RESOURCE: case FTPReply.FILE_UNAVAILABLE: // Requested action not taken. File unavailable (e.g., file not found, no access) return new NotfoundException(buffer.toString(), e); case FTPReply.SERVICE_NOT_AVAILABLE: return new ConnectionRefusedException(buffer.toString(), e); } return new InteroperabilityException(buffer.toString(), e); } }
@Override public BackgroundException map(final GenericException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); final StatusLine status = e.getHttpStatusLine(); if(null != status) { this.append(buffer, String.format("%d %s", status.getStatusCode(), status.getReasonPhrase())); } switch(e.getHttpStatusCode()) { case HttpStatus.SC_BAD_REQUEST: return new LoginFailureException(buffer.toString(), e); } return new HttpResponseExceptionMappingService().map(new HttpResponseException(e.getHttpStatusCode(), buffer.toString())); } }
switch(e.getError().getCode()) { case "SignatureDoesNotMatch": return new LoginFailureException(buffer.toString(), e); case "InvalidAccessKeyId": return new LoginFailureException(buffer.toString(), e); case "InvalidClientTokenId": return new LoginFailureException(buffer.toString(), e); case "InvalidSecurity": return new LoginFailureException(buffer.toString(), e); case "MissingClientTokenId": return new LoginFailureException(buffer.toString(), e); case "MissingAuthenticationToken": return new LoginFailureException(buffer.toString(), e);
public BackgroundException map(final Throwable failure, final StringBuilder buffer, final int statusCode) { switch(statusCode) { case HttpStatus.SC_UNAUTHORIZED: return new LoginFailureException(buffer.toString(), failure); case HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED: return new ProxyLoginFailureException(buffer.toString(), failure);
@Override public BackgroundException map(final MantaClientHttpResponseException failure) { switch(failure.getStatusCode()) { case 403: final StringBuilder buffer = new StringBuilder(); this.append(buffer, failure.getStatusMessage()); return new LoginFailureException(buffer.toString(), failure); } return new HttpResponseExceptionMappingService().map(new HttpResponseException(failure.getStatusCode(), failure.getStatusMessage())); } }
public BackgroundException map(final IOException e, final StringBuilder buffer, final DisconnectReason reason) { final String failure = buffer.toString(); if(DisconnectReason.HOST_KEY_NOT_VERIFIABLE.equals(reason)) { log.warn(String.format("Failure verifying host key. %s", failure)); // Host key dismissed by user return new ConnectionCanceledException(e); } if(DisconnectReason.PROTOCOL_ERROR.equals(reason)) { // Too many authentication failures return new InteroperabilityException(failure, e); } if(DisconnectReason.ILLEGAL_USER_NAME.equals(reason)) { return new LoginFailureException(failure, e); } if(DisconnectReason.NO_MORE_AUTH_METHODS_AVAILABLE.equals(reason)) { return new LoginFailureException(failure, e); } if(DisconnectReason.PROTOCOL_VERSION_NOT_SUPPORTED.equals(reason)) { return new InteroperabilityException(failure, e); } if(e instanceof TransportException) { return new ConnectionRefusedException(buffer.toString(), e); } return this.wrap(e, buffer); } }
@Override public BackgroundException map(final StorageException e) { final StringBuilder buffer = new StringBuilder(); this.append(buffer, e.getMessage()); if(ExceptionUtils.getRootCause(e) instanceof UnknownHostException) { return new NotfoundException(buffer.toString(), e); } switch(e.getHttpStatusCode()) { case 403: return new LoginFailureException(buffer.toString(), e); case 404: return new NotfoundException(buffer.toString(), e); case 304: case 405: case 400: case 411: case 412: return new InteroperabilityException(buffer.toString(), e); case 500: // InternalError // OperationTimedOut return new ConnectionTimeoutException(buffer.toString(), e); case 503: // ServerBusy return new RetriableAccessDeniedException(buffer.toString(), e); } return this.wrap(e, buffer); } }
return new LoginFailureException(buffer.toString(), e);
return new LoginFailureException(buffer.toString(), failure);
throw new LoginFailureException(e.getDetail(false), e); throw new LoginFailureException(e.getDetail(false), e); throw new LoginFailureException(MessageFormat.format(LocaleFactory.localizedString( "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(host)));
@Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { try { final IRODSAccount account = client.getIRODSAccount(); final Credentials credentials = host.getCredentials(); account.setUserName(credentials.getUsername()); account.setPassword(credentials.getPassword()); final AuthResponse response = client.getIRODSAccessObjectFactory().authenticateIRODSAccount(account); if(log.isDebugEnabled()) { log.debug(String.format("Connected to %s", response.getStartupResponse())); } if(!response.isSuccessful()) { throw new LoginFailureException(MessageFormat.format(LocaleFactory.localizedString( "Login {0} with username and password", "Credentials"), BookmarkNameProvider.toString(host))); } } catch(JargonException e) { throw new IRODSExceptionMappingService().map(e); } }
throw new LoginFailureException(e.getMessage(), e);