private void DeployDefinition(object modelHost, SPFarm spFarm, SecureStoreApplicationDefinition definition)
        {
            var currentObject = GetCurrentSecureStoreApplication(spFarm, definition);

            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioning,
                Object = currentObject,
                ObjectType = typeof(ISecureStore),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });


            InvokeOnModelEvent(this, new ModelEventArgs
            {
                CurrentModelNode = null,
                Model = null,
                EventType = ModelEventType.OnProvisioned,
                Object = currentObject,
                ObjectType = typeof(ISecureStore),
                ObjectDefinition = definition,
                ModelHost = modelHost
            });
        }
 protected ISecureStore GetCurrentSecureStoreApplication(SPFarm spFarm, SecureStoreApplicationDefinition definition)
 {
     if (definition.UseDefault)
     {
         var context = SPServiceContext.GetContext(SPServiceApplicationProxyGroup.Default, SPSiteSubscriptionIdentifier.Default);
         var ssp = new SecureStoreServiceProxy();
         return ssp.GetSecureStore(context);
     }
     else
     {
         throw new SPMeta2NotImplementedException("Secure Store resolution by Name/Id is not supported yet. Please use 'UseDefault' property set 'true' instead.");
     }
 }
 public static ModelNode AddHostSecureStoreApplication(this ModelNode model, SecureStoreApplicationDefinition definition)
 {
     return AddHostSecureStoreApplication(model, definition, null);
 }
 public static ModelNode AddHostSecureStoreApplication(this ModelNode model, SecureStoreApplicationDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNodeWithOptions(definition, action, ModelNodeOptions.New().NoSelfProcessing());
 }
 public static ModelNode AddSecureStoreApplication(this ModelNode model, SecureStoreApplicationDefinition definition, Action<ModelNode> action)
 {
     return model.AddDefinitionNode(definition, action);
 }