Exemple #1
0
        public static bool Authenticate(string serviceName, string user, string password)
        {
            //Initialize
            PamStatus           lastReturnedValue   = PamStatus.PAM_SUCCESS;
            IntPtr              pamHandle           = IntPtr.Zero;
            PamConv             conversation        = new PamConv();
            ConversationHandler conversationHandler = new ConversationHandler(password);

            conversation.ConversationCallback = conversationHandler.HandlePamConversation;

            try {
                //Start
                lastReturnedValue = Pam.pam_start(serviceName, user, conversation, ref pamHandle);
                if (lastReturnedValue != PamStatus.PAM_SUCCESS)
                {
                    return(false);
                }
                //Authenticate - Verifies username and password
                lastReturnedValue = Pam.pam_authenticate(pamHandle, AuthenticateFlags);
                if (lastReturnedValue != PamStatus.PAM_SUCCESS)
                {
                    return(false);
                }
                //Account Management - Checks that account is valid, checks account expiration, access restrictions.
                lastReturnedValue = Pam.pam_acct_mgmt(pamHandle, AccountManagementFlags);
                if (lastReturnedValue != PamStatus.PAM_SUCCESS)
                {
                    return(false);
                }
            } finally {
                lastReturnedValue = Pam.pam_end(pamHandle, lastReturnedValue);
            }

            return(true);
        }
Exemple #2
0
 ///<summary>
 /// Ensures that the account is in good standing - not locked out expired, etc.
 /// http://linux.die.net/man/3/pam_acct_mgmt
 ///</summary>
 public PamStatus AccountManagement(int flags)
 {
     lock (this.PamCallLock) {
         EnsureSessionAlive();
         this.lastReturnedValue = Pam.pam_acct_mgmt(this.pamHandle, flags);
         return(this.lastReturnedValue);
     }
 }
Exemple #3
0
 ///<summary>
 /// Authenticates the user against PAM. Only ensures that the username and password are correct. Call AccountManagement to check that the account is in good standing.
 /// http://linux.die.net/man/3/pam_authenticate
 ///</summary>
 public PamStatus Authenticate(int flags)
 {
     lock (this.PamCallLock) {
         EnsureSessionAlive();
         this.lastReturnedValue = Pam.pam_authenticate(this.pamHandle, flags);
         return(this.lastReturnedValue);
     }
 }
Exemple #4
0
 public void ReadCorrectData() => File.OpenRead(FileName).Using(stream =>
 {
     var TestPam = Pam.Read(stream);
     Assert.Equal(0x4D4150, (int)TestPam.header.MagicCode);
     Assert.Equal("OpenKHAnim", TestPam.animList[0].AnimEntry.AnimationName);
     Assert.Equal(1.818989362888275E-14, TestPam.animList[0].BoneChannels[1].TranslationX.Header.MaxValue);
     Assert.Equal(-0.027958117425441742, TestPam.animList[0].BoneChannels[2].TranslationX.Header.MaxValue);
     Assert.Equal(0.17539772391319275, TestPam.animList[0].BoneChannels[52].RotationZ.Header.MaxValue);
 });
Exemple #5
0
        ///<summary>
        /// Initializes the session. Must be called first.
        /// http://linux.die.net/man/3/pam_start
        ///</summary>
        public PamStatus Start()
        {
            PamConv conversation = new PamConv();

            conversation.ConversationCallback = HandlePamConversation;
            conversation.AppData = appData;
            lock (this.PamCallLock) {
                if (this.pamHandle != IntPtr.Zero)
                {
                    throw new InvalidOperationException("Start may not be called multiple times for the same PamSession!");
                }
                this.lastReturnedValue = Pam.pam_start(this.serviceName, user, conversation, ref pamHandle);
                return(this.lastReturnedValue);
            }
        }
Exemple #6
0
 ///<summary>
 /// Releases the PAM handle held as part of this session.
 /// http://linux.die.net/man/3/pam_end
 ///</summary>
 public PamStatus End()
 {
     lock (this.PamCallLock) {
         if (this.pamHandle == IntPtr.Zero)
         {
             return(PamStatus.PAM_SUCCESS);
         }
         if (this.endCalled)
         {
             return(this.lastReturnedValue);
         }
         this.lastReturnedValue = Pam.pam_end(this.pamHandle, this.lastReturnedValue);
         this.endCalled         = true;
         return(this.lastReturnedValue);
     }
 }
Exemple #7
0
        private static List <Assimp.Animation> PAMtoFBXAnim(Pmo pmo, Pam pam)
        {
            List <Assimp.Animation> animationList = new List <Assimp.Animation>();

            for (int i = 0; i < pam.header.AnimationCount; i++)
            {
                Assimp.Animation anim = new Assimp.Animation();
                anim.Name            = pam.animList[i].AnimEntry.AnimationName;
                anim.DurationInTicks = pam.animList[i].AnimHeader.FrameCount;
                anim.TicksPerSecond  = pam.animList[i].AnimHeader.Framerate;

                //anim.MeshAnimationChannels[0].MeshKeys.Add(new MeshKey(anim.DurationInTicks / 2, new Vector3D(0, 0, 100)));

                for (int b = 0; b < pam.animList[i].AnimHeader.BoneCount; b++)
                {
                    Pam.BoneChannel chann = pam.animList[i].BoneChannels[b];

                    anim.NodeAnimationChannels.Add(new NodeAnimationChannel());
                    anim.NodeAnimationChannels[b].NodeName = pmo.boneList[b].JointName;
                    ChannelData dat = GetChannelKeyframes(chann, anim.DurationInTicks);

                    //AddTranslationAtKeyframe(anim.NodeAnimationChannels[b].PositionKeys, 0, new Vector3D(), anim.TicksPerSecond);
                    // Position

                    /*if(dat.transData != null)
                     * {
                     *  foreach (ChannelTranslationData trans in dat.transData)
                     *  {
                     *      AddTranslationAtKeyframe(anim.NodeAnimationChannels[b].PositionKeys, trans.keyframeID, trans.Translation, anim.TicksPerSecond);
                     *  }
                     * }*/

                    /*if (dat.rotData != null)
                     * {
                     *  // Rotation
                     *  foreach (ChannelRotationData trans in dat.rotData)
                     *  {
                     *      AddRotationAtKeyframe(anim.NodeAnimationChannels[b].RotationKeys, trans.keyframeID, trans.Rotation, anim.TicksPerSecond);
                     *  }
                     * }*/
                }

                animationList.Add(anim);
            }

            return(animationList);
        }
Exemple #8
0
        private static void Convert(string PMO_Path, string PAM_Path)
        {
            Stream pmoStream = File.OpenRead(PMO_Path);
            Stream pamStream = File.OpenRead(PAM_Path);
            Pmo    pmo       = Pmo.Read(pmoStream);
            Pam    pam       = Pam.Read(pamStream);

            Assimp.Scene            nScene   = GetPMOScene(pmo);
            List <Assimp.Animation> FBXAnims = PAMtoFBXAnim(pmo, pam);

            nScene.Animations.AddRange(FBXAnims);

            pmoStream.Close();
            pamStream.Close();

            using var ctx = new AssimpContext();
            ctx.ExportFile(nScene, "Test.fbx", "fbx");
        }