/// <summary>
        /// Convert to service model
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static GroupDocument ToDocumentModel(
            this TrustGroupRegistrationModel model)
        {
            var document = new GroupDocument {
                GroupId = model.Id,
                Name    = model.Group.Name,
                IssuedSignatureAlgorithm = model.Group.IssuedSignatureAlgorithm,
                IssuedKeySize            = model.Group.IssuedKeySize,
                IssuedLifetime           = model.Group.IssuedLifetime,
                SignatureAlgorithm       = model.Group.SignatureAlgorithm,
                KeySize     = model.Group.KeySize,
                Lifetime    = model.Group.Lifetime,
                ParentId    = model.Group.ParentId,
                SubjectName = model.Group.SubjectName,
                Type        = model.Group.Type.ToString()
            };

            return(document);
        }
Example #2
0
        /// <summary>
        /// Create default configuration
        /// </summary>
        /// <param name="request"></param>
        /// <param name="parent"></param>
        /// <returns></returns>
        public static TrustGroupRegistrationModel ToRegistration(
            this TrustGroupRegistrationRequestModel request, TrustGroupModel parent)
        {
            var config = new TrustGroupRegistrationModel {
                Id    = Guid.NewGuid().ToString(),
                Group = new TrustGroupModel {
                    Name                     = request.Name ?? "Default",
                    SubjectName              = request.SubjectName ?? kDefaultSubject,
                    Type                     = parent.Type,
                    Lifetime                 = parent.IssuedLifetime,
                    SignatureAlgorithm       = parent.IssuedSignatureAlgorithm,
                    KeySize                  = parent.IssuedKeySize,
                    IssuedLifetime           = request.IssuedLifetime ?? parent.IssuedLifetime / 2,
                    IssuedSignatureAlgorithm = request.IssuedSignatureAlgorithm ??
                                               parent.IssuedSignatureAlgorithm,
                    IssuedKeySize = request.IssuedKeySize ?? parent.IssuedKeySize
                }
            };

            config.Group.Validate();
            return(config);
        }
Example #3
0
        /// <summary>
        /// Create default configuration
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static TrustGroupRegistrationModel ToRegistration(
            this TrustGroupRootCreateRequestModel request)
        {
            var config = new TrustGroupRegistrationModel {
                Id    = Guid.NewGuid().ToString(),
                Group = new TrustGroupModel {
                    Name               = request.Name ?? "Default",
                    SubjectName        = request.SubjectName ?? kDefaultSubject,
                    Type               = request.Type,
                    Lifetime           = request.Lifetime,
                    SignatureAlgorithm = request.SignatureAlgorithm ??
                                         SignatureAlgorithm.Rsa256,
                    KeySize                  = request.KeySize ?? 2048,
                    IssuedLifetime           = request.IssuedLifetime ?? request.Lifetime / 2,
                    IssuedSignatureAlgorithm = request.IssuedSignatureAlgorithm ??
                                               SignatureAlgorithm.Rsa256,
                    IssuedKeySize = request.IssuedKeySize ?? 2048
                }
            };

            config.Group.Validate();
            return(config);
        }