/** * Updates the entity config to add the circle of turst name to the <code>cotlist</code> * attribute. The Service Provider and Identity Provider Configurations are updated. * * @param realm realm the entity resides in. * @param cotName the circle of trust name. * @param entityID the name of the Entity identifier. * @throws IDFFMetaException if there is a configuration error when updating the configuration. * @throws JAXBException is there is an error updating the entity configuration. */ public void updateEntityConfig(String realm, String cotName, String entityID) throws IDFFMetaException, JAXBException { String classMethod = "IDFFCOTUtils.updateEntityConfig: "; IDFFMetaManager idffMetaMgr = new IDFFMetaManager(callerSession); ObjectFactory objFactory = new ObjectFactory(); // Check whether the entity id existed in the DS EntityDescriptorElement entityDesc = idffMetaMgr.getEntityDescriptor(realm, entityID); if (entityDesc == null) { debug.error(classMethod + " No such entity: " + entityID); String[] data = {entityID}; throw new IDFFMetaException("invalidEntityID", data); } EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityID); if (entityConfig == null) { // create entity config and add the cot attribute BaseConfigType IDFFCOTUtils = null; AttributeType atype = objFactory.createAttributeType(); atype.setName(COT_LIST); atype.getValue().add(cotName); // add to entityConfig entityConfig = objFactory.createEntityConfigElement(); entityConfig.setEntityID(entityID); entityConfig.setHosted(false); // Decide which role EntityDescriptorElement includes // It could have one sp and one idp. if (IDFFMetaUtils.getSPDescriptor(entityDesc) != null) { IDFFCOTUtils = objFactory.createSPDescriptorConfigElement(); IDFFCOTUtils.getAttribute().add(atype); entityConfig.getSPDescriptorConfig().add(IDFFCOTUtils); } if (IDFFMetaUtils.getIDPDescriptor(entityDesc) != null) { IDFFCOTUtils = objFactory.createIDPDescriptorConfigElement(); IDFFCOTUtils.getAttribute().add(atype); entityConfig.getIDPDescriptorConfig().add(IDFFCOTUtils); } if (entityDesc.getAffiliationDescriptor() != null) { IDFFCOTUtils = objFactory.createAffiliationDescriptorConfigElement(); IDFFCOTUtils.getAttribute().add(atype); entityConfig.setAffiliationDescriptorConfig(IDFFCOTUtils); } idffMetaMgr.setEntityConfig(realm, entityConfig); } else { // update the sp and idp entity config List spConfigList = entityConfig.getSPDescriptorConfig(); List idpConfigList = entityConfig.getIDPDescriptorConfig(); updateCOTAttrInConfig(realm, spConfigList, cotName, entityConfig, objFactory, idffMetaMgr); updateCOTAttrInConfig(realm, idpConfigList, cotName, entityConfig, objFactory, idffMetaMgr); BaseConfigType affiConfig = entityConfig.getAffiliationDescriptorConfig(); if (affiConfig != null) { List affiConfigList = new ArrayList(); affiConfigList.add(affiConfig); updateCOTAttrInConfig( realm, affiConfigList, cotName, entityConfig, objFactory, idffMetaMgr); } } }
/** * Removes the circle trust name passed from the <code>cotlist</code> list attribute in the Entity * Config. The Service Provider and Identity Provider Entity Configuration are updated. * * @param realm realm the entity resides in. * @param cotName the circle of trust name to be removed. * @param entityID the entity identifier of the provider. * @throws IDFFMetaException if there is an error updating the entity config. * @throws JAXBException if there is an error updating the entity config. */ public void removeFromEntityConfig(String realm, String cotName, String entityID) throws IDFFMetaException, JAXBException { String classMethod = "IDFFCOTUtils.removeFromEntityConfig: "; IDFFMetaManager idffMetaMgr = new IDFFMetaManager(callerSession); // Check whether the entity id existed in the DS EntityDescriptorElement entityDesc = idffMetaMgr.getEntityDescriptor(realm, entityID); if (entityDesc == null) { debug.error(classMethod + "No such entity: " + entityID); String[] data = {entityID}; throw new IDFFMetaException("invalidEntityID", data); } EntityConfigElement entityConfig = idffMetaMgr.getEntityConfig(realm, entityID); if (entityConfig != null) { List spConfigList = entityConfig.getSPDescriptorConfig(); List idpConfigList = entityConfig.getIDPDescriptorConfig(); removeCOTNameFromConfig(realm, spConfigList, cotName, entityConfig, idffMetaMgr); removeCOTNameFromConfig(realm, idpConfigList, cotName, entityConfig, idffMetaMgr); BaseConfigType affiConfig = entityConfig.getAffiliationDescriptorConfig(); if (affiConfig != null) { List affiConfigList = new ArrayList(); affiConfigList.add(affiConfig); removeCOTNameFromConfig(realm, affiConfigList, cotName, entityConfig, idffMetaMgr); } } }