Build a new remote session and initialize it.
NOTE: This is convenience method to create a task below the current APPLICATION (not below this task)
@param properties to create the new remote task
@return The remote Task.
9156
public RemoteTask createRemoteTask(Map<String, Object> properties) throws RemoteException
    {   // Note: This new task's parent is MY application!
        BaseTransport transport = this.createProxyTransport(CREATE_REMOTE_TASK); // Don't use my method yet, since I don't have the returned ID
        transport.addParam(PROPERTIES, properties);
        String strID = (String)transport.sendMessageAndGetReply();
        return new TaskProxy((ApplicationProxy)m_parentProxy, strID);   // Note the parent is MY PARENT not ME. (just like the remote hierarchy)
    }
741755
public void runCalendarEntry(Map<String,Object> properties)
    {
        ProcessRunnerTask task = new ProcessRunnerTask(null, null, properties);
        ((Application)this.getTask().getApplication()).getTaskScheduler().addTask(task);
    }
763817
public void doProcess(InputStream in, PrintWriter out, Map<String, Object> properties)
        throws RemoteException
    {
        String strCommand = this.getProperty(REMOTE_COMMAND, properties);
        if (RECEIVE_REMOTE_MESSAGE.equals(strCommand))
        {
            Message message = ((RemoteReceiveQueue)m_remoteObject).receiveRemoteMessage();
            if (message != null)	// If the client quits, this is freed and I get a null message (which I don't need to return)
            	this.setReturnObject(out, message);
        }
        else if (ADD_REMOTE_MESSAGE_FILTER.equals(strCommand))
        {
            BaseMessageFilter messageFilter = (BaseMessageFilter)this.getNextObjectParam(in, FILTER, properties);
            String strSessionPathID = this.getNextStringParam(in, SESSION, properties);
            BaseHolder sessionHolder = this.getSessionFromPath(strSessionPathID);
            BaseMessageFilter objReturn = null;
            if (sessionHolder instanceof SessionHolder)
            {       // Always
                RemoteSession remoteSession = (RemoteSession)sessionHolder.getRemoteObject();
                objReturn = ((RemoteReceiveQueue)m_remoteObject).addRemoteMessageFilter(messageFilter, remoteSession);
            }
            else if (sessionHolder == null)
            {   // Session may be null.
                objReturn = ((RemoteReceiveQueue)m_remoteObject).addRemoteMessageFilter(messageFilter, null);
            }
            else
                Utility.getLogger().warning("Remote session not found");
            this.setReturnObject(out, objReturn);
        }
        else if (REMOVE_REMOTE_MESSAGE_FILTER.equals(strCommand))
        {
            BaseMessageFilter messageFilter = (BaseMessageFilter)this.getNextObjectParam(in, FILTER, properties);
            boolean bFreeFilter = this.getNextBooleanParam(in, FREE, properties);
            boolean bSuccess = ((RemoteReceiveQueue)m_remoteObject).removeRemoteMessageFilter(messageFilter, bFreeFilter);
            this.setReturnObject(out, new Boolean(bSuccess));
        }
        else if (UPDATE_REMOTE_FILTER_PROPERTIES.equals(strCommand))
        {
            BaseMessageFilter messageFilter = (BaseMessageFilter)this.getNextObjectParam(in, FILTER, properties);
            Object[][] propIn = (Object[][])this.getNextObjectParam(in, PROPERTIES, properties);
            Map<String,Object> propFilter = this.getNextPropertiesParam(in, MAP, properties);
            ((RemoteReceiveQueue)m_remoteObject).updateRemoteFilterProperties(messageFilter, propIn, propFilter);
        }
        else
            super.doProcess(in, out, properties);
    }
443787
private static void setProperties(GenericApplicationContext newContext, Properties properties) {
        PropertiesPropertySource pps = new PropertiesPropertySource("external-props", properties);
        newContext.getEnvironment().getPropertySources().addFirst(pps);
    }
449663
public Task addStandaloneHost_Task(HostConnectSpec spec, ComputeResourceConfigSpec compResSpec, boolean addConnected) throws InvalidLogin, HostConnectFault, RuntimeFault, RemoteException {
        return addStandaloneHost_Task(spec, compResSpec, addConnected, null);
    }
