Commit dc53c5c9 authored by michael.simon's avatar michael.simon
Browse files

change datamodel in order to store SAML SPs and AttributeAuthorities

parent 359e34b0
/*******************************************************************************
* Copyright (c) 2014 Michael Simon.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the GNU Public License v3.0
* which accompanies this distribution, and is available at
* http://www.gnu.org/licenses/gpl.html
*
* Contributors:
* Michael Simon - initial
******************************************************************************/
package edu.kit.scc.webreg.entity;
import java.util.List;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
@Entity(name = "SamlAAMetadataEntity")
@Table(name = "aametadata")
public class SamlAAMetadataEntity extends SamlMetadataEntity {
private static final long serialVersionUID = 1L;
@ManyToMany(targetEntity = FederationEntity.class,
cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
@JoinTable(name = "aametadata_federation",
joinColumns = @JoinColumn(name = "aametadata_id"),
inverseJoinColumns = @JoinColumn(name = "federation_id"))
private Set<FederationEntity> federations;
@ElementCollection
@JoinTable(name = "aametadata_entity_categories")
@Column(name = "value_data", length = 2048)
private List<String> entityCategoryList;
public Set<FederationEntity> getFederations() {
return federations;
}
public void setFederations(Set<FederationEntity> federations) {
this.federations = federations;
}
public List<String> getEntityCategoryList() {
return entityCategoryList;
}
public void setEntityCategoryList(List<String> entityCategoryList) {
this.entityCategoryList = entityCategoryList;
}
}
......@@ -11,25 +11,18 @@
package edu.kit.scc.webreg.entity;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToMany;
import javax.persistence.MapKeyColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import org.hibernate.annotations.Type;
@Entity(name = "SamlIdpMetadataEntity")
@Table(name = "idpmetadata")
public class SamlIdpMetadataEntity extends SamlMetadataEntity {
......@@ -42,54 +35,22 @@ public class SamlIdpMetadataEntity extends SamlMetadataEntity {
joinColumns = @JoinColumn(name = "idpmetadata_id"),
inverseJoinColumns = @JoinColumn(name = "federation_id"))
private Set<FederationEntity> federations;
@Column(name = "entity_desc")
@Basic(fetch = FetchType.LAZY)
@Lob
@Type(type = "org.hibernate.type.TextType")
private String entityDescriptor;
@Column(name = "org_name", length = 512)
private String orgName;
@Column(name = "display_name", length = 512)
private String displayName;
@Column(name = "description", length = 1024)
private String description;
@Column(name = "information_url", length = 1024)
private String informationUrl;
@OneToMany(targetEntity = SamlIdpScopeEntity.class,
mappedBy = "idp", cascade = CascadeType.REMOVE)
private Set<SamlIdpScopeEntity> scopes;
@ElementCollection
@JoinTable(name = "idp_generic_store")
@MapKeyColumn(name = "key_data", length = 128)
@Column(name = "value_data", length = 2048)
private Map<String, String> genericStore;
@ElementCollection
@JoinTable(name = "idp_entity_categories")
@Column(name = "value_data", length = 2048)
private List<String> entityCategoryList;
public String getEntityDescriptor() {
return entityDescriptor;
}
public void setEntityDescriptor(String entityDescriptor) {
this.entityDescriptor = entityDescriptor;
}
public String getOrgName() {
return orgName;
public Set<FederationEntity> getFederations() {
return federations;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
public void setFederations(Set<FederationEntity> federations) {
this.federations = federations;
}
public Set<SamlIdpScopeEntity> getScopes() {
......@@ -100,46 +61,6 @@ public class SamlIdpMetadataEntity extends SamlMetadataEntity {
this.scopes = scopes;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getInformationUrl() {
return informationUrl;
}
public void setInformationUrl(String informationUrl) {
this.informationUrl = informationUrl;
}
public Map<String, String> getGenericStore() {
return genericStore;
}
public void setGenericStore(Map<String, String> genericStore) {
this.genericStore = genericStore;
}
public Set<FederationEntity> getFederations() {
return federations;
}
public void setFederations(Set<FederationEntity> federations) {
this.federations = federations;
}
public List<String> getEntityCategoryList() {
return entityCategoryList;
}
......
......@@ -10,14 +10,25 @@
******************************************************************************/
package edu.kit.scc.webreg.entity;
import java.util.List;
import java.util.Map;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.MapKeyColumn;
import javax.persistence.Table;
import org.hibernate.annotations.Type;
@Entity(name = "SamlMetadataEntity")
@Table(name = "samlmetadata")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
......@@ -30,6 +41,30 @@ public class SamlMetadataEntity extends AbstractBaseEntity {
@Enumerated(EnumType.STRING)
private SamlMetadataEntityStatus status;
@Column(name = "org_name", length = 512)
private String orgName;
@Column(name = "display_name", length = 512)
private String displayName;
@Column(name = "description", length = 1024)
private String description;
@Column(name = "information_url", length = 1024)
private String informationUrl;
@Column(name = "entity_desc")
@Basic(fetch = FetchType.LAZY)
@Lob
@Type(type = "org.hibernate.type.TextType")
private String entityDescriptor;
@ElementCollection
@JoinTable(name = "samlmetadata_generic_store")
@MapKeyColumn(name = "key_data", length = 128)
@Column(name = "value_data", length = 2048)
private Map<String, String> genericStore;
public String getEntityId() {
return entityId;
......@@ -39,6 +74,22 @@ public class SamlMetadataEntity extends AbstractBaseEntity {
this.entityId = entityId;
}
public String getOrgName() {
return orgName;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public String getEntityDescriptor() {
return entityDescriptor;
}
public void setEntityDescriptor(String entityDescriptor) {
this.entityDescriptor = entityDescriptor;
}
public SamlMetadataEntityStatus getStatus() {
return status;
}
......@@ -47,6 +98,38 @@ public class SamlMetadataEntity extends AbstractBaseEntity {
this.status = status;
}
public Map<String, String> getGenericStore() {
return genericStore;
}
public void setGenericStore(Map<String, String> genericStore) {
this.genericStore = genericStore;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getInformationUrl() {
return informationUrl;
}
public void setInformationUrl(String informationUrl) {
this.informationUrl = informationUrl;
}
@Override
public int hashCode() {
final int prime = 31;
......
......@@ -16,6 +16,8 @@ import java.util.List;
import javax.persistence.Column;
import javax.persistence.ElementCollection;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.Lob;
import javax.persistence.Table;
......@@ -24,10 +26,16 @@ import org.hibernate.annotations.Type;
@Entity
@Table(name = "spconfig")
public class SamlSpConfigurationEntity extends SamlSpMetadataEntity {
public class SamlSpConfigurationEntity extends AbstractBaseEntity {
private static final long serialVersionUID = 1L;
@Column(name = "entity_id", length = 2048)
private String entityId;
@Enumerated(EnumType.STRING)
private SamlMetadataEntityStatus status;
@Column(name = "private_key")
@Lob
@Type(type = "org.hibernate.type.TextType")
......@@ -86,4 +94,12 @@ public class SamlSpConfigurationEntity extends SamlSpMetadataEntity {
public void setEcp(String ecp) {
this.ecp = ecp;
}
public String getEntityId() {
return entityId;
}
public void setEntityId(String entityId) {
this.entityId = entityId;
}
}
......@@ -10,8 +10,13 @@
******************************************************************************/
package edu.kit.scc.webreg.entity;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
@Entity(name = "SamlSpMetadataEntity")
......@@ -20,15 +25,19 @@ public class SamlSpMetadataEntity extends SamlMetadataEntity {
private static final long serialVersionUID = 1L;
@ManyToOne(targetEntity = FederationEntity.class)
private FederationEntity federation;
@ManyToMany(targetEntity = FederationEntity.class,
cascade = { CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REFRESH})
@JoinTable(name = "spmetadata_federation",
joinColumns = @JoinColumn(name = "spmetadata_id"),
inverseJoinColumns = @JoinColumn(name = "federation_id"))
private Set<FederationEntity> federations;
public FederationEntity getFederation() {
return federation;
public Set<FederationEntity> getFederations() {
return federations;
}
public void setFederation(FederationEntity federation) {
this.federation = federation;
public void setFederations(Set<FederationEntity> federations) {
this.federations = federations;
}
}
......@@ -19,7 +19,7 @@ import org.opensaml.saml2.metadata.EntityDescriptor;
import edu.kit.scc.webreg.entity.RegistryEntity;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlSpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlSpConfigurationEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.exc.MisconfiguredServiceException;
......@@ -50,7 +50,7 @@ public interface KnowledgeSessionService {
List<Object> checkRule(String unitId, UserEntity user,
Map<String, List<Object>> attributeMap, Assertion assertion,
SamlIdpMetadataEntity idp, EntityDescriptor idpEntityDescriptor, SamlSpMetadataEntity sp)
SamlIdpMetadataEntity idp, EntityDescriptor idpEntityDescriptor, SamlSpConfigurationEntity sp)
throws MisconfiguredServiceException;
}
......@@ -35,7 +35,6 @@ import edu.kit.scc.webreg.dao.AuditEntryDao;
import edu.kit.scc.webreg.dao.RegistryDao;
import edu.kit.scc.webreg.dao.ServiceDao;
import edu.kit.scc.webreg.dao.UserDao;
import edu.kit.scc.webreg.drools.BpmProcessService;
import edu.kit.scc.webreg.drools.KnowledgeSessionService;
import edu.kit.scc.webreg.drools.OverrideAccess;
import edu.kit.scc.webreg.drools.UnauthorizedUser;
......@@ -45,7 +44,7 @@ import edu.kit.scc.webreg.entity.EventType;
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.SamlSpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlSpConfigurationEntity;
import edu.kit.scc.webreg.entity.ServiceEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.event.EventSubmitter;
......@@ -108,7 +107,7 @@ public class KnowledgeSessionServiceImpl implements KnowledgeSessionService {
@Override
public List<Object> checkRule(String unitId, UserEntity user, Map<String, List<Object>> attributeMap,
Assertion assertion, SamlIdpMetadataEntity idp, EntityDescriptor idpEntityDescriptor, SamlSpMetadataEntity sp)
Assertion assertion, SamlIdpMetadataEntity idp, EntityDescriptor idpEntityDescriptor, SamlSpConfigurationEntity sp)
throws MisconfiguredServiceException {
KieSession ksession = getStatefulSession(unitId);
......
......@@ -14,7 +14,7 @@ import java.util.List;
import java.util.Map;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlSpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlSpConfigurationEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.exc.RegisterException;
......@@ -23,7 +23,7 @@ public interface UserCreateService {
UserEntity createUser(UserEntity user, Map<String, List<Object>> attributeMap, String executor)
throws RegisterException;
UserEntity preCreateUser(SamlIdpMetadataEntity idpEntity, SamlSpMetadataEntity spEntity, String persistentId,
UserEntity preCreateUser(SamlIdpMetadataEntity idpEntity, SamlSpConfigurationEntity spEntity, String persistentId,
String locale, Map<String, List<Object>> attributeMap) throws RegisterException;
}
......@@ -29,7 +29,7 @@ import edu.kit.scc.webreg.dao.AuditEntryDao;
import edu.kit.scc.webreg.entity.AuditStatus;
import edu.kit.scc.webreg.entity.EventType;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlSpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlSpConfigurationEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.entity.UserRoleEntity;
import edu.kit.scc.webreg.entity.UserStatus;
......@@ -77,7 +77,7 @@ public class UserCreateServiceImpl implements UserCreateService {
private ApplicationConfig appConfig;
@Override
public UserEntity preCreateUser(SamlIdpMetadataEntity idpEntity, SamlSpMetadataEntity spEntity, String persistentId,
public UserEntity preCreateUser(SamlIdpMetadataEntity idpEntity, SamlSpConfigurationEntity spConfigEntity, String persistentId,
String locale, Map<String, List<Object>> attributeMap)
throws RegisterException {
......@@ -86,7 +86,7 @@ public class UserCreateServiceImpl implements UserCreateService {
UserEntity entity = userService.createNew();
entity.setIdp(idpEntity);
entity.setPersistentIdpId(idpEntity.getEntityId());
entity.setPersistentSpId(spEntity.getEntityId());
entity.setPersistentSpId(spConfigEntity.getEntityId());
entity.setPersistentId(persistentId);
entity.setRoles(new HashSet<UserRoleEntity>());
entity.setAttributeStore(new HashMap<String, String>());
......
......@@ -23,6 +23,7 @@ import javax.inject.Inject;
import org.slf4j.Logger;
import edu.kit.scc.webreg.entity.SamlIdpMetadataEntity;
import edu.kit.scc.webreg.entity.SamlSpConfigurationEntity;
import edu.kit.scc.webreg.entity.SamlSpMetadataEntity;
import edu.kit.scc.webreg.entity.UserEntity;
import edu.kit.scc.webreg.exc.RegisterException;
......@@ -62,16 +63,16 @@ public class RegisterUserBean implements Serializable {
private UserEntity entity;
private SamlIdpMetadataEntity idpEntity;
private SamlSpMetadataEntity spEntity;
private SamlSpConfigurationEntity spConfigEntity;
private Boolean errorState = false;
public void preRenderView(ComponentSystemEvent ev) {
idpEntity = idpService.findById(sessionManager.getIdpId());
spEntity = spService.findById(sessionManager.getSpId());
spConfigEntity = spService.findById(sessionManager.getSpId());
try {
entity = userCreateService.preCreateUser(idpEntity, spEntity, sessionManager.getPersistentId(),
entity = userCreateService.preCreateUser(idpEntity, spConfigEntity, sessionManager.getPersistentId(),
sessionManager.getLocale(), sessionManager.getAttributeMap());
} catch (RegisterException e) {
......
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