public static void updateProviderKeyInfo(String realm,String entityID,String certAlias,boolean isSigning,boolean isIDP,String encAlgo,int keySize) throws IDFFMetaException {
  IDFFMetaManager metaManager=FSUtils.getIDFFMetaManager();
  EntityConfigElement config=metaManager.getEntityConfig(realm,entityID);
  if (!config.isHosted()) {
    String[] args={entityID,realm};
    throw new IDFFMetaException("entityNotHosted",args);
  }
  EntityDescriptorElement desp=metaManager.getEntityDescriptor(realm,entityID);
  if (isIDP) {
    IDPDescriptorConfigElement idpConfig=IDFFMetaUtils.getIDPDescriptorConfig(config);
    IDPDescriptorType idpDesp=IDFFMetaUtils.getIDPDescriptor(desp);
    if ((idpConfig == null) || (idpDesp == null)) {
      String[] args={entityID,realm};
      throw new IDFFMetaException("entityNotIDP",args);
    }
    if ((certAlias == null) || (certAlias.length() == 0)) {
      removeKeyDescriptor(idpDesp,isSigning);
      if (isSigning) {
        setExtendedAttributeValue(idpConfig,IFSConstants.SIGNING_CERT_ALIAS,null);
      }
 else {
        setExtendedAttributeValue(idpConfig,IFSConstants.ENCRYPTION_CERT_ALIAS,null);
      }
    }
 else {
      KeyDescriptorElement kde=getKeyDescriptor(certAlias,isSigning,encAlgo,keySize);
      updateKeyDescriptor(idpDesp,kde);
      Set value=new HashSet();
      value.add(certAlias);
      if (isSigning) {
        setExtendedAttributeValue(idpConfig,IFSConstants.SIGNING_CERT_ALIAS,value);
      }
 else {
        setExtendedAttributeValue(idpConfig,IFSConstants.ENCRYPTION_CERT_ALIAS,value);
      }
    }
    metaManager.setEntityDescriptor(realm,desp);
    metaManager.setEntityConfig(realm,config);
  }
 else {
    SPDescriptorConfigElement spConfig=IDFFMetaUtils.getSPDescriptorConfig(config);
    SPDescriptorType spDesp=IDFFMetaUtils.getSPDescriptor(desp);
    if ((spConfig == null) || (spDesp == null)) {
      String[] args={entityID,realm};
      throw new IDFFMetaException("entityNotSP",args);
    }
    if ((certAlias == null) || (certAlias.length() == 0)) {
      removeKeyDescriptor(spDesp,isSigning);
      if (isSigning) {
        setExtendedAttributeValue(spConfig,IFSConstants.SIGNING_CERT_ALIAS,null);
      }
 else {
        setExtendedAttributeValue(spConfig,IFSConstants.ENCRYPTION_CERT_ALIAS,null);
      }
    }
 else {
      KeyDescriptorElement kde=getKeyDescriptor(certAlias,isSigning,encAlgo,keySize);
      updateKeyDescriptor(spDesp,kde);
      Set value=new HashSet();
      value.add(certAlias);
      if (isSigning) {
        setExtendedAttributeValue(spConfig,IFSConstants.SIGNING_CERT_ALIAS,value);
      }
 else {
        setExtendedAttributeValue(spConfig,IFSConstants.ENCRYPTION_CERT_ALIAS,value);
      }
    }
    metaManager.setEntityDescriptor(realm,desp);
    metaManager.setEntityConfig(realm,config);
  }
}

public static void updateProviderKeyInfo ( String realm , String entityID , String certAlias , boolean isSigning , boolean isIDP , String encAlgo , int keySize ) throws IDFFMetaException { IDFFMetaManager metaManager = FSUtils . getIDFFMetaManager ( ) ; EntityConfigElement config = metaManager . getEntityConfig ( realm , entityID ) ; if ( ! config . isHosted ( ) ) { String [ ] args = { entityID , realm } ; throw new IDFFMetaException ( "entityNotHosted" , args ) ; } EntityDescriptorElement desp = metaManager . getEntityDescriptor ( realm , entityID ) ; if ( isIDP ) { IDPDescriptorConfigElement idpConfig = IDFFMetaUtils . getIDPDescriptorConfig ( config ) ; IDPDescriptorType idpDesp = IDFFMetaUtils . getIDPDescriptor ( desp ) ; if ( ( idpConfig == null ) || ( idpDesp == null ) ) { String [ ] args = { entityID , realm } ; throw new IDFFMetaException ( "entityNotIDP" , args ) ; } if ( ( certAlias == null ) || ( certAlias . length ( ) == 0 ) ) { removeKeyDescriptor ( idpDesp , isSigning ) ; if ( isSigning ) { setExtendedAttributeValue ( idpConfig , IFSConstants . SIGNING_CERT_ALIAS , null ) ; } else { setExtendedAttributeValue ( idpConfig , IFSConstants . ENCRYPTION_CERT_ALIAS , null ) ; } } else { KeyDescriptorElement kde = getKeyDescriptor ( certAlias , isSigning , encAlgo , keySize ) ; updateKeyDescriptor ( idpDesp , kde ) ; Set value = new HashSet ( ) ; value . add ( certAlias ) ; if ( isSigning ) { setExtendedAttributeValue ( idpConfig , IFSConstants . SIGNING_CERT_ALIAS , value ) ; } else { setExtendedAttributeValue ( idpConfig , IFSConstants . ENCRYPTION_CERT_ALIAS , value ) ; } } metaManager . setEntityDescriptor ( realm , desp ) ; metaManager . setEntityConfig ( realm , config ) ; } else { SPDescriptorConfigElement spConfig = IDFFMetaUtils . getSPDescriptorConfig ( config ) ; SPDescriptorType spDesp = IDFFMetaUtils . getSPDescriptor ( desp ) ; if ( ( spConfig == null ) || ( spDesp == null ) ) { String [ ] args = { entityID , realm } ; throw new IDFFMetaException ( "entityNotSP" , args ) ; } if ( ( certAlias == null ) || ( certAlias . length ( ) == 0 ) ) { removeKeyDescriptor ( spDesp , isSigning ) ; if ( isSigning ) { setExtendedAttributeValue ( spConfig , IFSConstants . SIGNING_CERT_ALIAS , null ) ; } else { setExtendedAttributeValue ( spConfig , IFSConstants . ENCRYPTION_CERT_ALIAS , null ) ; } } else { KeyDescriptorElement kde = getKeyDescriptor ( certAlias , isSigning , encAlgo , keySize ) ; updateKeyDescriptor ( spDesp , kde ) ; Set value = new HashSet ( ) ; value . add ( certAlias ) ; if ( isSigning ) { setExtendedAttributeValue ( spConfig , IFSConstants . SIGNING_CERT_ALIAS , value ) ; } else { setExtendedAttributeValue ( spConfig , IFSConstants . ENCRYPTION_CERT_ALIAS , value ) ; } } metaManager . setEntityDescriptor ( realm , desp ) ; metaManager . setEntityConfig ( realm , config ) ; } }
updates signing or encryption key info for sp or idp . this will update both signing / encryption alias on extended metadata and certificates in standard metadata .
