2 * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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
19 namespace Tizen.Security.SecureRepository
22 /// This class is a base class of XxxManager classes. It provides the common methods
23 /// for all sub classes.
25 /// <since_tizen> 3 </since_tizen>
29 /// Creates a new full alias which is concatenation of owner id and alias.
31 /// <since_tizen> 3 </since_tizen>
32 /// <param name="ownerId">Data owner's id. This should be package id if data
33 /// owner is application. If you want to access data stored by system services,
34 /// use CreateFullSystemAlias() instead.</param>
35 /// <param name="alias">Data alias.</param>
36 static public string CreateFullAlias(string ownerId, string alias)
38 return ownerId + Manager.OwnerIdSeperator + alias;
42 /// Creates a new full alias which is concatenation of system service's
43 /// owner id and alias.
45 /// <since_tizen> 3 </since_tizen>
46 /// <param name="alias">Data alias which is owned by system service.</param>
47 static public string CreateFullSystemAlias(string alias)
49 return Manager.CreateFullAlias(Manager.SystemOwnerId, alias);
53 /// Removes a an entry (no matter of type) from the key manager.
55 /// <since_tizen> 3 </since_tizen>
56 /// <param name="alias">Item alias to be removed.</param>
57 /// <exception cref="ArgumentNullException">alias is null.</exception>
58 /// <exception cref="ArgumentException">alias is invalid format.</exception>
59 /// <exception cref="InvalidOperationException">alias does not exist.</exception>
61 /// To remove item, client must have remove permission to the specified item.
63 /// <remarks>The item owner can remove by default.</remarks>
64 static public void RemoveAlias(string alias)
67 throw new ArgumentNullException("alias should not be null");
69 Interop.CheckNThrowException(
70 Interop.CkmcManager.RemoveAlias(alias),
71 "Failed to remove alias. alias=" + alias);
75 /// Allows another application to access client's application data.
77 /// <since_tizen> 3 </since_tizen>
78 /// <param name="alias">Item alias for which access will be granted.</param>
79 /// <param name="otherPackageId">
80 /// Package id of the application that will gain access rights.
82 /// <param name="permissions">
83 /// Mask of permissions(Permission enum) granted for an application with
86 /// <exception cref="ArgumentNullException">
87 /// alias or otherPackageId is null.
89 /// <exception cref="ArgumentException">
90 /// alias or otherPackageId is invalid format.
92 /// <exception cref="InvalidOperationException">alias does not exist.</exception>
93 /// <remarks>Data identified by alias should exist.</remarks>
94 /// <remarks>The item owner can set permissions.</remarks>
95 static public void SetPermission(
96 string alias, string otherPackageId, int permissions)
98 if (alias == null || otherPackageId == null)
99 throw new ArgumentNullException("alias or otherPackageId is null");
101 Interop.CheckNThrowException(
102 Interop.CkmcManager.SetPermission(alias, otherPackageId, permissions),
103 "Failed to set permission. alias=" + alias);
106 // to being static base class
111 private const string OwnerIdSeperator = " ";
112 private const string SystemOwnerId = "/System";