517309
public void doProcess(InputStream in, PrintWriter out, Map<String, Object> properties)
        throws RemoteException
    {
        String strCommand = this.getProperty(REMOTE_COMMAND, properties);
        try {
            if (FREE_REMOTE_SESSION.equals(strCommand))
            {
                ((BaseSession)m_remoteObject).freeRemoteSession();
                this.free();    // Free this (peer's) resources.
            }
            else if (MAKE_REMOTE_SESSION.equals(strCommand))
            {
                String strSessionClassName = this.getNextStringParam(in, NAME, properties);
                RemoteBaseSession remoteSession = ((RemoteBaseSession)m_remoteObject).makeRemoteSession(strSessionClassName);
                this.setReturnSessionOrObject(out, remoteSession);
            }
            else if (DO_REMOTE_ACTION.equals(strCommand))
            {
                String strAction = this.getNextStringParam(in, NAME, properties);
                Map<String,Object> propIn = this.getNextPropertiesParam(in, PROPERTIES, properties);
                if (propIn != null)
                    properties.putAll(propIn);
                Object objReturn = ((RemoteBaseSession)m_remoteObject).doRemoteAction(strAction, properties);
                this.setReturnSessionOrObject(out, objReturn);  // Could be a session.
            }
            else
                super.doProcess(in, out, properties);
        } catch (Exception ex)    {
            // ex.printStackTrace();    // Don't print this error, since I am returning it to my ajax caller.
            this.setReturnObject(out, ex);
        }
    }
1079968
void setup(final Map<String, Object> properties) {
        final List<SetupAction> successfulActions = new ArrayList<SetupAction>();
        for (final SetupAction action : setupActions) {
            try {
                action.setup(properties);
                successfulActions.add(action);
            } catch (final Throwable e) {
                for (SetupAction s : successfulActions) {
                    try {
                        s.teardown(properties);
                    } catch (final Throwable t) {
                        // we ignore these, and just propagate the exception that caused the setup to fail
                    }
                }
                throw new RuntimeException(e);
            }
        }
    }
