예제 #1
0
        public static ContextualSecurityToken OTPGateChallengeResponse(WorkflowAuthenticationResponse gateResponse,
                                                                       ref AuthenticationRequiredException authNException,
                                                                       out WorkflowAuthenticationChallenge workflowAuthenticationChallenge)
        {
            AuthenticationChallengeResponseType[] authenticationChallengeResponses = null;


            if (gateResponse != null)
            {
                AuthenticationChallengeResponseType authenticationChallengeResponse = new AuthenticationChallengeResponseType();
                authenticationChallengeResponse.Response = new ClientSerializer(
                    typeof(WorkflowAuthenticationResponse)).WriteObjectToXmlElement(gateResponse);

                authenticationChallengeResponses = new AuthenticationChallengeResponseType[] { authenticationChallengeResponse };
            }

            ContextualSecurityToken authNSecurityToken = null;

            workflowAuthenticationChallenge = null;

            try
            {
                MessageBuffer messageBuffer;
                authNSecurityToken = authNException.Authenticate(authenticationChallengeResponses, out messageBuffer);
            }
            catch (AuthenticationRequiredException exception)
            {
                authNException = exception;
                workflowAuthenticationChallenge = (WorkflowAuthenticationChallenge) new Microsoft.ResourceManagement.Client.ClientSerializer(
                    typeof(WorkflowAuthenticationChallenge)).ReadObjectFromXmlNode(
                    authNException.AuthenticationChallenges[0].Challenge);
            }

            return(authNSecurityToken);
        }
예제 #2
0
        internal static void TestOTPBusiness()
        {
            AuthenticationRequiredException authnException = null;
            WorkflowAuthenticationChallenge workflowAuthenticationChallenge = null;

            //Initiate OTP Reset
            try
            {
                OTPReset("ilm-vm-serverad", "jdoe", null, null);
            }
            catch (AuthenticationRequiredException exception)
            {
                authnException = exception;
            }

            //Go to STS to get the challenge
            Utilities.OTPGateChallengeResponse(null /* we don't have anything to respond yet*/, ref authnException, out workflowAuthenticationChallenge);
            Console.WriteLine(UnicodeEncoding.Unicode.GetString(workflowAuthenticationChallenge.data));

            //Now send our challenge response aka the OTP Pin
            string otpTestPin = Console.ReadLine();
            var    workflowChallengeResponse = new WorkflowAuthenticationResponse();

            workflowChallengeResponse.data = UnicodeEncoding.Unicode.GetBytes(otpTestPin);

            var securityToken = Utilities.OTPGateChallengeResponse(workflowChallengeResponse, ref authnException, out workflowAuthenticationChallenge);

            //Now we have a security token.  Time to go back to the MT to resubmit our initial request
            Utilities.OTPReset("ilm-vm-serverad", "jdoe", securityToken, authnException.InitialContextMessageProperty);

            //Bi-winning
        }
예제 #3
0
        protected void validateOTPButton_Click(object sender, EventArgs e)
        {
            //Now send our challenge response aka the OTP Pin
            string[] userDetails = this.domainUserName.Text.Split('\\');
            WorkflowAuthenticationChallenge workflowAuthenticationChallenge = null;
            var workflowChallengeResponse = new WorkflowAuthenticationResponse();

            workflowChallengeResponse.data = UnicodeEncoding.Unicode.GetBytes(this.otpInput.Text);

            var authnException = HttpContext.Current.Cache.Get("authNExcep") as AuthenticationRequiredException;
            var securityToken  = Utilities.OTPGateChallengeResponse(workflowChallengeResponse, ref authnException, out workflowAuthenticationChallenge);

            //Now we have a security token.  Time to go back to the MT to resubmit our initial request
            try
            {
                Utilities.OTPReset(userDetails[0], userDetails[1], securityToken, authnException.InitialContextMessageProperty);

                //Bi-winning
                this.otpvalidationResults.Text = "You are winning so radically before our first cup of coffee. Your new password has been sent to your phone. I take it back, you are bi-winning.";
            }
            catch
            {
                this.otpvalidationResults.Text = "Stop trying to hack other people's accounts by guessing passwords; this is FIM not facebook. Or maybe you can't type your pin from your phone correctly.  That's prolly worse. Either way, you just won two side orders of FAIL.";
            }

            stage = 2;
            ScriptManager sm = ScriptManager.GetCurrent(Page);

            if (sm.IsInAsyncPostBack)
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "anotherKey", "available_indexes.push(" + stage + ");$('#accordion').accordion('activate', " + stage + ");", true);
            }
        }
예제 #4
0
        public static ContextualSecurityToken OTPGateChallengeResponse(WorkflowAuthenticationResponse gateResponse, 
                                                   ref AuthenticationRequiredException authNException, 
                                                   out WorkflowAuthenticationChallenge workflowAuthenticationChallenge)
        {
            AuthenticationChallengeResponseType[] authenticationChallengeResponses = null;

            if (gateResponse != null)
            {
                AuthenticationChallengeResponseType authenticationChallengeResponse = new AuthenticationChallengeResponseType();
                authenticationChallengeResponse.Response = new ClientSerializer(
                    typeof(WorkflowAuthenticationResponse)).WriteObjectToXmlElement(gateResponse);

                authenticationChallengeResponses = new AuthenticationChallengeResponseType[] { authenticationChallengeResponse };
            }

            ContextualSecurityToken authNSecurityToken = null;
            workflowAuthenticationChallenge = null;

            try
            {
                MessageBuffer messageBuffer;
                authNSecurityToken = authNException.Authenticate(authenticationChallengeResponses, out messageBuffer);
            }
            catch (AuthenticationRequiredException exception)
            {
                authNException = exception;
                workflowAuthenticationChallenge = (WorkflowAuthenticationChallenge)new Microsoft.ResourceManagement.Client.ClientSerializer(
                        typeof(WorkflowAuthenticationChallenge)).ReadObjectFromXmlNode(
                            authNException.AuthenticationChallenges[0].Challenge);
            }

            return authNSecurityToken;
        }
예제 #5
0
        protected void sendOTPButton_Click(object sender, EventArgs e)
        {
            AuthenticationRequiredException authnException = null;
            WorkflowAuthenticationChallenge workflowAuthenticationChallenge = null;

            string[] userDetails = this.domainUserName.Text.Split('\\');


            //Initiate OTP Reset
            try
            {
                Utilities.OTPReset(userDetails[0], userDetails[1], null, null);
            }
            catch (AuthenticationRequiredException exception)
            {
                authnException = exception;
            }

            //Go to STS to get the challenge
            Utilities.OTPGateChallengeResponse(null /* we don't have anything to respond yet*/, ref authnException, out workflowAuthenticationChallenge);
            this.otpGateInstructions.Text = UnicodeEncoding.Unicode.GetString(workflowAuthenticationChallenge.data);

            HttpContext.Current.Cache.Insert("authNExcep", authnException);

            stage = 1;
            ScriptManager sm = ScriptManager.GetCurrent(Page);

            if (sm.IsInAsyncPostBack)
            {
                ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "anotherKey", "available_indexes.push(" + stage + ");$('#accordion').accordion('activate', " + stage + ");", true);
            }
        }