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

Only store last assertion from user

parent 020f05bb
......@@ -11,7 +11,10 @@
package edu.kit.scc.webreg.dao;
import edu.kit.scc.webreg.entity.SamlAssertionEntity;
import edu.kit.scc.webreg.entity.UserEntity;
public interface SamlAssertionDao extends BaseDao<SamlAssertionEntity, Long> {
void deleteAssertionForUser(UserEntity user);
}
......@@ -14,10 +14,11 @@ import java.io.Serializable;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import javax.persistence.Query;
import edu.kit.scc.webreg.dao.SamlAssertionDao;
import edu.kit.scc.webreg.entity.SamlAssertionEntity;
import edu.kit.scc.webreg.entity.SamlUserEntity;
import edu.kit.scc.webreg.entity.UserEntity;
@Named
@ApplicationScoped
......@@ -29,4 +30,11 @@ public class JpaSamlAssertionDao extends JpaBaseDao<SamlAssertionEntity, Long> i
public Class<SamlAssertionEntity> getEntityClass() {
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;
@StaticMetamodel(SamlAssertionEntity.class)
public abstract class SamlAssertionEntity_ extends edu.kit.scc.webreg.entity.AbstractBaseEntity_ {
public static volatile SingularAttribute<SamlMetadataEntity, String> assertionData;
public static volatile SingularAttribute<SamlMetadataEntity, Date> validUntil;
public static volatile SingularAttribute<SamlMetadataEntity, SamlUserEntity> user;
public static volatile SingularAttribute<SamlAssertionEntity, String> assertionData;
public static volatile SingularAttribute<SamlAssertionEntity, Date> validUntil;
public static volatile SingularAttribute<SamlAssertionEntity, SamlUserEntity> user;
}
......@@ -258,6 +258,8 @@ public class UserUpdater implements Serializable {
public SamlUserEntity updateUser(SamlUserEntity user, Assertion assertion, String executor, ServiceEntity service)
throws UserUpdateException {
samlAsserionDao.deleteAssertionForUser(user);
SamlAssertionEntity samlAssertionEntity = samlAsserionDao.createNew();
samlAssertionEntity.setUser(user);
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