Release 4.0.0-preview1-00051
[platform/core/csapi/tizenfx.git] / src / Tizen.Security.SecureRepository / Tizen.Security.SecureRepository / Policy.cs
1 /*
2  *  Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License
15  */
16
17 using System;
18 using static Interop;
19
20 namespace Tizen.Security.SecureRepository
21 {
22     /// <summary>
23     /// A class for a policy for storing key, certificate, and binary data.
24     /// </summary>
25     /// <since_tizen> 3 </since_tizen>
26     public class Policy
27     {
28         /// <summary>
29         /// A default constructor of Policy with default policy.
30         /// </summary>
31         /// <since_tizen> 3 </since_tizen>
32         /// <remarks>The default value for Password is null and the default value for Extractabl is false.</remarks>
33         public Policy()
34         {
35             Password = null;
36             Extractable = true;
37         }
38
39         /// <summary>
40         /// A constructor of Key that takes the password and the flag for extractable.
41         /// </summary>
42         /// <since_tizen> 3 </since_tizen>
43         /// <param name="password">Used to encrypt data secure repository.</param>
44         /// <param name="extractable">If true key may be extracted from secure repository.</param>
45         public Policy(String password, bool extractable)
46         {
47             Password = password;
48             Extractable = extractable;
49         }
50
51         /// <summary>
52         /// Used to encrypt data secure repository. If it is not null, the data
53         /// (or key, or certificate) is stored encrypted with this password inside secure repository
54         /// </summary>
55         /// <since_tizen> 3 </since_tizen>
56         public String Password
57         {
58             get; set;
59         }
60
61         /// <summary>
62         /// If true key may be extracted from secure repository.
63         /// </summary>
64         /// <since_tizen> 3 </since_tizen>
65         public bool Extractable
66         {
67             get; set;
68         }
69
70         internal CkmcPolicy ToCkmcPolicy()
71         {
72             return new Interop.CkmcPolicy(Password, Extractable);
73         }
74     }
75 }