Skip to content
Snippets Groups Projects
Commit ad4be90f authored by Michael Simon's avatar Michael Simon
Browse files

introduce attributequery status for idp

parent 82108e8e
No related branches found
No related tags found
No related merge requests found
......@@ -10,6 +10,7 @@
******************************************************************************/
package edu.kit.scc.webreg.entity;
import java.util.Date;
import java.util.List;
import java.util.Set;
......@@ -17,6 +18,8 @@ import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
......@@ -45,6 +48,18 @@ public class SamlIdpMetadataEntity extends SamlMetadataEntity {
@Column(name = "value_data", length = 2048)
private List<String> entityCategoryList;
@Enumerated(EnumType.STRING)
private SamlIdpMetadataEntityStatus aqIdpStatus;
@Column(name = "last_aq_status_change")
private Date lastAqStatusChange;
@Enumerated(EnumType.STRING)
private SamlIdpMetadataEntityStatus idIdpStatus;
@Column(name = "last_id_status_change")
private Date lastIdStatusChange;
public Set<FederationEntity> getFederations() {
return federations;
}
......@@ -68,4 +83,36 @@ public class SamlIdpMetadataEntity extends SamlMetadataEntity {
public void setEntityCategoryList(List<String> entityCategoryList) {
this.entityCategoryList = entityCategoryList;
}
public SamlIdpMetadataEntityStatus getAqIdpStatus() {
return aqIdpStatus;
}
public void setAqIdpStatus(SamlIdpMetadataEntityStatus aqIdpStatus) {
this.aqIdpStatus = aqIdpStatus;
}
public Date getLastAqStatusChange() {
return lastAqStatusChange;
}
public void setLastAqStatusChange(Date lastAqStatusChange) {
this.lastAqStatusChange = lastAqStatusChange;
}
public SamlIdpMetadataEntityStatus getIdIdpStatus() {
return idIdpStatus;
}
public void setIdIdpStatus(SamlIdpMetadataEntityStatus idIdpStatus) {
this.idIdpStatus = idIdpStatus;
}
public Date getLastIdStatusChange() {
return lastIdStatusChange;
}
public void setLastIdStatusChange(Date lastIdStatusChange) {
this.lastIdStatusChange = lastIdStatusChange;
}
}
package edu.kit.scc.webreg.entity;
public enum SamlIdpMetadataEntityStatus {
GOOD,
FAULTY
}
......@@ -10,7 +10,6 @@
******************************************************************************/
package edu.kit.scc.webreg.entity;
import java.util.List;
import java.util.Map;
import javax.persistence.Basic;
......
......@@ -39,6 +39,7 @@ import edu.kit.scc.webreg.entity.GroupEntity;
import edu.kit.scc.webreg.entity.RegistryEntity;
import edu.kit.scc.webreg.entity.RegistryStatus;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntityStatus;
import edu.kit.scc.webreg.entity.SamlSpConfigurationEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.UserEntity;
......@@ -279,6 +280,7 @@ public class UserUpdater implements Serializable {
* This exception is thrown if the certificate chain is incomplete e.g.
*/
updateFail(user, e);
updateIdpStatus(SamlIdpMetadataEntityStatus.FAULTY, idpEntity);
throw new UserUpdateException(e);
} catch (MetadataException e) {
/*
......@@ -286,9 +288,11 @@ public class UserUpdater implements Serializable {
* with the sp certificate
*/
updateFail(user, e);
updateIdpStatus(SamlIdpMetadataEntityStatus.FAULTY, idpEntity);
throw new UserUpdateException(e);
} catch (SecurityException e) {
updateFail(user, e);
updateIdpStatus(SamlIdpMetadataEntityStatus.FAULTY, idpEntity);
throw new UserUpdateException(e);
}
......@@ -318,22 +322,34 @@ public class UserUpdater implements Serializable {
assertion = null;
}
updateIdpStatus(SamlIdpMetadataEntityStatus.GOOD, idpEntity);
return updateUser(user, assertion, "attribute-query", service);
} catch (DecryptionException e) {
updateFail(user, e);
updateIdpStatus(SamlIdpMetadataEntityStatus.FAULTY, idpEntity);
throw new UserUpdateException(e);
} catch (IOException e) {
updateFail(user, e);
updateIdpStatus(SamlIdpMetadataEntityStatus.FAULTY, idpEntity);
throw new UserUpdateException(e);
} catch (SamlAuthenticationException e) {
/*
* Thrown if i.e. the AttributeQuery profile is not configured correctly
*/
updateFail(user, e);
updateIdpStatus(SamlIdpMetadataEntityStatus.FAULTY, idpEntity);
throw new UserUpdateException(e);
}
}
protected void updateIdpStatus(SamlIdpMetadataEntityStatus status, SamlIdpMetadataEntity idpEntity) {
if (! status.equals(idpEntity.getAqIdpStatus())) {
idpEntity.setAqIdpStatus(status);
idpEntity.setLastAqStatusChange(new Date());
}
}
protected void updateFail(UserEntity user, Exception e) {
user.setLastFailedUpdate(new Date());
user.setGroups(null);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment