@Test public void testBadPasswordThrowsConnectionException() { String pw = DEFAULT_PASSWORD + "x"; try { this.configurer .loginAndGetBindingConfigData(DEFAULT_USER, pw, partnerBindingCache.getBinding(), this.semaphore, false); fail(); } catch (ApiException e) { assertEquals(ExceptionCode.INVALID___LOGIN, e.getApiFaultCode()); assertEquals("Invalid username, password, security token; or user locked out.", e.getApiFaultMessage()); assertEquals("Bad credentials for user '" + DEFAULT_USER + "'", e.getMessage()); } }
@Nonnull BindingConfig loginAndGetBindingConfigData(@Nonnull String username, @Nonnull String password, @Nonnull Soap binding, @Nonnull CallSemaphore callSemaphore, boolean sandboxOrg) throws ApiException { Login loginParam = new Login(); loginParam.setPassword(password); loginParam.setUsername(username); WSBindingProvider wsBindingProvider = (WSBindingProvider) binding; if (sandboxOrg) { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, SANDBOX_INITIAL_ENDPOINT); } else { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NORMAL_INITIAL_ENDPOINT); } logger.trace("Using initial endpoint: " + wsBindingProvider.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)); CallOptions callOpts = new CallOptions(); callOpts.setClient(this.partnerKey); wsBindingProvider.setOutboundHeaders(Headers.create(this.partnerJaxbContext, callOpts)); this.configureRequestContextConnectionParams(wsBindingProvider); try { callSemaphore.acquire(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw ApiException .getNewWithCause("Interrupted while getting a call token to make the login call", username, e); } Timer.Context context = loginTimer.time(); LoginResponse response; try { response = binding.login(loginParam); } catch (InvalidIdFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Invalid Id", username, e, e.getFaultInfo()); } catch (LoginFault_Exception e) { throw ApiException .getNewWithCauseAndStubApiFault("Bad credentials for user '" + username + "'", username, e, e.getFaultInfo()); } catch (UnexpectedErrorFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Unexpected error", username, e, e.getFaultInfo()); } catch (WebServiceException e) { throw ApiException.getNewWithCause("Web Service exception", username, e); } finally { callSemaphore.release(); context.stop(); } LoginResultType loginResult = response.getResult(); logger.debug("User " + username + " using partner endpoint " + loginResult.getServerUrl()); Id orgId = new Id(loginResult.getUserInfo().getOrganizationId()); String sessionId = loginResult.getSessionId(); return new BindingConfig(orgId, sessionId, loginResult.getServerUrl(), loginResult.getMetadataServerUrl(), username); }
BindingConfigurer { @Nonnull BindingConfig loginAndGetBindingConfigData(@Nonnull String username, @Nonnull String password, @Nonnull Soap binding, @Nonnull CallSemaphore callSemaphore, boolean sandboxOrg) throws ApiException { Login loginParam = new Login(); loginParam.setPassword(password); loginParam.setUsername(username); WSBindingProvider wsBindingProvider = (WSBindingProvider) binding; if (sandboxOrg) { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, SANDBOX_INITIAL_ENDPOINT); } else { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NORMAL_INITIAL_ENDPOINT); } logger.trace("Using initial endpoint: " + wsBindingProvider.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)); CallOptions callOpts = new CallOptions(); callOpts.setClient(this.partnerKey); wsBindingProvider.setOutboundHeaders(Headers.create(this.partnerJaxbContext, callOpts)); this.configureRequestContextConnectionParams(wsBindingProvider); try { callSemaphore.acquire(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw ApiException .getNewWithCause("Interrupted while getting a call token to make the login call", username, e); } Timer.Context context = loginTimer.time(); LoginResponse response; try { response = binding.login(loginParam); } catch (InvalidIdFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Invalid Id", username, e, e.getFaultInfo()); } catch (LoginFault_Exception e) { throw ApiException .getNewWithCauseAndStubApiFault("Bad credentials for user '" + username + "'", username, e, e.getFaultInfo()); } catch (UnexpectedErrorFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Unexpected error", username, e, e.getFaultInfo()); } catch (WebServiceException e) { throw ApiException.getNewWithCause("Web Service exception", username, e); } finally { callSemaphore.release(); context.stop(); } LoginResultType loginResult = response.getResult(); logger.debug("User " + username + " using partner endpoint " + loginResult.getServerUrl()); Id orgId = new Id(loginResult.getUserInfo().getOrganizationId()); String sessionId = loginResult.getSessionId(); return new BindingConfig(orgId, sessionId, loginResult.getServerUrl(), loginResult.getMetadataServerUrl(), username); } }
BindingConfigurer { @Nonnull BindingConfig loginAndGetBindingConfigData(@Nonnull String username, @Nonnull String password, @Nonnull Soap binding, @Nonnull CallSemaphore callSemaphore, boolean sandboxOrg) throws ApiException { Login loginParam = new Login(); loginParam.setPassword(password); loginParam.setUsername(username); WSBindingProvider wsBindingProvider = (WSBindingProvider) binding; if (sandboxOrg) { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, SANDBOX_INITIAL_ENDPOINT); } else { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NORMAL_INITIAL_ENDPOINT); } logger.trace("Using initial endpoint: " + wsBindingProvider.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)); CallOptions callOpts = new CallOptions(); callOpts.setClient(this.partnerKey); wsBindingProvider.setOutboundHeaders(Headers.create(this.partnerJaxbContext, callOpts)); this.configureRequestContextConnectionParams(wsBindingProvider); try { callSemaphore.acquire(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw ApiException .getNewWithCause("Interrupted while getting a call token to make the login call", username, e); } Timer.Context context = loginTimer.time(); LoginResponse response; try { response = binding.login(loginParam); } catch (InvalidIdFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Invalid Id", username, e, e.getFaultInfo()); } catch (LoginFault_Exception e) { throw ApiException .getNewWithCauseAndStubApiFault("Bad credentials for user '" + username + "'", username, e, e.getFaultInfo()); } catch (UnexpectedErrorFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Unexpected error", username, e, e.getFaultInfo()); } catch (WebServiceException e) { throw ApiException.getNewWithCause("Web Service exception", username, e); } finally { callSemaphore.release(); context.stop(); } LoginResultType loginResult = response.getResult(); logger.debug("User " + username + " using partner endpoint " + loginResult.getServerUrl()); Id orgId = new Id(loginResult.getUserInfo().getOrganizationId()); String sessionId = loginResult.getSessionId(); return new BindingConfig(orgId, sessionId, loginResult.getServerUrl(), loginResult.getMetadataServerUrl(), username); } BindingConfigurer(@Nonnull String partnerKey, MetricRegistry metricRegistry); }
BindingConfigurer { @Nonnull BindingConfig loginAndGetBindingConfigData(@Nonnull String username, @Nonnull String password, @Nonnull Soap binding, @Nonnull CallSemaphore callSemaphore, boolean sandboxOrg) throws ApiException { Login loginParam = new Login(); loginParam.setPassword(password); loginParam.setUsername(username); WSBindingProvider wsBindingProvider = (WSBindingProvider) binding; if (sandboxOrg) { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, SANDBOX_INITIAL_ENDPOINT); } else { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NORMAL_INITIAL_ENDPOINT); } logger.trace("Using initial endpoint: " + wsBindingProvider.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)); CallOptions callOpts = new CallOptions(); callOpts.setClient(this.partnerKey); wsBindingProvider.setOutboundHeaders(Headers.create(this.partnerJaxbContext, callOpts)); this.configureRequestContextConnectionParams(wsBindingProvider); try { callSemaphore.acquire(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw ApiException .getNewWithCause("Interrupted while getting a call token to make the login call", username, e); } Timer.Context context = loginTimer.time(); LoginResponse response; try { response = binding.login(loginParam); } catch (InvalidIdFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Invalid Id", username, e, e.getFaultInfo()); } catch (LoginFault_Exception e) { throw ApiException .getNewWithCauseAndStubApiFault("Bad credentials for user '" + username + "'", username, e, e.getFaultInfo()); } catch (UnexpectedErrorFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Unexpected error", username, e, e.getFaultInfo()); } catch (WebServiceException e) { throw ApiException.getNewWithCause("Web Service exception", username, e); } finally { callSemaphore.release(); context.stop(); } LoginResultType loginResult = response.getResult(); logger.debug("User " + username + " using partner endpoint " + loginResult.getServerUrl()); Id orgId = new Id(loginResult.getUserInfo().getOrganizationId()); String sessionId = loginResult.getSessionId(); return new BindingConfig(orgId, sessionId, loginResult.getServerUrl(), loginResult.getMetadataServerUrl(), username); } BindingConfigurer(@Nonnull String partnerKey, MetricRegistry metricRegistry);  }
BindingConfigurer { @Nonnull BindingConfig loginAndGetBindingConfigData(@Nonnull String username, @Nonnull String password, @Nonnull Soap binding, @Nonnull CallSemaphore callSemaphore, boolean sandboxOrg) throws ApiException { Login loginParam = new Login(); loginParam.setPassword(password); loginParam.setUsername(username); WSBindingProvider wsBindingProvider = (WSBindingProvider) binding; if (sandboxOrg) { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, SANDBOX_INITIAL_ENDPOINT); } else { wsBindingProvider.getRequestContext() .put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, NORMAL_INITIAL_ENDPOINT); } logger.trace("Using initial endpoint: " + wsBindingProvider.getRequestContext().get(BindingProvider.ENDPOINT_ADDRESS_PROPERTY)); CallOptions callOpts = new CallOptions(); callOpts.setClient(this.partnerKey); wsBindingProvider.setOutboundHeaders(Headers.create(this.partnerJaxbContext, callOpts)); this.configureRequestContextConnectionParams(wsBindingProvider); try { callSemaphore.acquire(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); throw ApiException .getNewWithCause("Interrupted while getting a call token to make the login call", username, e); } Timer.Context context = loginTimer.time(); LoginResponse response; try { response = binding.login(loginParam); } catch (InvalidIdFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Invalid Id", username, e, e.getFaultInfo()); } catch (LoginFault_Exception e) { throw ApiException .getNewWithCauseAndStubApiFault("Bad credentials for user '" + username + "'", username, e, e.getFaultInfo()); } catch (UnexpectedErrorFault_Exception e) { throw ApiException.getNewWithCauseAndStubApiFault("Unexpected error", username, e, e.getFaultInfo()); } catch (WebServiceException e) { throw ApiException.getNewWithCause("Web Service exception", username, e); } finally { callSemaphore.release(); context.stop(); } LoginResultType loginResult = response.getResult(); logger.debug("User " + username + " using partner endpoint " + loginResult.getServerUrl()); Id orgId = new Id(loginResult.getUserInfo().getOrganizationId()); String sessionId = loginResult.getSessionId(); return new BindingConfig(orgId, sessionId, loginResult.getServerUrl(), loginResult.getMetadataServerUrl(), username); } BindingConfigurer(@Nonnull String partnerKey, MetricRegistry metricRegistry);   }