public static void updateProviderKeyInfo(String realm,String entityID,String certAlias,boolean isIDP) throws WSFederationMetaException {
  WSFederationMetaManager metaManager=new WSFederationMetaManager();
  FederationConfigElement config=metaManager.getEntityConfig(realm,entityID);
  if (!config.isHosted()) {
    String[] args={entityID,realm};
    throw new WSFederationMetaException("entityNotHosted",args);
  }
  FederationElement desp=metaManager.getEntityDescriptor(realm,entityID);
  if (isIDP) {
    IDPSSOConfigElement idpConfig=metaManager.getIDPSSOConfig(realm,entityID);
    if ((idpConfig == null) || (desp == null)) {
      String[] args={entityID,realm};
      throw new WSFederationMetaException("entityNotIDP",args);
    }
    if ((certAlias == null) || (certAlias.length() == 0)) {
      removeKeyDescriptor(desp);
      setExtendedAttributeValue(idpConfig,SAML2Constants.SIGNING_CERT_ALIAS,null);
    }
 else {
      TokenSigningKeyInfoElement kde=getKeyDescriptor(certAlias);
      updateKeyDescriptor(desp,kde);
      Set value=new HashSet();
      value.add(certAlias);
      setExtendedAttributeValue(idpConfig,SAML2Constants.SIGNING_CERT_ALIAS,value);
    }
  }
 else {
    SPSSOConfigElement spConfig=metaManager.getSPSSOConfig(realm,entityID);
    if ((spConfig == null) || (desp == null)) {
      String[] args={entityID,realm};
      throw new WSFederationMetaException("entityNotSP",args);
    }
    if ((certAlias == null) || (certAlias.length() == 0)) {
      removeKeyDescriptor(desp);
      setExtendedAttributeValue(spConfig,SAML2Constants.SIGNING_CERT_ALIAS,null);
    }
 else {
      TokenSigningKeyInfoElement kde=getKeyDescriptor(certAlias);
      updateKeyDescriptor(desp,kde);
      Set value=new HashSet();
      value.add(certAlias);
      setExtendedAttributeValue(spConfig,SAML2Constants.SIGNING_CERT_ALIAS,value);
    }
  }
  metaManager.setFederation(realm,desp);
  metaManager.setEntityConfig(realm,config);
}

public static void updateProviderKeyInfo ( String realm , String entityID , String certAlias , boolean isIDP ) throws WSFederationMetaException { WSFederationMetaManager metaManager = new WSFederationMetaManager ( ) ; FederationConfigElement config = metaManager . getEntityConfig ( realm , entityID ) ; if ( ! config . isHosted ( ) ) { String [ ] args = { entityID , realm } ; throw new WSFederationMetaException ( "entityNotHosted" , args ) ; } FederationElement desp = metaManager . getEntityDescriptor ( realm , entityID ) ; if ( isIDP ) { IDPSSOConfigElement idpConfig = metaManager . getIDPSSOConfig ( realm , entityID ) ; if ( ( idpConfig == null ) || ( desp == null ) ) { String [ ] args = { entityID , realm } ; throw new WSFederationMetaException ( "entityNotIDP" , args ) ; } if ( ( certAlias == null ) || ( certAlias . length ( ) == 0 ) ) { removeKeyDescriptor ( desp ) ; setExtendedAttributeValue ( idpConfig , SAML2Constants . SIGNING_CERT_ALIAS , null ) ; } else { TokenSigningKeyInfoElement kde = getKeyDescriptor ( certAlias ) ; updateKeyDescriptor ( desp , kde ) ; Set value = new HashSet ( ) ; value . add ( certAlias ) ; setExtendedAttributeValue ( idpConfig , SAML2Constants . SIGNING_CERT_ALIAS , value ) ; } } else { SPSSOConfigElement spConfig = metaManager . getSPSSOConfig ( realm , entityID ) ; if ( ( spConfig == null ) || ( desp == null ) ) { String [ ] args = { entityID , realm } ; throw new WSFederationMetaException ( "entityNotSP" , args ) ; } if ( ( certAlias == null ) || ( certAlias . length ( ) == 0 ) ) { removeKeyDescriptor ( desp ) ; setExtendedAttributeValue ( spConfig , SAML2Constants . SIGNING_CERT_ALIAS , null ) ; } else { TokenSigningKeyInfoElement kde = getKeyDescriptor ( certAlias ) ; updateKeyDescriptor ( desp , kde ) ; Set value = new HashSet ( ) ; value . add ( certAlias ) ; setExtendedAttributeValue ( spConfig , SAML2Constants . SIGNING_CERT_ALIAS , value ) ; } } metaManager . setFederation ( 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 .
