Search in sources :

Example 1 with Passport

use of com.netsuite.webservices.v2016_2.platform.core.Passport in project components by Talend.

the class NetSuiteClientServiceImpl method doLogin.

@Override
protected void doLogin() throws NetSuiteException {
    port = getNetSuitePort(endpointUrl, credentials.getAccount());
    setHttpClientPolicy(port);
    setLoginHeaders(port);
    PortOperation<SessionResponse, NetSuitePortType> loginOp;
    if (!credentials.isUseSsoLogin()) {
        final Passport passport = createNativePassport(credentials);
        loginOp = new PortOperation<SessionResponse, NetSuitePortType>() {

            @Override
            public SessionResponse execute(NetSuitePortType port) throws Exception {
                LoginRequest request = new LoginRequest();
                request.setPassport(passport);
                LoginResponse response = port.login(request);
                return response.getSessionResponse();
            }
        };
    } else {
        throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.ssoLoginNotSupported"));
    }
    Status status = null;
    SessionResponse sessionResponse;
    String exceptionMessage = null;
    for (int i = 0; i < getRetryCount(); i++) {
        try {
            sessionResponse = loginOp.execute(port);
            status = sessionResponse.getStatus();
        } catch (InvalidCredentialsFault f) {
            throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), f.getFaultInfo().getMessage());
        } catch (UnexpectedErrorFault f) {
            exceptionMessage = f.getFaultInfo().getMessage();
        } catch (Exception e) {
            exceptionMessage = e.getMessage();
        }
        if (status != null) {
            break;
        }
        if (i != getRetryCount() - 1) {
            waitForRetryInterval();
        }
    }
    checkLoginError(toNsStatus(status), exceptionMessage);
    removeLoginHeaders(port);
}
Also used : Status(com.netsuite.webservices.v2016_2.platform.core.Status) NsStatus(org.talend.components.netsuite.client.NsStatus) InvalidCredentialsFault(com.netsuite.webservices.v2016_2.platform.InvalidCredentialsFault) LoginResponse(com.netsuite.webservices.v2016_2.platform.messages.LoginResponse) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) UnexpectedErrorFault(com.netsuite.webservices.v2016_2.platform.UnexpectedErrorFault) LoginRequest(com.netsuite.webservices.v2016_2.platform.messages.LoginRequest) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SocketException(java.net.SocketException) MalformedURLException(java.net.MalformedURLException) WebServiceException(javax.xml.ws.WebServiceException) NetSuitePortType(com.netsuite.webservices.v2016_2.platform.NetSuitePortType) NetSuiteErrorCode(org.talend.components.netsuite.NetSuiteErrorCode) Passport(com.netsuite.webservices.v2016_2.platform.core.Passport) SessionResponse(com.netsuite.webservices.v2016_2.platform.messages.SessionResponse)

Example 2 with Passport

use of com.netsuite.webservices.v2016_2.platform.core.Passport in project components by Talend.

the class NetSuiteClientServiceImpl method createNativePassport.

@Override
protected Passport createNativePassport(NetSuiteCredentials nsCredentials) {
    RecordRef roleRecord = new RecordRef();
    roleRecord.setInternalId(nsCredentials.getRoleId());
    final Passport passport = new Passport();
    passport.setEmail(nsCredentials.getEmail());
    passport.setPassword(nsCredentials.getPassword());
    passport.setRole(roleRecord);
    passport.setAccount(nsCredentials.getAccount());
    return passport;
}
Also used : Passport(com.netsuite.webservices.v2016_2.platform.core.Passport) RecordRef(com.netsuite.webservices.v2016_2.platform.core.RecordRef)

Example 3 with Passport

use of com.netsuite.webservices.v2016_2.platform.core.Passport in project components by Talend.

the class NetSuiteClientServiceImpl method createNativePassport.

@Override
protected Passport createNativePassport(NetSuiteCredentials nsCredentials) {
    RecordRef roleRecord = new RecordRef();
    roleRecord.setInternalId(nsCredentials.getRoleId());
    final Passport passport = new Passport();
    passport.setEmail(nsCredentials.getEmail());
    passport.setPassword(nsCredentials.getPassword());
    passport.setRole(roleRecord);
    passport.setAccount(nsCredentials.getAccount());
    return passport;
}
Also used : Passport(com.netsuite.webservices.v2014_2.platform.core.Passport) RecordRef(com.netsuite.webservices.v2014_2.platform.core.RecordRef)

Example 4 with Passport

use of com.netsuite.webservices.v2016_2.platform.core.Passport in project components by Talend.

the class NetSuiteClientServiceImpl method doLogin.

