Exemplo n.º 1
0
 /// <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);
     }
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
        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());
        }
Exemplo n.º 4
0
        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);
        }