Search in sources :

Example 66 with Identity

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());
}
Also used : TableController(org.olat.core.gui.components.table.TableController) StaticColumnDescriptor(org.olat.core.gui.components.table.StaticColumnDescriptor) TableGuiConfiguration(org.olat.core.gui.components.table.TableGuiConfiguration) Identity(org.olat.core.id.Identity)

Example 67 with Identity

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);
}
Also used : AssertException(org.olat.core.logging.AssertException) Identity(org.olat.core.id.Identity)

Example 68 with Identity

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;
}
Also used : Identity(org.olat.core.id.Identity)

Example 69 with Identity

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();
}
Also used : Identity(org.olat.core.id.Identity)

Example 70 with Identity

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;
}
Also used : ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity)

Aggregations

Identity (org.olat.core.id.Identity)3749 Test (org.junit.Test)1956 RepositoryEntry (org.olat.repository.RepositoryEntry)898 BusinessGroup (org.olat.group.BusinessGroup)560 ArrayList (java.util.ArrayList)550 Date (java.util.Date)312 URI (java.net.URI)272 ICourse (org.olat.course.ICourse)266 HttpResponse (org.apache.http.HttpResponse)260 File (java.io.File)211 AssessmentManager (org.olat.course.assessment.AssessmentManager)210 Path (javax.ws.rs.Path)182 OLATResource (org.olat.resource.OLATResource)172 OLATResourceable (org.olat.core.id.OLATResourceable)156 Roles (org.olat.core.id.Roles)154 HashMap (java.util.HashMap)151 RestSecurityHelper.getIdentity (org.olat.restapi.security.RestSecurityHelper.getIdentity)142 HashSet (java.util.HashSet)136 List (java.util.List)132 Produces (javax.ws.rs.Produces)130