/// <exception cref="System.IO.IOException"/> private void DoAccessCheck(string keyName, KeyAuthorizationKeyProvider.KeyOpType opType) { KeyProvider.Metadata metadata = provider.GetMetadata(keyName); if (metadata != null) { string aclName = metadata.GetAttributes()[KeyAclName]; CheckAccess((aclName == null) ? keyName : aclName, GetUser(), opType); } }
private static KeyProvider.Metadata ParseJSONMetadata(IDictionary valueMap) { KeyProvider.Metadata metadata = null; if (!valueMap.IsEmpty()) { metadata = new KMSClientProvider.KMSMetadata((string)valueMap[KMSRESTConstants.CipherField ], (int)valueMap[KMSRESTConstants.LengthField], (string)valueMap[KMSRESTConstants .DescriptionField], (IDictionary <string, string>)valueMap[KMSRESTConstants.AttributesField ], Extensions.CreateDate((long)valueMap[KMSRESTConstants.CreatedField]), (int)valueMap[KMSRESTConstants.VersionsField]); } return(metadata); }
public virtual Response GetMetadata(string name) { UserGroupInformation user = HttpUserGroupInformation.Get(); KMSClientProvider.CheckNotEmpty(name, "name"); KMSWebApp.GetAdminCallsMeter().Mark(); AssertAccess(KMSACLs.Type.GetMetadata, user, KMS.KMSOp.GetMetadata, name); KeyProvider.Metadata metadata = user.DoAs(new _PrivilegedExceptionAction_287(this , name)); object json = KMSServerJSONUtils.ToJSON(name, metadata); kmsAudit.Ok(user, KMS.KMSOp.GetMetadata, name, string.Empty); return(Response.Ok().Type(MediaType.ApplicationJson).Entity(json).Build()); }
public static IDictionary ToJSON(string keyName, KeyProvider.Metadata meta) { IDictionary json = new LinkedHashMap(); if (meta != null) { json[KMSRESTConstants.NameField] = keyName; json[KMSRESTConstants.CipherField] = meta.GetCipher(); json[KMSRESTConstants.LengthField] = meta.GetBitLength(); json[KMSRESTConstants.DescriptionField] = meta.GetDescription(); json[KMSRESTConstants.AttributesField] = meta.GetAttributes(); json[KMSRESTConstants.CreatedField] = meta.GetCreated().GetTime(); json[KMSRESTConstants.VersionsField] = (long)meta.GetVersions(); } return(json); }