Search in sources :

Example 6 with JpaUserReference

use of org.opencastproject.security.impl.jpa.JpaUserReference in project opencast by opencast.

the class JpaUserReferenceProvider method getUsers.

@Override
public Iterator<User> getUsers() {
    String orgId = securityService.getOrganization().getId();
    List<User> users = new ArrayList<User>();
    for (JpaUserReference userRef : findUserReferences(orgId, 0, 0, emf)) {
        users.add(userRef.toUser(PROVIDER_NAME));
    }
    return users.iterator();
}
Also used : User(org.opencastproject.security.api.User) ArrayList(java.util.ArrayList) JpaUserReference(org.opencastproject.security.impl.jpa.JpaUserReference)

Example 7 with JpaUserReference

use of org.opencastproject.security.impl.jpa.JpaUserReference in project opencast by opencast.

the class ConfigurableLoginHandler method existingUserLogin.

/**
 * Handle an existing user login.
 *
 * @param id
 *          The identity of the user, ideally the Shibboleth persistent unique identifier
 * @param request
 *          The request, for accessing any other Shibboleth variables
 */
@Override
public void existingUserLogin(String id, HttpServletRequest request) {
    Organization organization = securityService.getOrganization();
    // Load the user reference
    JpaUserReference userReference = userReferenceProvider.findUserReference(id, organization.getId());
    if (userReference == null) {
        throw new IllegalStateException("User reference '" + id + "' was not found");
    }
    // Update the reference
    userReference.setName(extractName(request));
    userReference.setEmail(extractEmail(request));
    userReference.setLastLogin(new Date());
    Set<JpaRole> roles = extractRoles(id, request);
    userReference.setRoles(roles);
    logger.debug("Shibboleth user '{}' logged in", id);
    userReferenceProvider.updateUserReference(userReference);
}
Also used : Organization(org.opencastproject.security.api.Organization) JaxbOrganization(org.opencastproject.security.api.JaxbOrganization) JpaOrganization(org.opencastproject.security.impl.jpa.JpaOrganization) JpaRole(org.opencastproject.security.impl.jpa.JpaRole) JpaUserReference(org.opencastproject.security.impl.jpa.JpaUserReference) Date(java.util.Date)

Aggregations

JpaUserReference (org.opencastproject.security.impl.jpa.JpaUserReference)7 Date (java.util.Date)4 EntityManager (javax.persistence.EntityManager)3 JpaOrganization (org.opencastproject.security.impl.jpa.JpaOrganization)3 JpaRole (org.opencastproject.security.impl.jpa.JpaRole)3 ArrayList (java.util.ArrayList)2 EntityTransaction (javax.persistence.EntityTransaction)2 User (org.opencastproject.security.api.User)2 NoResultException (javax.persistence.NoResultException)1 Query (javax.persistence.Query)1 JaxbOrganization (org.opencastproject.security.api.JaxbOrganization)1 Organization (org.opencastproject.security.api.Organization)1