コード例 #1
0
        public P11Attribute Clone()
        {
            P11Attribute p11 = GetCkLoadedCopy();

            p11.metaData   = this.metaData;
            p11.isAssigned = this.isAssigned;
            return(p11);
        }
コード例 #2
0
ファイル: P11Object.cs プロジェクト: Ducis01/EidCardReader
        public static P11Attribute GetAttribute(Session session, uint hObj, P11Attribute attr)
        {
            try
            {
                uint hSession           = session.HSession;
                Wrapper.Pkcs11Module pm = session.Module.P11Module;

                CK_ATTRIBUTE tmp = pm.GetAttributeValue(hSession, hObj, new CK_ATTRIBUTE[] { attr.CK_ATTRIBUTE })[0];
                P11Attribute p11 = attr.Clone().Load(tmp);
                p11.MetaData.IsPresent   = true;
                p11.MetaData.IsSensitive = false;
                return(p11);
            }
            catch (TokenException tex)
            {
                if (tex.ErrorCode == CKR.ATTRIBUTE_TYPE_INVALID ||
                    tex.ErrorCode == CKR.ATTRIBUTE_VALUE_INVALID)
                {
                    P11Attribute p11 = attr.Clone();
                    p11.MetaData.IsPresent   = false;
                    p11.MetaData.IsSensitive = false;
                    return(p11);
                }
                else if (tex.ErrorCode == CKR.ATTRIBUTE_SENSITIVE)
                {
                    P11Attribute p11 = attr.Clone();
                    p11.MetaData.IsPresent   = true;
                    p11.MetaData.IsSensitive = true;
                    return(p11);
                }
                else
                {
                    throw tex;
                }
            }
        }
コード例 #3
0
ファイル: P11Object.cs プロジェクト: Ducis01/EidCardReader
        protected static P11Attribute AssignAttributeFromObj(Session session, uint hObj, P11Attribute attr)
        {
            uint hSession = session.HSession;

            Wrapper.Pkcs11Module pm = session.Module.P11Module;
            try
            {
                return(attr.Load(pm.GetAttributeValue(hSession, hObj, new CK_ATTRIBUTE[] { attr.CK_ATTRIBUTE })[0]));
            }
            catch
            {//TODO:sadece attribute not found handle et
                return(null);
            }
        }