final boolean autenticate(String user, String password) throws ServiceException, NotSignedException {
LOGGER.debug("autenticate:"+user); //$NON-NLS-1$
checkCanConnectServer();
if(user != null && user.length()==0 && password != null && password.length()==0) {
throw new NotSignedException(Messages.getString("services.bad.account.info")); //$NON-NLS-1$
}
Authentification auth = null;
try {
SimpleMonitor.startTask("autenticate"); //$NON-NLS-1$
//always log into master server
LOGGER.debug("autenticate calling server"); //$NON-NLS-1$
auth = _serverServicesProvider.getAuthentificationService().authenticate(user, password, System.getProperty(PLUGIN_VERSION, "not set"));
LOGGER.debug("autenticate server respond:"+auth); //$NON-NLS-1$
} catch (ServiceNotAvailableException e) {
LOGGER.error("ServiceNotAvailableException:"+e); //$NON-NLS-1$
setServerNotAvailable();
resetLoginInfos();
throw e;
} catch (ServiceException e) {
LOGGER.error("ServiceException:"+e); //$NON-NLS-1$
resetLoginInfos();
throw e;
} finally {
SimpleMonitor.endTask("autenticate"); //$NON-NLS-1$
}
if(auth == null) {
resetLoginInfos();
} else {
if (auth instanceof AuthSuccessfull) {
LOGGER.debug("AuthSuccessfull:"+auth); //$NON-NLS-1$
AuthSuccessfull success = (AuthSuccessfull) auth;
_serverVersion = (String) success.getExtraParameter(Authentification.SERVER_VERSION);
_serverConfiguration = success.getExtraParameters();
setExpirationDate(success.getLicenceExpirationDate());
return true;
} else if (auth instanceof AuthFailed) {
LOGGER.debug("AuthFailed:"+auth); //$NON-NLS-1$
AuthFailed failed = (AuthFailed) auth;
_serverVersion = (String) failed.getExtraParameter(Authentification.SERVER_VERSION);
resetLoginInfos();
switch (failed.getReasonCode()) {
case AuthFailed.BAD_AUTHENTIFICATION_INFO:
throw new NotSignedException(Messages.getString("services.error.badlogin"), failed.getReasonCode()); //$NON-NLS-1$
case AuthFailed.LICENCE_EXPIRED:
throw new NotSignedException(Messages.getString("services.error.licenseexpired"), failed.getReasonCode()); //$NON-NLS-1$
case AuthFailed.SERVER_UNDER_MAINTENANCE:
throw new NotSignedException(Messages.getString("services.error.servernotreachable"), failed.getReasonCode()); //$NON-NLS-1$
case AuthFailed.ACCOUNT_BLOCKED:
throw new NotSignedException(Messages.getString("services.error.account.suspended")+"\n"+failed.getReasonMessage(), failed.getReasonCode()); //$NON-NLS-1$ //$NON-NLS-2$
default:
throw new NotSignedException(Messages.getString("services.error.unknow")+failed.getReasonMessage(), failed.getReasonCode()); //$NON-NLS-1$
}
}
}
return false;
}