protected void doLogin() throws NetSuiteException {
    port = getNetSuitePort(endpointUrl, credentials.getAccount());
    setHttpClientPolicy(port);
    setLoginHeaders(port);
    PortOperation<SessionResponse, NetSuitePortType> loginOp;
    if (!credentials.isUseSsoLogin()) {
        final Passport passport = createNativePassport(credentials);
        loginOp = new PortOperation<SessionResponse, NetSuitePortType>() {

            @Override
            public SessionResponse execute(NetSuitePortType port) throws Exception {
                LoginRequest request = new LoginRequest();
                request.setPassport(passport);
                LoginResponse response = port.login(request);
                return response.getSessionResponse();
            }
        };
    } else {
        throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), NetSuiteRuntimeI18n.MESSAGES.getMessage("error.ssoLoginNotSupported"));
    }
    Status status = null;
    SessionResponse sessionResponse;
    String exceptionMessage = null;
    for (int i = 0; i < getRetryCount(); i++) {
        try {
            sessionResponse = loginOp.execute(port);
            status = sessionResponse.getStatus();
        } catch (InvalidCredentialsFault f) {
            throw new NetSuiteException(new NetSuiteErrorCode(NetSuiteErrorCode.CLIENT_ERROR), f.getFaultInfo().getMessage());
        } catch (UnexpectedErrorFault f) {
            exceptionMessage = f.getFaultInfo().getMessage();
        } catch (Exception e) {
            exceptionMessage = e.getMessage();
        }
        if (status != null) {
            break;
        }
        if (i != getRetryCount() - 1) {
            waitForRetryInterval();
        }
    }
    checkLoginError(toNsStatus(status), exceptionMessage);
    removeLoginHeaders(port);
}
Also used : Status(com.netsuite.webservices.v2014_2.platform.core.Status) NsStatus(org.talend.components.netsuite.client.NsStatus) InvalidCredentialsFault(com.netsuite.webservices.v2014_2.platform.InvalidCredentialsFault) LoginResponse(com.netsuite.webservices.v2014_2.platform.messages.LoginResponse) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) UnexpectedErrorFault(com.netsuite.webservices.v2014_2.platform.UnexpectedErrorFault) LoginRequest(com.netsuite.webservices.v2014_2.platform.messages.LoginRequest) NetSuiteException(org.talend.components.netsuite.client.NetSuiteException) InvocationTargetException(java.lang.reflect.InvocationTargetException) RemoteException(java.rmi.RemoteException) SOAPFaultException(javax.xml.ws.soap.SOAPFaultException) SocketException(java.net.SocketException) MalformedURLException(java.net.MalformedURLException) WebServiceException(javax.xml.ws.WebServiceException) NetSuitePortType(com.netsuite.webservices.v2014_2.platform.NetSuitePortType) NetSuiteErrorCode(org.talend.components.netsuite.NetSuiteErrorCode) Passport(com.netsuite.webservices.v2014_2.platform.core.Passport) SessionResponse(com.netsuite.webservices.v2014_2.platform.messages.SessionResponse)

Aggregations

Passport (com.netsuite.webservices.v2014_2.platform.core.Passport)2 Passport (com.netsuite.webservices.v2016_2.platform.core.Passport)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 MalformedURLException (java.net.MalformedURLException)2 SocketException (java.net.SocketException)2 RemoteException (java.rmi.RemoteException)2 WebServiceException (javax.xml.ws.WebServiceException)2 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)2 NetSuiteErrorCode (org.talend.components.netsuite.NetSuiteErrorCode)2 NetSuiteException (org.talend.components.netsuite.client.NetSuiteException)2 NsStatus (org.talend.components.netsuite.client.NsStatus)2 InvalidCredentialsFault (com.netsuite.webservices.v2014_2.platform.InvalidCredentialsFault)1 NetSuitePortType (com.netsuite.webservices.v2014_2.platform.NetSuitePortType)1 UnexpectedErrorFault (com.netsuite.webservices.v2014_2.platform.UnexpectedErrorFault)1 RecordRef (com.netsuite.webservices.v2014_2.platform.core.RecordRef)1 Status (com.netsuite.webservices.v2014_2.platform.core.Status)1 LoginRequest (com.netsuite.webservices.v2014_2.platform.messages.LoginRequest)1 LoginResponse (com.netsuite.webservices.v2014_2.platform.messages.LoginResponse)1 SessionResponse (com.netsuite.webservices.v2014_2.platform.messages.SessionResponse)1 InvalidCredentialsFault (com.netsuite.webservices.v2016_2.platform.InvalidCredentialsFault)1