Search in sources :

Example 1 with ClientInfo

use of com.servoy.j2db.dataprocessing.ClientInfo in project servoy-client by Servoy.

the class HeadlessClient method closeSolution.

@Override
public boolean closeSolution(final boolean force, final Object[] args) {
    final boolean[] res = new boolean[] { false };
    invokeAndWait(new Runnable() {

        @Override
        public void run() {
            res[0] = superCloseSolution(force, args);
        }
    });
    if (res[0]) {
        try {
            // always reset for headless client the tenant value.
            ClientInfo clientInfo = getClientInfo();
            if (clientInfo != null) {
                clientInfo.setTenantValue(null);
                getClientHost().pushClientInfo(clientInfo.getClientId(), clientInfo);
            }
        } catch (Exception e) {
            Debug.error(e);
        }
    }
    return res[0];
}
Also used : ClientInfo(com.servoy.j2db.dataprocessing.ClientInfo)

Example 2 with ClientInfo

use of com.servoy.j2db.dataprocessing.ClientInfo in project servoy-client by Servoy.

the class AbstractApplication method setTimeZone.

@Override
public synchronized void setTimeZone(TimeZone zone) {
    if (timeZone != null && timeZone.equals(zone))
        return;
    TimeZone old = timeZone;
    timeZone = zone;
    // $NON-NLS-1$
    J2DBGlobals.firePropertyChange(this, "timeZone", old, timeZone);
    ClientInfo clientInfo = getClientInfo();
    clientInfo.setTimeZone(timeZone);
    try {
        getClientHost().pushClientInfo(clientInfo.getClientId(), clientInfo);
    } catch (RemoteException e) {
        Debug.error(e);
    }
}
Also used : TimeZone(java.util.TimeZone) ClientInfo(com.servoy.j2db.dataprocessing.ClientInfo) RemoteException(java.rmi.RemoteException)

Example 3 with ClientInfo

use of com.servoy.j2db.dataprocessing.ClientInfo in project servoy-client by Servoy.

the class MessageLogger method logMessage.

private void logMessage(String message) {
    StringBuilder sb = new StringBuilder(message.length() + 50);
    sb.append(session.getSessionKey()).append('|').append(windowNr).append('|');
    INGApplication client = session.getClient();
    if (client != null) {
        sb.append(client.getClientID());
        sb.append('|');
        ClientInfo clientInfo = client.getClientInfo();
        if (clientInfo != null) {
            sb.append(clientInfo.getUserName() != null ? clientInfo.getUserName() : "<no-user>");
        } else {
            sb.append("<no-client-info>");
        }
    } else {
        sb.append("<no-client>|<no-user>");
    }
    sb.append('|');
    sb.append(message);
    // it logs to error so it will always log when this line is hit. (but with the logMessages boolea this can be toggled)
    messageLogger.error(sb.toString());
}
Also used : ClientInfo(com.servoy.j2db.dataprocessing.ClientInfo)

Example 4 with ClientInfo

use of com.servoy.j2db.dataprocessing.ClientInfo in project servoy-client by Servoy.

the class JSSecurity method js_login.

/**
 * Login to be able to leave the solution loginForm.
 *
 * Example: Group names may be received from LDAP (Lightweight Directory Access Protocol) - a standard protocol used in web browsers and email applications to enable lookup queries that access a directory listing.
 *
 * @sample
 * var groups = ['Administrators']; //normally these groups are for example received from LDAP
 * var user_uid = scopes.globals.email; //also this uid might be received from external authentication method
 * var ok =  security.login(scopes.globals.username, user_uid , groups)
 * if (!ok)
 * {
 * 	plugins.dialogs.showErrorDialog('Login failure',  'Already logged in? or no user_uid/groups specified?', 'OK')
 * }
 *
 * @param username the username, like 'JamesWebb'
 * @param a_userUID the user UID to process login for
 * @param groups the groups array
 * @return true if loggedin
 */
