Commit 69e060f5 authored by michael.simon's avatar michael.simon
Browse files

Only store last assertion from user

parent 020f05bb
...@@ -11,7 +11,10 @@ ...@@ -11,7 +11,10 @@
package edu.kit.scc.webreg.dao; package edu.kit.scc.webreg.dao;
import edu.kit.scc.webreg.entity.SamlAssertionEntity; import edu.kit.scc.webreg.entity.SamlAssertionEntity;
import edu.kit.scc.webreg.entity.UserEntity;
public interface SamlAssertionDao extends BaseDao<SamlAssertionEntity, Long> { public interface SamlAssertionDao extends BaseDao<SamlAssertionEntity, Long> {
void deleteAssertionForUser(UserEntity user);
} }
...@@ -14,10 +14,11 @@ import java.io.Serializable; ...@@ -14,10 +14,11 @@ import java.io.Serializable;
import javax.enterprise.context.ApplicationScoped; import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named; import javax.inject.Named;
import javax.persistence.Query;
import edu.kit.scc.webreg.dao.SamlAssertionDao; import edu.kit.scc.webreg.dao.SamlAssertionDao;
import edu.kit.scc.webreg.entity.SamlAssertionEntity; import edu.kit.scc.webreg.entity.SamlAssertionEntity;
import edu.kit.scc.webreg.entity.SamlUserEntity; import edu.kit.scc.webreg.entity.UserEntity;
@Named @Named
@ApplicationScoped @ApplicationScoped
...@@ -29,4 +30,11 @@ public class JpaSamlAssertionDao extends JpaBaseDao<SamlAssertionEntity, Long> i ...@@ -29,4 +30,11 @@ public class JpaSamlAssertionDao extends JpaBaseDao<SamlAssertionEntity, Long> i
public Class<SamlAssertionEntity> getEntityClass() { public Class<SamlAssertionEntity> getEntityClass() {
return SamlAssertionEntity.class; return SamlAssertionEntity.class;
} }
@Override
public void deleteAssertionForUser(UserEntity user) {
Query query = em.createQuery("delete from SamlAssertionEntity where user=:user");
query.setParameter("user", user);
query.executeUpdate();
}
} }
...@@ -10,9 +10,9 @@ import javax.persistence.metamodel.StaticMetamodel; ...@@ -10,9 +10,9 @@ import javax.persistence.metamodel.StaticMetamodel;
@StaticMetamodel(SamlAssertionEntity.class) @StaticMetamodel(SamlAssertionEntity.class)
public abstract class SamlAssertionEntity_ extends edu.kit.scc.webreg.entity.AbstractBaseEntity_ { public abstract class SamlAssertionEntity_ extends edu.kit.scc.webreg.entity.AbstractBaseEntity_ {
public static volatile SingularAttribute<SamlMetadataEntity, String> assertionData; public static volatile SingularAttribute<SamlAssertionEntity, String> assertionData;
public static volatile SingularAttribute<SamlMetadataEntity, Date> validUntil; public static volatile SingularAttribute<SamlAssertionEntity, Date> validUntil;
public static volatile SingularAttribute<SamlMetadataEntity, SamlUserEntity> user; public static volatile SingularAttribute<SamlAssertionEntity, SamlUserEntity> user;
} }
...@@ -258,6 +258,8 @@ public class UserUpdater implements Serializable { ...@@ -258,6 +258,8 @@ public class UserUpdater implements Serializable {
public SamlUserEntity updateUser(SamlUserEntity user, Assertion assertion, String executor, ServiceEntity service) public SamlUserEntity updateUser(SamlUserEntity user, Assertion assertion, String executor, ServiceEntity service)
throws UserUpdateException { throws UserUpdateException {
samlAsserionDao.deleteAssertionForUser(user);
SamlAssertionEntity samlAssertionEntity = samlAsserionDao.createNew(); SamlAssertionEntity samlAssertionEntity = samlAsserionDao.createNew();
samlAssertionEntity.setUser(user); samlAssertionEntity.setUser(user);
samlAssertionEntity.setAssertionData(samlHelper.prettyPrint(assertion)); samlAssertionEntity.setAssertionData(samlHelper.prettyPrint(assertion));
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment