Commit 90e83c9a authored by michael.simon's avatar michael.simon
Browse files

remove deprecated persistentIdpId field

parent 8003a97e
......@@ -14,13 +14,13 @@ public class SamlUserEntity extends UserEntity {
@Column(name = "persistent_id", length = 1024)
private String persistentId;
@Column(name = "saml_subject_id", length = 1024)
private String subjectId;
@Column(name = "persistent_spid", length = 1024)
private String persistentSpId;
@Column(name = "persistent_idpid", length = 1024)
private String persistentIdpId;
@ManyToOne(targetEntity = SamlIdpMetadataEntity.class)
private SamlIdpMetadataEntity idp;
......@@ -43,16 +43,6 @@ public class SamlUserEntity extends UserEntity {
this.persistentSpId = persistentSpId;
}
@Deprecated
public String getPersistentIdpId() {
return persistentIdpId;
}
@Deprecated
public void setPersistentIdpId(String persistentIdpId) {
this.persistentIdpId = persistentIdpId;
}
public SamlIdpMetadataEntity getIdp() {
return idp;
}
......@@ -68,4 +58,12 @@ public class SamlUserEntity extends UserEntity {
public void setAssertions(Set<SamlAssertionEntity> assertions) {
this.assertions = assertions;
}
public String getSubjectId() {
return subjectId;
}
public void setSubjectId(String subjectId) {
this.subjectId = subjectId;
}
}
......@@ -17,6 +17,7 @@ import java.util.List;
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Named;
import javax.persistence.NoResultException;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.JoinType;
......@@ -78,18 +79,13 @@ public class JpaSamlUserDao extends JpaBaseDao<SamlUserEntity, Long> implements
@Override
public SamlUserEntity findByPersistent(String spId, String idpId, String persistentId) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<SamlUserEntity> criteria = builder.createQuery(SamlUserEntity.class);
Root<SamlUserEntity> user = criteria.from(SamlUserEntity.class);
criteria.where(builder.and(
builder.equal(user.get("persistentSpId"), spId),
builder.equal(user.get("persistentIdpId"), idpId),
builder.equal(user.get("persistentId"), persistentId)
));
criteria.select(user);
TypedQuery<SamlUserEntity> query = em.createQuery("select u from SamlUserEntity u where u.persistentSpId = :spId and u.idp.entityId = :idpId and "
+ "u.persistentId = :persistentId", SamlUserEntity.class).setParameter("spId", spId)
.setParameter("idpId", idpId).setParameter("persistentId", persistentId);
try {
return em.createQuery(criteria).getSingleResult();
return query.getSingleResult();
}
catch (NoResultException e) {
return null;
......
......@@ -95,7 +95,6 @@ public class UserCreateServiceImpl implements UserCreateService {
SamlUserEntity entity = samlUserDao.createNew();
entity.setIdp(idpEntity);
entity.setPersistentIdpId(idpEntity.getEntityId());
entity.setPersistentSpId(spConfigEntity.getEntityId());
entity.setPersistentId(persistentId);
entity.setRoles(new HashSet<UserRoleEntity>());
......
......@@ -171,17 +171,17 @@ public class Saml2AssertionService {
}
/*
* prefer subject-id over pairwise-id over persistent
* prefer pairwise-id over persistent over subject-id
*/
if (samlIdentifier.getSubjectId() != null) {
return samlIdentifier.getSubjectId();
}
else if (samlIdentifier.getPairwiseId() != null) {
if (samlIdentifier.getPairwiseId() != null) {
return samlIdentifier.getPairwiseId();
}
else if (samlIdentifier.getPersistentId() != null) {
return samlIdentifier.getPersistentId();
}
else if (samlIdentifier.getSubjectId() != null) {
return samlIdentifier.getSubjectId();
}
else {
throw new SamlAuthenticationException("No usable identifier found. Acceptable identifiers are Pairwise-ID, Subject-ID or Persistent ID");
}
......
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