public boolean js_login(String username, Object a_userUID, String[] groups) {
    if (application.getUserManager() == null) {
        // cannot login locally in client because client has to be authenticated at the server first
        return false;
    }
    String userUID = normalizeUID(a_userUID);
    if (groups == null || groups.length == 0 || username == null || username.length() == 0 || userUID == null || userUID.length() == 0)
        return false;
    // check if the groups all exist
    IDataSet groupsDataSet;
    try {
        groupsDataSet = application.getUserManager().getGroups(application.getClientID());
    } catch (Exception e) {
        Debug.error(e);
        return false;
    }
    for (String group : groups) {
        int i;
        for (i = 0; i < groupsDataSet.getRowCount() && !groupsDataSet.getRow(i)[1].equals(group); i++) {
        }
        if (i == groupsDataSet.getRowCount()) {
            // $NON-NLS-1$//$NON-NLS-2$
            Debug.log("Could not log in user for unknown group '" + group + "'");
            return false;
        }
    }
    ClientInfo ci = application.getClientInfo();
    if (ci.getUserUid() != null && !ci.getUserUid().equalsIgnoreCase(userUID)) {
        // already logged in
        return false;
    }
    ci.setUserName(username);
    ci.setUserUid(userUID);
    ci.setUserGroups(groups);
    if (application.getSolution().getSolutionType() != SolutionMetaData.AUTHENTICATOR) {
        application.clearLoginForm();
    }
    return true;
}
Also used : ClientInfo(com.servoy.j2db.dataprocessing.ClientInfo) IDataSet(com.servoy.j2db.dataprocessing.IDataSet) ServoyException(com.servoy.j2db.util.ServoyException) ApplicationException(com.servoy.j2db.ApplicationException) RepositoryException(com.servoy.j2db.persistence.RepositoryException)

Example 5 with ClientInfo

use of com.servoy.j2db.dataprocessing.ClientInfo in project servoy-client by Servoy.

the class JSSecurity method setTenantValue.

/**
 * Set the tenant value for this Client, this value will be used as the value for all tables that have a column marked as a tenant column.
 * This results in adding a table filter for that table based on that column and the this value.
 *<p>
 * This value will be auto filled in for all the columns that are marked as a tenant column. If you give an array of values then the first array value is used for this.
 *</p>
 *<p>
 *  When a tenant value is set the client will only receive databroadcasts from other clients that have no or a common tenant value set
 *  Be sure to not access or depend on records having different tenant values, as no databroadcasts will be received for those
 *</p>
 * @param value a single tenant value or an array of tenant values to filter tables having a column flagged as Tenant column by.
 */
@JSFunction
public void setTenantValue(Object value) {
    ClientInfo clientInfo = application.getClientInfo();
    clientInfo.setTenantValue(toArray(value));
    try {
        application.getClientHost().pushClientInfo(clientInfo.getClientId(), clientInfo);
    } catch (Exception e) {
        Debug.error(e);
    }
    // flush all foundsets that are based on tenant columns
    application.getFoundSetManager().refreshFoundsetsForTenantTables();
}
Also used : ClientInfo(com.servoy.j2db.dataprocessing.ClientInfo) ServoyException(com.servoy.j2db.util.ServoyException) ApplicationException(com.servoy.j2db.ApplicationException) RepositoryException(com.servoy.j2db.persistence.RepositoryException) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Aggregations

ClientInfo (com.servoy.j2db.dataprocessing.ClientInfo)7 ApplicationException (com.servoy.j2db.ApplicationException)2 RepositoryException (com.servoy.j2db.persistence.RepositoryException)2 ServoyException (com.servoy.j2db.util.ServoyException)2 RemoteException (java.rmi.RemoteException)2 TimeZone (java.util.TimeZone)2 IServiceProvider (com.servoy.j2db.IServiceProvider)1 IDataSet (com.servoy.j2db.dataprocessing.IDataSet)1 Solution (com.servoy.j2db.persistence.Solution)1 AppendingStringBuffer (com.servoy.j2db.util.AppendingStringBuffer)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 Locale (java.util.Locale)1 JSONObject (org.json.JSONObject)1 JSFunction (org.mozilla.javascript.annotations.JSFunction)1 BaseWebObject (org.sablo.BaseWebObject)1