Exemplo n.º 1
0
        public void Setup()
        {
            var realmService = new FakeRealmService("CORP.BLAH.COM");

            this.principal = realmService.Principals.Find(KrbPrincipalName.FromString("*****@*****.**"));
            this.pac       = this.principal.GeneratePac();
            this.key       = new KerberosKey(new byte[32], etype: EncryptionType.AES256_CTS_HMAC_SHA1_96);

            var groups = new List <GroupMembership>();

            for (var i = 0; i < this.GroupSize; i++)
            {
                groups.Add(new GroupMembership
                {
                    Attributes = SidAttributes.SE_GROUP_ENABLED | SidAttributes.SE_GROUP_MANDATORY,
                    RelativeId = (uint)i
                });
            }

            this.pac.LogonInfo.GroupIds = groups;

            var extra = new List <RpcSidAttributes>();

            for (var i = 0; i < this.ExtraSize; i++)
            {
                extra.Add(new RpcSidAttributes
                {
                    Attributes = SidAttributes.SE_GROUP_ENABLED | SidAttributes.SE_GROUP_MANDATORY,
                    Sid        = new RpcSid()
                    {
                        IdentifierAuthority = new RpcSidIdentifierAuthority
                        {
                            IdentifierAuthority = new byte[] { 0, 0, 0, 0, 0, (byte)IdentifierAuthority.NTAuthority }
                        },
                        SubAuthority = new uint[] { 21, 3333, 4444, 5555, 111 },
                        Revision     = 1
                    }
                });
            }

            this.pac.LogonInfo.ExtraIds = extra;
        }
Exemplo n.º 2
0
        public void GenerateTgt()
        {
            var realmService = new FakeRealmService(Realm);
            var principal    = realmService.Principals.Find(KrbPrincipalName.FromString(UserUpn));

            var principalKey = principal.RetrieveLongTermCredential();

            var rst = new ServiceTicketRequest
            {
                Flags               = TicketFlags.EncryptedPreAuthentication | TicketFlags.Renewable | TicketFlags.Forwardable,
                Principal           = principal,
                EncryptedPartKey    = principalKey,
                ServicePrincipalKey = new KerberosKey(key: TgtKey, etype: etype, kvno: 123)
            };

            for (var i = 0; i < AuthenticationAttempts; i++)
            {
                var tgt = KrbAsRep.GenerateTgt(rst, realmService);

                Assert.IsNotNull(tgt);
            }
        }
Exemplo n.º 3
0
        private Task <IRealmService> LocateRealm(string realm)
        {
            IRealmService service = new FakeRealmService(realm);

            return(Task.FromResult(service));
        }