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];
}
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);
}
}
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());
}
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;
}
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();
}
Aggregations