use of org.olat.modules.vitero.model.CheckUserInfo in project OpenOLAT by OpenOLAT.
the class ViteroConfigurationController method checkUsers.
private void checkUsers() {
try {
CheckUserInfo infos = viteroManager.checkUsers();
if (infos.getAuthenticationCreated() == 0 && infos.getAuthenticationDeleted() == 0) {
showInfo("check.users.ok");
} else {
String[] args = new String[] { Integer.toString(infos.getAuthenticationCreated()), Integer.toString(infos.getAuthenticationDeleted()), Integer.toString(infos.getAuthenticationCreated() + infos.getAuthenticationDeleted()) };
getWindowControl().setInfo(translate("check.users.nok", args));
}
} catch (VmsNotAvailableException e) {
showError(VmsNotAvailableException.I18N_KEY);
}
}
use of org.olat.modules.vitero.model.CheckUserInfo in project openolat by klemens.
the class ViteroConfigurationController method checkUsers.
private void checkUsers() {
try {
CheckUserInfo infos = viteroManager.checkUsers();
if (infos.getAuthenticationCreated() == 0 && infos.getAuthenticationDeleted() == 0) {
showInfo("check.users.ok");
} else {
String[] args = new String[] { Integer.toString(infos.getAuthenticationCreated()), Integer.toString(infos.getAuthenticationDeleted()), Integer.toString(infos.getAuthenticationCreated() + infos.getAuthenticationDeleted()) };
getWindowControl().setInfo(translate("check.users.nok", args));
}
} catch (VmsNotAvailableException e) {
showError(VmsNotAvailableException.I18N_KEY);
}
}
use of org.olat.modules.vitero.model.CheckUserInfo in project OpenOLAT by OpenOLAT.
the class ViteroManager method checkUsers.
public CheckUserInfo checkUsers() throws VmsNotAvailableException {
final String[] authProviders = new String[] { VMS_PROVIDER };
final String prefix = getVmsUsernamePrefix();
int authenticationCreated = 0;
int authenticationDeleted = 0;
// check if vms user with an openolat login exists on vms server
// without the need authentication object in openolat.
List<Usertype> users = getCustomersUsers();
if (users != null && users.size() > 0) {
for (Usertype user : users) {
String vmsUsername = user.getUsername();
if (vmsUsername.startsWith(prefix)) {
String olatUsername = vmsUsername.substring(prefix.length(), vmsUsername.length());
List<Identity> identities = securityManager.getIdentitiesByPowerSearch(olatUsername, null, false, null, null, authProviders, null, null, null, null, null);
if (identities.isEmpty()) {
Identity identity = securityManager.findIdentityByName(olatUsername);
if (identity != null) {
authenticationCreated++;
securityManager.createAndPersistAuthentication(identity, VMS_PROVIDER, Integer.toString(user.getId()), null, null);
log.info("Recreate VMS authentication for: " + identity.getName());
}
}
}
}
}
// check if all openolat users with a vms authentication have an user
// on the vms server
List<Identity> identities = securityManager.getIdentitiesByPowerSearch(null, null, false, null, null, authProviders, null, null, null, null, null);
for (Identity identity : identities) {
Authentication authentication = securityManager.findAuthentication(identity, VMS_PROVIDER);
String vmsUserId = authentication.getAuthusername();
boolean foundIt = false;
for (Usertype user : users) {
if (vmsUserId.equals(Integer.toString(user.getId()))) {
foundIt = true;
}
}
if (!foundIt) {
securityManager.deleteAuthentication(authentication);
authenticationDeleted++;
}
}
CheckUserInfo infos = new CheckUserInfo();
infos.setAuthenticationCreated(authenticationCreated);
infos.setAuthenticationDeleted(authenticationDeleted);
return infos;
}
use of org.olat.modules.vitero.model.CheckUserInfo in project openolat by klemens.
the class ViteroManager method checkUsers.
public CheckUserInfo checkUsers() throws VmsNotAvailableException {
final String[] authProviders = new String[] { VMS_PROVIDER };
final String prefix = getVmsUsernamePrefix();
int authenticationCreated = 0;
int authenticationDeleted = 0;
// check if vms user with an openolat login exists on vms server
// without the need authentication object in openolat.
List<Usertype> users = getCustomersUsers();
if (users != null && users.size() > 0) {
for (Usertype user : users) {
String vmsUsername = user.getUsername();
if (vmsUsername.startsWith(prefix)) {
String olatUsername = vmsUsername.substring(prefix.length(), vmsUsername.length());
List<Identity> identities = securityManager.getIdentitiesByPowerSearch(olatUsername, null, false, null, null, authProviders, null, null, null, null, null);
if (identities.isEmpty()) {
Identity identity = securityManager.findIdentityByName(olatUsername);
if (identity != null) {
authenticationCreated++;
securityManager.createAndPersistAuthentication(identity, VMS_PROVIDER, Integer.toString(user.getId()), null, null);
log.info("Recreate VMS authentication for: " + identity.getName());
}
}
}
}
}
// check if all openolat users with a vms authentication have an user
// on the vms server
List<Identity> identities = securityManager.getIdentitiesByPowerSearch(null, null, false, null, null, authProviders, null, null, null, null, null);
for (Identity identity : identities) {
Authentication authentication = securityManager.findAuthentication(identity, VMS_PROVIDER);
String vmsUserId = authentication.getAuthusername();
boolean foundIt = false;
for (Usertype user : users) {
if (vmsUserId.equals(Integer.toString(user.getId()))) {
foundIt = true;
}
}
if (!foundIt) {
securityManager.deleteAuthentication(authentication);
authenticationDeleted++;
}
}
CheckUserInfo infos = new CheckUserInfo();
infos.setAuthenticationCreated(authenticationCreated);
infos.setAuthenticationDeleted(authenticationDeleted);
return infos;
}
Aggregations