@Test(expected = LoginFailureException.class) public void testLoginFailure() throws Exception { final Host host = new Host(new B2Protocol(), new B2Protocol().getDefaultHostname(), new Credentials( System.getProperties().getProperty("b2.user"), "s" )); final B2Session session = new B2Session(host, new DefaultX509TrustManager(), new DefaultX509KeyManager()); session.open(Proxy.DIRECT, new DisabledHostKeyCallback(), new DisabledLoginCallback()); session.login(Proxy.DIRECT, new DisabledLoginCallback(), new DisabledCancelCallback()); }
@Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { try { final String accountId = host.getCredentials().getUsername(); final String applicationKey = host.getCredentials().getPassword(); final B2AuthorizeAccountResponse response = client.authenticate(accountId, applicationKey); if(StringUtils.isNotBlank(response.getBucketId())) { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(response.getBucketId()); listService.withBucket(new Path(PathNormalizer.normalize(response.getBucketName()), EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); } retryHandler.setTokens(accountId, applicationKey, response.getAuthorizationToken()); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } }
B2Session extends HttpSession<B2ApiClient> { @Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { try { final String accountId = host.getCredentials().getUsername(); final String applicationKey = host.getCredentials().getPassword(); final B2AuthorizeAccountResponse response = client.authenticate(accountId, applicationKey); if(StringUtils.isNotBlank(response.getBucketId())) { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(response.getBucketId()); listService.withBucket(new Path(PathNormalizer.normalize(response.getBucketName()), EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); } retryHandler.setTokens(accountId, applicationKey, response.getAuthorizationToken()); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } }
B2Session extends HttpSession<B2ApiClient> { @Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { try { final String accountId = host.getCredentials().getUsername(); final String applicationKey = host.getCredentials().getPassword(); final B2AuthorizeAccountResponse response = client.authenticate(accountId, applicationKey); if(StringUtils.isNotBlank(response.getBucketId())) { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(response.getBucketId()); listService.withBucket(new Path(PathNormalizer.normalize(response.getBucketName()), EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); } retryHandler.setTokens(accountId, applicationKey, response.getAuthorizationToken()); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } B2Session(final Host host, final X509TrustManager trust, final X509KeyManager key); }
B2Session extends HttpSession<B2ApiClient> { @Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { try { final String accountId = host.getCredentials().getUsername(); final String applicationKey = host.getCredentials().getPassword(); final B2AuthorizeAccountResponse response = client.authenticate(accountId, applicationKey); if(StringUtils.isNotBlank(response.getBucketId())) { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(response.getBucketId()); listService.withBucket(new Path(PathNormalizer.normalize(response.getBucketName()), EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); } retryHandler.setTokens(accountId, applicationKey, response.getAuthorizationToken()); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } B2Session(final Host host, final X509TrustManager trust, final X509KeyManager key); @Override B2ApiClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt); @Override void logout(); @Override void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel); @Override @SuppressWarnings("unchecked") T _getFeature(final Class<T> type); }
B2Session extends HttpSession<B2ApiClient> { @Override public void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException { try { final String accountId = host.getCredentials().getUsername(); final String applicationKey = host.getCredentials().getPassword(); final B2AuthorizeAccountResponse response = client.authenticate(accountId, applicationKey); if(StringUtils.isNotBlank(response.getBucketId())) { final PathAttributes attributes = new PathAttributes(); attributes.setVersionId(response.getBucketId()); listService.withBucket(new Path(PathNormalizer.normalize(response.getBucketName()), EnumSet.of(Path.Type.directory, Path.Type.volume), attributes)); } retryHandler.setTokens(accountId, applicationKey, response.getAuthorizationToken()); } catch(B2ApiException e) { throw new B2ExceptionMappingService().map(e); } catch(IOException e) { throw new DefaultIOExceptionMappingService().map(e); } } B2Session(final Host host, final X509TrustManager trust, final X509KeyManager key); @Override B2ApiClient connect(final Proxy proxy, final HostKeyCallback key, final LoginCallback prompt); @Override void logout(); @Override void login(final Proxy proxy, final LoginCallback prompt, final CancelCallback cancel); @Override @SuppressWarnings("unchecked") T _getFeature(final Class<T> type);  }