Package com.sforce.soap.partner

Examples of com.sforce.soap.partner.LoginResult


    return sfSoap;
  }
 
  private void login(String username, String password, URL url) throws ResourceException {
    if (!isValid()) {
      LoginResult loginResult = null;
      sfSoap = null;
      sfService = null;
      co = new CallOptions();
      // This value identifies Teiid as a SF certified solution.
      // It was provided by SF and should not be changed.
      co.setClient("RedHat/MetaMatrix/"); //$NON-NLS-1$
     
      if(url == null) {
        throw new ResourceException("SalesForce URL is not specified, please provide a valid URL"); //$NON-NLS-1$
      }

      Bus bus = BusFactory.getThreadDefaultBus();
      BusFactory.setThreadDefaultBus(mcf.getBus());
      try {
        sfService = new SforceService();
        sfSoap = sfService.getSoap();
        ((BindingProvider)sfSoap).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, url.toExternalForm());
        loginResult = sfSoap.login(username, password);
      } catch (LoginFault e) {
        throw new ResourceException(e);
      } catch (InvalidIdFault e) {
        throw new ResourceException(e);
      } catch (com.sforce.soap.partner.UnexpectedErrorFault e) {
        throw new ResourceException(e);
      } finally {
        BusFactory.setThreadDefaultBus(bus);
      }
      LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Login was successful for username " + username); //$NON-NLS-1$

      sh = new SessionHeader();
      sh.setSessionId(loginResult.getSessionId());
      // Reset the SOAP endpoint to the returned server URL
      ((BindingProvider)sfSoap).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,loginResult.getServerUrl());
      // or maybe org.apache.cxf.message.Message.ENDPOINT_ADDRESS
      ((BindingProvider)sfSoap).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,Boolean.TRUE);
      // Set the timeout.
      //((BindingProvider)sfSoap).getRequestContext().put(JAXWSProperties.CONNECT_TIMEOUT, timeout);
View Full Code Here


            newBinding.setCallOptions(API_CLIENT_NAME, null);

            logger.info("Logging in as " + bindingConfig.getUsername() + "/" + bindingConfig.getPassword() + " to URL: " + bindingConfig.getAuthEndpoint());
            if (bindingConfig.isManualLogin()) {
                LoginResult loginResult = newBinding.login(bindingConfig.getUsername(), bindingConfig.getPassword());
                // if password has expired, throw an exception
                if (loginResult.getPasswordExpired()) {
                    throw new PasswordExpiredException(Messages.getString("Client.errorExpiredPassword")); //$NON-NLS-1$
                }
                // update session id and service endpoint based on response
                newBinding.setSessionHeader(loginResult.getSessionId());
                bindingConfig.setServiceEndpoint(loginResult.getServerUrl());
            }
            return newBinding;
        } catch (ConnectionException e) {
            // in case of exception try to get a connection again
            if (retries < 3) {
View Full Code Here

    config.setPassword(password);
    config.setAuthEndpoint(END_POINT);
    config.setServiceEndpoint(END_POINT);
    try {
      conn = Connector.newConnection(config);
      LoginResult loginResult = conn.login(username, password);
      if (loginResult.getPasswordExpired()) {
        throw new WormholeException("Error Expired Password",
            JobStatus.CONF_FAILED.getStatus());
      }
      conn.setSessionHeader(loginResult.getSessionId());
    } catch (ConnectionException e) {
      LOG.error("Error Login " + e.getMessage());
      throw new WormholeException("Error Login " + e.getMessage(),
          JobStatus.CONF_FAILED.getStatus());
    }
View Full Code Here

TOP

Related Classes of com.sforce.soap.partner.LoginResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.