use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class StatusController method initializeTableController.
private void initializeTableController(UserRequest ureq) {
TableGuiConfiguration tableConfig = new TableGuiConfiguration();
tableConfig.setTableEmptyMessage(translate("error.no.user.found"));
removeAsListenerAndDispose(tableCtr);
tableCtr = new TableController(tableConfig, ureq, getWindowControl(), this.propertyHandlerTranslator);
listenTo(tableCtr);
List<Identity> l = UserDeletionManager.getInstance().getIdentitiesInDeletionProcess(UserDeletionManager.getInstance().getDeleteEmailDuration());
tdm = new UserDeleteTableModel(l, ureq.getLocale(), isAdministrativeUser);
tdm.addColumnDescriptors(tableCtr, null, "table.identity.deleteEmail");
tableCtr.addColumnDescriptor(new StaticColumnDescriptor(ACTION_SINGLESELECT_CHOOSE, "table.header.action", translate("action.activate")));
tableCtr.setMultiSelect(false);
tableCtr.setTableDataModel(tdm);
userDeleteStatusPanel.setContent(tableCtr.getInitialComponent());
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class BaseSecurityManager method findIdentityByNameCaseInsensitive.
@Override
public Identity findIdentityByNameCaseInsensitive(String identityName) {
if (identityName == null)
throw new AssertException("findIdentitybyName: name was null");
StringBuilder sb = new StringBuilder();
sb.append("select ident from ").append(IdentityImpl.class.getName()).append(" as ident where lower(ident.name)=:username");
List<Identity> identities = DBFactory.getInstance().getCurrentEntityManager().createQuery(sb.toString(), Identity.class).setParameter("username", identityName.toLowerCase()).getResultList();
return identities == null || identities.isEmpty() ? null : identities.get(0);
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class BaseSecurityManager method createAndPersistIdentityAndUserWithUserGroup.
/**
* Persists the given user, creates an identity for it and adds the user to
* the users system group, create an authentication for an external provider
*
* @param loginName
* @param externalId
* @param provider
* @param authusername
* @param newUser
* @return
*/
@Override
public Identity createAndPersistIdentityAndUserWithUserGroup(String loginName, String externalId, String provider, String authusername, User newUser) {
Identity ident = createAndPersistIdentityAndUser(loginName, externalId, newUser, provider, authusername, null);
log.audit("Create an identity with " + provider + " authentication (login=" + loginName + ",authusername=" + authusername + ")");
// Add user to system users group
SecurityGroup olatuserGroup = findSecurityGroupByName(Constants.GROUP_OLATUSERS);
addIdentityToSecurityGroup(ident, olatuserGroup);
return ident;
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class BaseSecurityManager method deleteInvalidAuthenticationsByEmail.
@Override
public void deleteInvalidAuthenticationsByEmail(String email) {
if (!StringHelper.containsNonWhitespace(email))
return;
// If a user with this email exists the email is valid.
Identity identity = UserManager.getInstance().findUniqueIdentityByEmail(email);
if (identity != null)
return;
StringBuilder sb = new StringBuilder();
sb.append("delete from ").append(AuthenticationImpl.class.getName()).append(" as auth");
sb.append(" where auth.authusername=:authusername");
sb.append(" and auth.provider in (:providers)");
List<String> providers = Arrays.asList(WebDAVAuthManager.PROVIDER_HA1_EMAIL, WebDAVAuthManager.PROVIDER_HA1_INSTITUTIONAL_EMAIL, WebDAVAuthManager.PROVIDER_WEBDAV_EMAIL, WebDAVAuthManager.PROVIDER_WEBDAV_INSTITUTIONAL_EMAIL);
dbInstance.getCurrentEntityManager().createQuery(sb.toString()).setParameter("authusername", email).setParameter("providers", providers).executeUpdate();
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class BaseSecurityManager method removeIdentityFromSecurityGroups.
@Override
public boolean removeIdentityFromSecurityGroups(List<Identity> identities, List<SecurityGroup> secGroups) {
// nothing to do
if (identities == null || identities.isEmpty())
return true;
// nothing to do
if (secGroups == null || secGroups.isEmpty())
return true;
StringBuilder sb = new StringBuilder();
sb.append("delete from ").append(SecurityGroupMembershipImpl.class.getName()).append(" as msi ").append(" where msi.identity.key in (:identityKeys) and msi.securityGroup.key in (:secGroupKeys)");
List<Long> identityKeys = new ArrayList<Long>();
for (Identity identity : identities) {
identityKeys.add(identity.getKey());
}
List<Long> secGroupKeys = new ArrayList<Long>();
for (SecurityGroup secGroup : secGroups) {
secGroupKeys.add(secGroup.getKey());
}
int rowsAffected = DBFactory.getInstance().getCurrentEntityManager().createQuery(sb.toString()).setParameter("identityKeys", identityKeys).setParameter("secGroupKeys", secGroupKeys).executeUpdate();
return rowsAffected > 0;
}
Aggregations