394597
public int login(Task task, String strUserName, String strPassword, String strDomain)
    {
        boolean bCreateServer = false;
        if ((this.getProperty(DBParams.REMOTE_HOST) != null) && (this.getProperty(DBParams.REMOTE_HOST).length() > 0))
            bCreateServer = true;
        org.jbundle.thin.base.remote.RemoteTask remoteTask = (org.jbundle.thin.base.remote.RemoteTask)this.getRemoteTask(null, strUserName, bCreateServer);
        if (remoteTask != null)
            return super.login(task, strUserName, strPassword, strDomain); // Remote client - have server log me in
        else
        {   // If I'm not remote, I need to read the user info.
            Map<String,Object> mapDomainProperties = this.setDomainProperties(task, strDomain);
            this.setProperty(Params.USER_ID, null);
            this.setProperty(Params.USER_NAME, null);
            if (Utility.isNumeric(strUserName))
                this.setProperty(Params.USER_ID, strUserName);
            else
                this.setProperty(Params.USER_NAME, strUserName);
            if ((this.getProperty(Params.USER_ID) == null) || (this.getProperty(Params.USER_ID).length() == 0))
                if ((this.getProperty(Params.USER_NAME) == null) || (this.getProperty(Params.USER_NAME).length() == 0))
            {   // If user is not specified (either for no user, or logout), use the anonymous user
                Record recUserControl = null;
                if (m_systemRecordOwner != null)
                {   // Always
                    recUserControl = (Record)m_systemRecordOwner.getRecord(UserControlModel.USER_CONTROL_FILE);
                    if (recUserControl == null)
                        recUserControl = Record.makeRecordFromClassName(UserControlModel.THICK_CLASS, m_systemRecordOwner);
                    String strUserID = recUserControl.getField(UserControlModel.ANON_USER_INFO_ID).getString();
                    if ((strUserID == null) || (strUserID.length() == 0))
                        strUserID = DBConstants.ANON_USER_ID;
                    this.setProperty(Params.USER_ID, strUserID);
                }
            }
            if (this.readUserInfo(false, true) == true)
            {
                UserInfoModel recUserInfo = this.getUserInfo();
                if ((strPassword != null) && (strPassword.length() > 0))
                {
                    while (strPassword.endsWith("%3D")) {
                        strPassword = strPassword.substring(0, strPassword.length() - 3) + "="; // Often converted when passing URLs
                    }
                    if (!strPassword.equals(recUserInfo.getField(UserInfoModel.PASSWORD).toString()))
                    {
                        return task.setLastError(this.getString("User name and password do not match"));
                    }
                    // Create and save the remote authorization token.
                    String strToken = Long.toString((long)(Math.random() * Long.MAX_VALUE));
                    strToken = Base64.encode(strToken);
                    this.setProperty(DBParams.AUTH_TOKEN, strToken);
                    // todo(don) HACK - For now, authentication is the SHA password! See ServletTask/777
                    this.setProperty(DBParams.AUTH_TOKEN, strPassword);    // NO NO NO                    
                }

                Record recUserGroup = ((ReferenceField)recUserInfo.getField(UserInfoModel.USER_GROUP_ID)).getReference();
                String strSecurityMap = null;
                Map<String,Object> mapUserProperties = ((PropertiesField)recUserInfo.getField(UserInfoModel.PROPERTIES)).getProperties();
                Map<String,Object> mapGroupProperties = null;
                if (recUserGroup != null)
                {
                    strSecurityMap = recUserGroup.getField(UserGroupModel.ACCESS_MAP).toString();
                    mapGroupProperties = ((PropertiesField)recUserGroup.getField(UserGroupModel.PROPERTIES)).getProperties();
                }
                if (strSecurityMap == null)
                    strSecurityMap = DBConstants.BLANK;     // The signals the the user is signed on
                this.setProperty(Params.SECURITY_MAP, strSecurityMap);
                this.setProperty(Params.SECURITY_LEVEL, ((strPassword == null) || (strPassword.length() == 0)) ? Integer.toString(Constants.LOGIN_USER) : Integer.toString(Constants.LOGIN_AUTHENTICATED));
                if ((DBConstants.ANON_USER_ID.equals(recUserInfo.getField(UserInfoModel.ID).toString()))
                        || (recUserInfo == null))
                    this.setProperty(Params.SECURITY_LEVEL, Integer.toString(Constants.LOGIN_USER));   // Special case - If user is anonymous, level is always anonymous
                Map<String,Object> properties = new Hashtable<String,Object>();
                if (mapDomainProperties != null)
                    properties.putAll(mapDomainProperties);   // Merge the properties
                if (mapGroupProperties != null)
                    properties.putAll(mapGroupProperties);   // Merge the properties
                if (mapUserProperties != null)
                    properties.putAll(mapUserProperties);   // Merge the properties
                if (recUserInfo != null)
                {
                    this.setProperty(DBParams.USER_ID, recUserInfo.getField(UserInfoModel.ID).toString());
                    if (!recUserInfo.getField(UserInfoModel.USER_NAME).isNull())
                        this.setProperty(DBParams.USER_NAME, recUserInfo.getField(UserInfoModel.USER_NAME).toString());
                    if (properties != null)
                    {
                        properties.put(DBParams.USER_ID, recUserInfo.getField(UserInfo.ID).toString());
                        if (!recUserInfo.getField(UserInfoModel.USER_NAME).isNull())
                            properties.put(DBParams.USER_NAME, recUserInfo.getField(UserInfoModel.USER_NAME).toString());
                        if (this.getProperty(DBParams.AUTH_TOKEN) != null)
                            properties.put(DBParams.AUTH_TOKEN, this.getProperty(DBParams.AUTH_TOKEN));
                    }
                }
                m_systemRecordOwner.setProperties(properties);  // These are the user properties

                UserLogModel recUserLog = null;
                if (m_systemRecordOwner != null)
                {   // Always
                    recUserLog = (UserLogModel)m_systemRecordOwner.getRecord(UserLogModel.USER_LOG_FILE);
                    if (recUserLog == null)
                        recUserLog = (UserLogModel)Record.makeRecordFromClassName(UserLogModel.THICK_CLASS, m_systemRecordOwner);
                }
                if (recUserLog != null)
                    if (this.getProperty(DBParams.USER_ID) != null)
                        if (this.getProperty(DBParams.USER_ID).length() > 0)
                            if (!DBConstants.ANON_USER_ID.equals(this.getProperty(DBParams.USER_ID)))
                {
                    try {
                        int iUserID = Integer.parseInt(this.getProperty(DBParams.USER_ID));
                        int iUserLogTypeID = UserLogTypeModel.LOGIN;
                        String strMessage = "Login";
                        recUserLog.log(iUserID, iUserLogTypeID, strMessage);
                    } catch (NumberFormatException e) {
                        // Ignore
                    }
                }

                return Constants.NORMAL_RETURN;
            }
            else if (task != null)
                return task.setLastError(this.getString("User name and password do not match"));
            else
                return DBConstants.ERROR_RETURN;
        }
    }
