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

Federations complete download

parent 7a078d1b
......@@ -129,4 +129,44 @@ public class FederationEntity extends AbstractBaseEntity {
BusinessRulePackageEntity entityFilterRulePackage) {
this.entityFilterRulePackage = entityFilterRulePackage;
}
public Boolean getFetchIdps() {
return fetchIdps;
}
public void setFetchIdps(Boolean fetchIdps) {
this.fetchIdps = fetchIdps;
}
public Boolean getFetchSps() {
return fetchSps;
}
public void setFetchSps(Boolean fetchSps) {
this.fetchSps = fetchSps;
}
public Boolean getFetchAAs() {
return fetchAAs;
}
public void setFetchAAs(Boolean fetchAAs) {
this.fetchAAs = fetchAAs;
}
public Set<SamlSpMetadataEntity> getSps() {
return sps;
}
public void setSps(Set<SamlSpMetadataEntity> sps) {
this.sps = sps;
}
public Set<SamlAAMetadataEntity> getAas() {
return aas;
}
public void setAas(Set<SamlAAMetadataEntity> aas) {
this.aas = aas;
}
}
......@@ -24,6 +24,7 @@ import org.opensaml.saml2.metadata.EntitiesDescriptor;
import org.opensaml.saml2.metadata.EntityDescriptor;
import org.slf4j.Logger;
import edu.kit.scc.webreg.bootstrap.ApplicationConfig;
import edu.kit.scc.webreg.dao.BaseDao;
import edu.kit.scc.webreg.dao.FederationDao;
import edu.kit.scc.webreg.drools.KnowledgeSessionService;
......@@ -69,13 +70,32 @@ public class FederationServiceImpl extends BaseServiceImpl<FederationEntity, Lon
logger.info("Starting updateFederation for federation {}", entity.getName());
EntitiesDescriptor entities = metadataHelper.fetchMetadata(entity.getFederationMetadataUrl());
List<EntityDescriptor> entityList = metadataHelper.convertEntitiesDescriptor(entities);
List<EntityDescriptor> tempEntityList = metadataHelper.convertEntitiesDescriptor(entities);
logger.debug("Got entity List size {}", tempEntityList.size());
List<EntityDescriptor> entityList = new ArrayList<EntityDescriptor>();
if (entity.getFetchIdps()) {
logger.debug("Getting IDPs");
entityList.addAll(metadataHelper.filterIdps(tempEntityList));
}
if (entity.getFetchSps()) {
logger.debug("Getting SPs");
entityList.addAll(metadataHelper.filterSps(tempEntityList));
}
logger.debug("Got entity List size {}", entityList.size());
entityList = metadataHelper.filterSP(entityList);
if ((entity.getEntityCategoryFilter() != null) && (! entity.getEntityCategoryFilter().equals("")))
if (entity.getFetchAAs()) {
logger.debug("Getting AAs");
entityList.addAll(metadataHelper.filterAAs(tempEntityList));
}
if ((entity.getEntityCategoryFilter() != null) && (! entity.getEntityCategoryFilter().equals(""))) {
logger.debug("Filtering entity category: {}", entity.getEntityCategoryFilter());
entityList = metadataHelper.filterEntityCategory(entityList, entity.getEntityCategoryFilter());
logger.debug("Got IDP entity List size {}", entityList.size());
}
logger.debug("Got Entity List size {}", entityList.size());
if (entity.getEntityFilterRulePackage() != null) {
long a = System.currentTimeMillis();
......@@ -106,11 +126,11 @@ public class FederationServiceImpl extends BaseServiceImpl<FederationEntity, Lon
}
entity.setEntityId(entities.getName());
updateEntities(entity, entityList);
updateIdpEntities(entity, entityList);
logger.debug("Updated SAML Entities for Federation {}", entity.getName());
}
private void updateEntities(FederationEntity entity, List<EntityDescriptor> entityList) {
private void updateIdpEntities(FederationEntity entity, List<EntityDescriptor> entityList) {
entity = dao.findById(entity.getId());
......
......@@ -40,6 +40,7 @@ import org.opensaml.saml2.metadata.EntitiesDescriptor;
import org.opensaml.saml2.metadata.EntityDescriptor;
import org.opensaml.saml2.metadata.IDPSSODescriptor;
import org.opensaml.saml2.metadata.OrganizationDisplayName;
import org.opensaml.saml2.metadata.SPSSODescriptor;
import org.opensaml.saml2.metadata.SingleSignOnService;
import org.opensaml.samlext.saml2mdattr.EntityAttributes;
import org.opensaml.samlext.saml2mdui.UIInfo;
......@@ -124,7 +125,7 @@ public class MetadataHelper implements Serializable {
return entityList;
}
public List<EntityDescriptor> filterSP(List<EntityDescriptor> entities) {
public List<EntityDescriptor> filterIdps(List<EntityDescriptor> entities) {
List<EntityDescriptor> returnList = new ArrayList<EntityDescriptor>();
for (EntityDescriptor entity : entities) {
......@@ -136,6 +137,31 @@ public class MetadataHelper implements Serializable {
return returnList;
}
public List<EntityDescriptor> filterSps(List<EntityDescriptor> entities) {
List<EntityDescriptor> returnList = new ArrayList<EntityDescriptor>();
for (EntityDescriptor entity : entities) {
SPSSODescriptor spsso = entity.getSPSSODescriptor(SAMLConstants.SAML20P_NS);
if (spsso != null)
returnList.add(entity);
}
return returnList;
}
public List<EntityDescriptor> filterAAs(List<EntityDescriptor> entities) {
List<EntityDescriptor> returnList = new ArrayList<EntityDescriptor>();
for (EntityDescriptor entity : entities) {
IDPSSODescriptor idpsso = entity.getIDPSSODescriptor(SAMLConstants.SAML20P_NS);
AttributeAuthorityDescriptor aadesc = entity.getAttributeAuthorityDescriptor(SAMLConstants.SAML20P_NS);
if (idpsso == null && aadesc != null)
returnList.add(entity);
}
return returnList;
}
public List<EntityDescriptor> filterEntityCategory(List<EntityDescriptor> entities, String category) {
List<EntityDescriptor> returnList = new ArrayList<EntityDescriptor>();
......
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