Search in sources :

Example 1 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class SchoolDataSourceDAO method create.

public SchoolDataSource create(String identifier) {
    SchoolDataSource dataSource = new SchoolDataSource();
    dataSource.setIdentifier(identifier);
    getEntityManager().persist(dataSource);
    return dataSource;
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource)

Example 2 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class ForgotPasswordRESTService method confirmResetPassword.

@Path("/confirm")
@GET
@RESTPermitUnimplemented
public Response confirmResetPassword(ConfirmResetPassword crp) {
    UserPendingPasswordChange passwordChange = userPendingPasswordChangeDAO.findByConfirmationHash(crp.getResetCode());
    UserEntity userEntity = userEntityController.findUserEntityById(passwordChange.getUserEntity());
    // TODO: tis a guesstimate of the datasource
    SchoolDataSource schoolDataSource = userEntity.getDefaultSchoolDataSource();
    try {
        userSchoolDataController.confirmResetPassword(schoolDataSource, crp.getResetCode(), crp.getNewPassword());
        return Response.noContent().build();
    } catch (SchoolDataBridgeUnauthorizedException e) {
        return Response.status(Status.FORBIDDEN).build();
    }
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource) UserPendingPasswordChange(fi.otavanopisto.muikku.plugins.user.UserPendingPasswordChange) SchoolDataBridgeUnauthorizedException(fi.otavanopisto.muikku.schooldata.SchoolDataBridgeUnauthorizedException) UserEntity(fi.otavanopisto.muikku.model.users.UserEntity) Path(javax.ws.rs.Path) RESTPermitUnimplemented(fi.otavanopisto.muikku.rest.RESTPermitUnimplemented) GET(javax.ws.rs.GET)

Example 3 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class UserSchoolDataController method findUserEntity.

/* User Entity */
public UserEntity findUserEntity(User user) {
    SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(user.getSchoolDataSource());
    UserSchoolDataIdentifier userSchoolDataIdentifier = userSchoolDataIdentifierDAO.findByDataSourceAndIdentifierAndArchived(schoolDataSource, user.getIdentifier(), Boolean.FALSE);
    return userSchoolDataIdentifier == null ? null : userSchoolDataIdentifier.getUserEntity();
}
Also used : UserSchoolDataIdentifier(fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier) SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource)

Example 4 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class UserSchoolDataController method updateUserCredentials.

public void updateUserCredentials(User user, String oldPassword, String newUsername, String newPassword) throws SchoolDataBridgeUnauthorizedException {
    SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(user.getSchoolDataSource());
    if (schoolDataSource == null) {
        throw new SchoolDataBridgeInternalException(String.format("Invalid data source %s", user.getSchoolDataSource()));
    }
    getUserBridge(schoolDataSource).updateUserCredentials(user.getIdentifier(), oldPassword, newUsername, newPassword);
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource)

Example 5 with SchoolDataSource

use of fi.otavanopisto.muikku.model.base.SchoolDataSource in project muikku by otavanopisto.

the class WorkspaceEntityController method createWorkspaceEntity.

public WorkspaceEntity createWorkspaceEntity(String dataSource, String identifier, String urlName) {
    SchoolDataSource schoolDataSource = schoolDataSourceDAO.findByIdentifier(dataSource);
    if (schoolDataSource == null) {
        logger.severe("Could not find school data source: " + dataSource);
        return null;
    }
    WorkspaceEntity workspaceEntity = workspaceEntityDAO.create(schoolDataSource, identifier, urlName, WorkspaceAccess.LOGGED_IN, Boolean.FALSE, Boolean.FALSE);
    return workspaceEntity;
}
Also used : SchoolDataSource(fi.otavanopisto.muikku.model.base.SchoolDataSource) WorkspaceEntity(fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)

Aggregations

SchoolDataSource (fi.otavanopisto.muikku.model.base.SchoolDataSource)35 RoleSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.RoleSchoolDataIdentifier)4 RoleEntity (fi.otavanopisto.muikku.model.users.RoleEntity)3 WorkspaceRoleEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceRoleEntity)3 EnvironmentRoleEntity (fi.otavanopisto.muikku.model.users.EnvironmentRoleEntity)2 UserEntity (fi.otavanopisto.muikku.model.users.UserEntity)2 WorkspaceEntity (fi.otavanopisto.muikku.model.workspace.WorkspaceEntity)2 LoginEvent (fi.otavanopisto.muikku.events.LoginEvent)1 CourseIdentifierEntity (fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierEntity)1 CourseIdentifierSchoolDataIdentifier (fi.otavanopisto.muikku.model.coursemeta.CourseIdentifierSchoolDataIdentifier)1 UserSchoolDataIdentifier (fi.otavanopisto.muikku.model.users.UserSchoolDataIdentifier)1 UserPendingPasswordChange (fi.otavanopisto.muikku.plugins.user.UserPendingPasswordChange)1 RESTPermitUnimplemented (fi.otavanopisto.muikku.rest.RESTPermitUnimplemented)1 SchoolDataBridgeUnauthorizedException (fi.otavanopisto.muikku.schooldata.SchoolDataBridgeUnauthorizedException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Locale (java.util.Locale)1 Set (java.util.Set)1 EntityManager (javax.persistence.EntityManager)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1