549738
public RemoteTask getNewRemoteTask(Application app, Map<String,Object> properties)
    {
        try   {
            // Map<String,Object> propApp = this.getApplicationProperties(properties);

            // Map<String,Object> propInitial = ProxyTask.getInitialProperties(this.getBasicServlet(), SERVLET_TYPE.PROXY);
            // if (propInitial != null)
            //	propApp.putAll(propInitial);
            
            if (app == null)
                app = new MainApplication(((BaseApplication)m_application).getEnvironment(), properties, null);	// propApp, null);
            RemoteTask remoteServer = new TaskSession(app);
            ((TaskSession)remoteServer).setProperties(properties);
            return remoteServer;
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }
357950
public void doProcess(InputStream in, PrintWriter out, Map<String, Object> properties)
        throws RemoteException
    {
        String strCommand = this.getProperty(REMOTE_COMMAND, properties);
        if (GET_REMOTE_TABLE.equals(strCommand))
        {
            String strName = this.getNextStringParam(in, NAME, properties);
            RemoteTable remoteTable = ((RemoteSession)m_remoteObject).getRemoteTable(strName);
            // First, see if this is in my list already?
            String strID = this.find(remoteTable);
            if (strID == null)
                strID = this.add(new TableHolder(this, remoteTable));
            this.setReturnString(out, strID);
        }
        else if (SETUP_REMOTE_SESSION_FILTER.equals(strCommand))
        {
            org.jbundle.thin.base.message.BaseMessageFilter filter = (org.jbundle.thin.base.message.BaseMessageFilter)this.getNextObjectParam(in, FILTER, properties);
            filter = ((RemoteSession)m_remoteObject).setupRemoteSessionFilter(filter);
            this.setReturnObject(out, filter);
        }
        else
            super.doProcess(in, out, properties);
    }
316532
public TaskInfo createTask(ManagedObject obj, String taskTypeId, String initiatedBy, boolean cancelable) throws RuntimeFault, RemoteException {
        return createTask(obj, taskTypeId, initiatedBy, cancelable, null);
    }
1109428
protected void init() {
        // create a synchronisation task which makes sure that the change requested by
        // the internal future has at one time been synchronized to the remote
        synchronisationFuture = GlobalCachedExecutorService.submit(() -> {
            dataProvider.addDataObserver(notifyChangeObserver);
            try {
                dataProvider.waitForData();
                T result = internalFuture.get();
                waitForSynchronization(result);
            } catch (CouldNotPerformException ex) {
                ExceptionPrinter.printHistory("Could not sync with internal future!", ex, logger);
            } finally {
                dataProvider.removeDataObserver(notifyChangeObserver);
            }
            return null;
        });
    }
1051741
public HttpAuthService build(Service<HttpRequest, HttpResponse> delegate) {
        return new HttpAuthService(requireNonNull(delegate, "delegate"), authorizer(),
                                   successHandler, failureHandler);
    }
777108
@SneakyThrows
    public static ClientConfiguration buildClientConfiguration(final BaseAmazonWebServicesProperties props) {
        val cfg = new ClientConfiguration();
        cfg.setConnectionTimeout(props.getConnectionTimeout());
        cfg.setMaxConnections(props.getMaxConnections());
        cfg.setRequestTimeout(props.getRequestTimeout());
        cfg.setSocketTimeout(props.getSocketTimeout());
        cfg.setUseGzip(props.isUseGzip());
        cfg.setUseReaper(props.isUseReaper());
        cfg.setUseThrottleRetries(props.isUseThrottleRetries());
        cfg.setUseTcpKeepAlive(props.isUseTcpKeepAlive());
        cfg.setProtocol(Protocol.valueOf(props.getProtocol().toUpperCase()));
        cfg.setClientExecutionTimeout(props.getClientExecutionTimeout());
        if (props.getMaxErrorRetry() > 0) {
            cfg.setMaxErrorRetry(props.getMaxErrorRetry());
        }
        cfg.setProxyHost(props.getProxyHost());
        cfg.setProxyPassword(props.getProxyPassword());
        if (props.getProxyPort() > 0) {
            cfg.setProxyPort(props.getProxyPort());
        }
        cfg.setProxyUsername(props.getProxyUsername());
        cfg.setCacheResponseMetadata(props.isCacheResponseMetadata());

        if (StringUtils.isNotBlank(props.getLocalAddress())) {
            LOGGER.trace("Creating DynamoDb client local address [{}]", props.getLocalAddress());
            cfg.setLocalAddress(InetAddress.getByName(props.getLocalAddress()));
        }

        return cfg;
    }
1245940
public RemoteBaseSession makeRemoteSession(String strSessionClassName) throws RemoteException
    {
        BaseSession session = null;
        try   {
            if (strSessionClassName.indexOf('.') == 0)
                strSessionClassName = Constants.ROOT_PACKAGE + strSessionClassName.substring(1);
            Utility.getLogger().info("Make remote session. Remote class: " + strSessionClassName);
        	session = (BaseSession)ClassServiceUtility.getClassService().makeObjectFromClassName(strSessionClassName);
            session.init(this, null, null);
        } catch (Exception ex)  {
            ex.printStackTrace();
            session = null;
        }
        return session;
    }
440114
public RemoteBaseSession makeRemoteSession(String strSessionClassName) throws RemoteException
    {
        BaseTransport transport = this.createProxyTransport(MAKE_REMOTE_SESSION);
        transport.addParam(NAME, strSessionClassName);
        String strClassAndID = (String)transport.sendMessageAndGetReply();
        return this.checkForSession(strClassAndID);
    }
613062
public Task addHost_Task(HostConnectSpec spec, boolean asConnected, ResourcePool resourcePool) throws InvalidLogin, HostConnectFault, RuntimeFault, RemoteException {
        return addHost_Task(spec, asConnected, resourcePool, null);
    }