示例#1
0
 /**
  * Updates the entity config to update the values of the <code>cotlist</code> attribute.
  *
  * @param realm realm the entity resides in.
  * @param configList the list containing config elements.
  * @param cotName the circle of trust name.
  * @param entityConfig the <code>EntityConfigElement</code> object
  * @param objFactory the object factory object
  * @param idffMetaMgr the <code>IDFFMetaManager</code> object.
  * @throws <code>IDFFMetaException</code> if there is an error retrieving and updating the
  *     entityConfig.
  * @throws <code>JAXBException</code> if there is an error setting the config.
  */
 private void updateCOTAttrInConfig(
     String realm,
     List configList,
     String cotName,
     EntityConfigElement entityConfig,
     ObjectFactory objFactory,
     IDFFMetaManager idffMetaMgr)
     throws IDFFMetaException, JAXBException {
   boolean foundCOT = false;
   for (Iterator iter = configList.iterator(); iter.hasNext(); ) {
     BaseConfigType bConfig = (BaseConfigType) iter.next();
     List list = bConfig.getAttribute();
     for (Iterator iter2 = list.iterator(); iter2.hasNext(); ) {
       AttributeType avp = (AttributeType) iter2.next();
       if (avp.getName().trim().equalsIgnoreCase(COT_LIST)) {
         foundCOT = true;
         List avpl = avp.getValue();
         if (avpl.isEmpty() || !containsValue(avpl, cotName)) {
           avpl.add(cotName);
           idffMetaMgr.setEntityConfig(realm, entityConfig);
           break;
         }
       }
     }
     // no cot_list in the original entity config
     if (!foundCOT) {
       AttributeType atype = objFactory.createAttributeType();
       atype.setName(COT_LIST);
       atype.getValue().add(cotName);
       list.add(atype);
       idffMetaMgr.setEntityConfig(realm, entityConfig);
     }
   }
 }
示例#2
0
  /**
   * 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);
      }
    }
  }