# Policy Information Provider (PIP)

`IPolicyInformationService` in assembly SanteDB.Core.Api version 3.0.1980.0

## Summary

Represents a contract for a policy information service

## Operations

| Operation         | Response/Return               | Input/Parameter                                                                                                                                                                                         | Description                                                   |
| ----------------- | ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| GetPolicies       | IEnumerable\<IPolicyInstance> | *Object* **securable**                                                                                                                                                                                  | Get all active policies for the specified securable type      |
| GetPolicies       | IEnumerable\<IPolicy>         | *none*                                                                                                                                                                                                  | Get all active policies for the specified securable type      |
| GetPolicy         | IPolicy                       | *String* **policyOid**                                                                                                                                                                                  | Get a specific policy                                         |
| AddPolicies       | void                          | <p><em>Object</em> <strong>securable</strong><br><em>PolicyGrantType</em> <strong>rule</strong><br><em>IPrincipal</em> <strong>principal</strong><br><em>String\[]</em> <strong>policyOids</strong></p> | Adds the specified policies to the specified securable object |
| GetPolicyInstance | IPolicyInstance               | <p><em>Object</em> <strong>securable</strong><br><em>String</em> <strong>policyOid</strong></p>                                                                                                         | Gets the policy instance for the specified object             |
| HasPolicy         | Boolean                       | <p><em>Object</em> <strong>securable</strong><br><em>String</em> <strong>policyOid</strong></p>                                                                                                         | Returns true if has assigned to it                            |
| RemovePolicies    | void                          | <p><em>Object</em> <strong>securable</strong><br><em>IPrincipal</em> <strong>principal</strong><br><em>String\[]</em> <strong>oid</strong></p>                                                          | Removes the specified policies from the user account          |
| CreatePolicy      | void                          | <p><em>IPolicy</em> <strong>policy</strong><br><em>IPrincipal</em> <strong>principal</strong></p>                                                                                                       | Create in the policy information point                        |

## Implementations

### BridgedPolicyInformationService - (SanteDB.Client)

Policy information service that uses either local or upstream policy provider.

#### Service Registration

```markup
...
<section xsi:type="ApplicationServiceContextConfigurationSection" threadPoolSize="4">
	<serviceProviders>
		...
		<add type="SanteDB.Client.Upstream.Security.BridgedPolicyInformationService, SanteDB.Client, Version=3.0.1980.0, Culture=neutral, PublicKeyToken=null" />
		...
	</serviceProviders>
```

### UpstreamPolicyInformationService - (SanteDB.Client)

Represents a policy information service which communicates with an upstream policy information service

#### Service Registration

```markup
...
<section xsi:type="ApplicationServiceContextConfigurationSection" threadPoolSize="4">
	<serviceProviders>
		...
		<add type="SanteDB.Client.Upstream.Repositories.UpstreamPolicyInformationService, SanteDB.Client, Version=3.0.1980.0, Culture=neutral, PublicKeyToken=null" />
		...
	</serviceProviders>
```

### AdoPolicyInformationService - (SanteDB.Persistence.Data)

A PIP service which stores data in the database

#### Service Registration

```markup
...
<section xsi:type="ApplicationServiceContextConfigurationSection" threadPoolSize="4">
	<serviceProviders>
		...
		<add type="SanteDB.Persistence.Data.Services.AdoPolicyInformationService, SanteDB.Persistence.Data, Version=3.0.1980.0, Culture=neutral, PublicKeyToken=null" />
		...
	</serviceProviders>
```

## Example Implementation

```csharp
/// Example Implementation
using SanteDB.Core.Security.Services;
/// Other usings here
public class MyPolicyInformationService : SanteDB.Core.Security.Services.IPolicyInformationService { 
	public String ServiceName => "My own IPolicyInformationService service";
	/// <summary>
	/// Get all active policies for the specified securable type
	/// </summary>
	public IEnumerable<IPolicyInstance> GetPolicies(Object securable){
		throw new System.NotImplementedException();
	}
	/// <summary>
	/// Get all active policies for the specified securable type
	/// </summary>
	public IEnumerable<IPolicy> GetPolicies(){
		throw new System.NotImplementedException();
	}
	/// <summary>
	/// Get a specific policy
	/// </summary>
	public IPolicy GetPolicy(String policyOid){
		throw new System.NotImplementedException();
	}
	/// <summary>
	/// Adds the specified policies to the specified securable object
	/// </summary>
	public void AddPolicies(Object securable,PolicyGrantType rule,IPrincipal principal,String[] policyOids){
		throw new System.NotImplementedException();
	}
	/// <summary>
	/// Gets the policy instance for the specified object
	/// </summary>
	public IPolicyInstance GetPolicyInstance(Object securable,String policyOid){
		throw new System.NotImplementedException();
	}
	/// <summary>
	/// Returns true if  has  assigned to it
	/// </summary>
	public Boolean HasPolicy(Object securable,String policyOid){
		throw new System.NotImplementedException();
	}
	/// <summary>
	/// Removes the specified policies from the user account
	/// </summary>
	public void RemovePolicies(Object securable,IPrincipal principal,String[] oid){
		throw new System.NotImplementedException();
	}
	/// <summary>
	/// Create  in the policy information point
	/// </summary>
	public void CreatePolicy(IPolicy policy,IPrincipal principal){
		throw new System.NotImplementedException();
	}
}
```

## References

* [IPolicyInformationService C# Documentation](http://santesuite.org/assets/doc/net/html/T_SanteDB_Core_Security_Services_IPolicyInformationService.htm)
* [BridgedPolicyInformationService C# Documentation](http://santesuite.org/assets/doc/net/html/T_SanteDB_Client_Upstream_Security_BridgedPolicyInformationService.htm)
* [UpstreamPolicyInformationService C# Documentation](http://santesuite.org/assets/doc/net/html/T_SanteDB_Client_Upstream_Repositories_UpstreamPolicyInformationService.htm)
* [AdoPolicyInformationService C# Documentation](http://santesuite.org/assets/doc/net/html/T_SanteDB_Persistence_Data_Services_AdoPolicyInformationService.htm)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.santesuite.org/developers/server-plugins/implementing-.net-features/service-definitions/policy-information-provider-pip.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
