p4ruby 2021.1.2156749-x64-mingw32 → 2021.1.2196401-x64-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/ext/P4/clientuserruby.cpp +195 -97
- data/ext/P4/clientuserruby.h +23 -42
- data/ext/P4/extconf.rb +4 -10
- data/ext/P4/p4.cpp +16 -0
- data/ext/P4/p4clientapi.cpp +11 -0
- data/ext/P4/p4clientapi.h +2 -0
- data/lib/2.6/P4.so +0 -0
- data/lib/2.7/P4.so +0 -0
- data/lib/3.0/P4.so +0 -0
- data/lib/P4/version.rb +1 -1
- data/lib/P4.rb +16 -0
- data/lib/P4.so +0 -0
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9b132efb11c78aa6705ac1346a7b4c59ab7cccf6dcba3178f0f9fc6a03fe8a3e
         | 
| 4 | 
            +
              data.tar.gz: 04c3421aa6c9bd9479572dda3bb87d71d979d0781cb424db565533d082b4101d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3a360cbc22044ccd0bc117847a033b1390933d7f2476ca1a7d47f78a21c48e4722db0bf1c9bd28a7956f56584455d01f697a3d72855f57a85e02045dcb6e9e0e
         | 
| 7 | 
            +
              data.tar.gz: 66a5854245e1ab4168c0831294c4c771ae140675779cc3c297c82381e6212cc073adb912f91dbd0b98860c2c7c61e2a2bd38cec029948edc105218c87c6cf7c9
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,4 +1,17 @@ | |
| 1 1 | 
             
            [](mailto:support@perforce.com)
         | 
| 2 2 |  | 
| 3 | 
            -
            #  | 
| 3 | 
            +
            # P4Ruby
         | 
| 4 4 | 
             
            P4Ruby is a wrapper for the P4 C++ API in Ruby.
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            P4Ruby is a Ruby module that provides an object-oriented API to Helix Core server. Using P4Ruby is faster than using the command-line interface in scripts, because multiple command can be executed on a single connection, and because it returns Helix server responses as Ruby hashes and arrays.
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            ## Requirements
         | 
| 9 | 
            +
            For P4Ruby requirements see "Compatibility Statements" in [RELNOTES](https://github.com/perforce/p4ruby/blob/master/RELNOTES.txt#L99)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            ## Documentation
         | 
| 12 | 
            +
            Official documentation is located on the [Perforce website](https://www.perforce.com/manuals/p4ruby/Content/P4Ruby/Home-p4ruby.html)
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            ## Support
         | 
| 15 | 
            +
            P4Ruby is officially supported by Perforce.
         | 
| 16 | 
            +
            Pull requests will be managed by Perforce's engineering teams. We will do our best to acknowledge these in a timely manner based on available capacity.  
         | 
| 17 | 
            +
            Issues will not be managed on GitHub. All issues should be recorded via [Perforce's standard support process](https://www.perforce.com/support/request-support).
         | 
    
        data/ext/P4/clientuserruby.cpp
    CHANGED
    
    | @@ -66,6 +66,19 @@ static const int CANCEL = 2; | |
| 66 66 | 
             
             * server, and converts the data to Ruby form for returning to the caller.
         | 
| 67 67 | 
             
             ******************************************************************************/
         | 
| 68 68 |  | 
| 69 | 
            +
            class SSOShim : public ClientSSO {
         | 
| 70 | 
            +
            public:
         | 
| 71 | 
            +
            	SSOShim(ClientUserRuby *ui) : ui(ui) {}
         | 
| 72 | 
            +
            	virtual ClientSSOStatus	Authorize( StrDict &vars,
         | 
| 73 | 
            +
            				           int maxLength,
         | 
| 74 | 
            +
            				           StrBuf &result )
         | 
| 75 | 
            +
            	{
         | 
| 76 | 
            +
            		return ui->Authorize(vars, maxLength, result);
         | 
| 77 | 
            +
            	}
         | 
| 78 | 
            +
            private:
         | 
| 79 | 
            +
            	ClientUserRuby *ui;
         | 
| 80 | 
            +
            } ;
         | 
| 81 | 
            +
             | 
| 69 82 | 
             
            ClientUserRuby::ClientUserRuby(SpecMgr *s) {
         | 
| 70 83 | 
             
            	specMgr = s;
         | 
| 71 84 | 
             
            	debug = 0;
         | 
| @@ -78,15 +91,22 @@ ClientUserRuby::ClientUserRuby(SpecMgr *s) { | |
| 78 91 | 
             
            	rubyExcept = 0;
         | 
| 79 92 | 
             
            	alive = 1;
         | 
| 80 93 | 
             
            	track = false;
         | 
| 81 | 
            -
             | 
| 94 | 
            +
                	SetSSOHandler( new SSOShim( this ) );
         | 
| 95 | 
            +
             | 
| 96 | 
            +
            	ssoEnabled = 0;
         | 
| 97 | 
            +
            	ssoResultSet = 0;
         | 
| 98 | 
            +
            	ssoResult = Qnil;
         | 
| 99 | 
            +
            	ssoHandler = Qnil;
         | 
| 82 100 |  | 
| 83 101 | 
             
            	ID idP4 = rb_intern("P4");
         | 
| 84 102 | 
             
            	ID idP4OH = rb_intern("OutputHandler");
         | 
| 85 103 | 
             
            	ID idP4Progress = rb_intern("Progress");
         | 
| 104 | 
            +
            	ID idP4SSO = rb_intern("SSOHandler");
         | 
| 86 105 |  | 
| 87 106 | 
             
            	VALUE cP4 = rb_const_get_at(rb_cObject, idP4);
         | 
| 88 107 | 
             
            	cOutputHandler = rb_const_get_at(cP4, idP4OH);
         | 
| 89 108 | 
             
            	cProgress = rb_const_get_at(cP4, idP4Progress );
         | 
| 109 | 
            +
            	cSSOHandler = rb_const_get_at(cP4, idP4SSO);
         | 
| 90 110 | 
             
            }
         | 
| 91 111 |  | 
| 92 112 | 
             
            void ClientUserRuby::Reset() {
         | 
| @@ -721,47 +741,130 @@ void ClientUserRuby::GCMark() { | |
| 721 741 | 
             
            	if (mergeResult != Qnil) rb_gc_mark( mergeResult);
         | 
| 722 742 | 
             
            	if (handler != Qnil) rb_gc_mark( handler);
         | 
| 723 743 | 
             
            	if (progress != Qnil) rb_gc_mark( progress );
         | 
| 724 | 
            -
            	rb_gc_mark(  | 
| 744 | 
            +
            	if (ssoResult != Qnil) rb_gc_mark( ssoResult );
         | 
| 745 | 
            +
            	if (ssoHandler != Qnil) rb_gc_mark( ssoHandler );
         | 
| 746 | 
            +
            	rb_gc_mark( cOutputHandler );
         | 
| 725 747 | 
             
            	rb_gc_mark( cProgress );
         | 
| 748 | 
            +
            	rb_gc_mark( cSSOHandler );
         | 
| 726 749 |  | 
| 727 750 | 
             
            	results.GCMark();
         | 
| 728 | 
            -
            	ssoHandler->GCMark();
         | 
| 729 751 | 
             
            }
         | 
| 730 752 |  | 
| 731 | 
            -
            //
         | 
| 732 | 
            -
            // SSO handler
         | 
| 733 | 
            -
            //
         | 
| 734 753 |  | 
| 735 | 
            -
             | 
| 736 | 
            -
             | 
| 737 | 
            -
             | 
| 738 | 
            -
             | 
| 739 | 
            -
             | 
| 740 | 
            -
             | 
| 754 | 
            +
            /*
         | 
| 755 | 
            +
             * Set the Handler object. Double-check that it is either nil or
         | 
| 756 | 
            +
             * an instance of OutputHandler to avoid future problems
         | 
| 757 | 
            +
             */
         | 
| 758 | 
            +
             | 
| 759 | 
            +
            VALUE
         | 
| 760 | 
            +
            ClientUserRuby::SetRubySSOHandler(VALUE h) {
         | 
| 761 | 
            +
            	if (P4RDB_CALLS) fprintf(stderr, "[P4] SetSSOHandler()\n");
         | 
| 762 | 
            +
             | 
| 763 | 
            +
            	if (Qnil != h && Qfalse == rb_obj_is_kind_of(h, cSSOHandler)) {
         | 
| 764 | 
            +
            		rb_raise(eP4, "Handler needs to be an instance of P4::SSOHandler");
         | 
| 765 | 
            +
            		return Qfalse;
         | 
| 766 | 
            +
            	}
         | 
| 767 | 
            +
             | 
| 768 | 
            +
            	ssoHandler = h;
         | 
| 769 | 
            +
            	alive = 1; // ensure that we don't drop out after the next call
         | 
| 770 | 
            +
             | 
| 771 | 
            +
            	return Qtrue;
         | 
| 772 | 
            +
            }
         | 
| 773 | 
            +
             | 
| 774 | 
            +
             | 
| 775 | 
            +
            // returns true if output should be reported
         | 
| 776 | 
            +
            // false if the output is handled and should be ignored
         | 
| 777 | 
            +
            static VALUE CallMethodSSO(VALUE data) {
         | 
| 778 | 
            +
            	VALUE *args = reinterpret_cast<VALUE *>(data);
         | 
| 779 | 
            +
            	return rb_funcall(args[0], (ID) rb_intern("authorize"), 2, args[1], args[2]);
         | 
| 741 780 | 
             
            }
         | 
| 742 781 |  | 
| 743 782 | 
             
            ClientSSOStatus
         | 
| 744 | 
            -
             | 
| 783 | 
            +
            ClientUserRuby::CallSSOMethod(VALUE vars, int maxLength, StrBuf &result) {
         | 
| 784 | 
            +
            	ClientSSOStatus answer = CSS_SKIP;
         | 
| 785 | 
            +
            	int excepted = 0;
         | 
| 786 | 
            +
            	result.Clear();
         | 
| 787 | 
            +
             | 
| 788 | 
            +
            	if (P4RDB_COMMANDS) fprintf(stderr, "[P4] CallSSOMethod\n");
         | 
| 789 | 
            +
             | 
| 790 | 
            +
            	// some wild hacks to satisfy the rb_protect method
         | 
| 791 | 
            +
             | 
| 792 | 
            +
            	VALUE args[3] = { ssoHandler, vars, INT2NUM( maxLength ) };
         | 
| 793 | 
            +
             | 
| 794 | 
            +
            	VALUE res = rb_protect(CallMethodSSO, (VALUE) args, &excepted);
         | 
| 795 | 
            +
             | 
| 796 | 
            +
            	if (excepted) { // exception thrown
         | 
| 797 | 
            +
            		alive = 0;
         | 
| 798 | 
            +
            		rb_jump_tag(excepted);
         | 
| 799 | 
            +
            	} else if( FIXNUM_P( res ) ) {
         | 
| 800 | 
            +
            		int a = NUM2INT(res);
         | 
| 801 | 
            +
            		if (P4RDB_COMMANDS)
         | 
| 802 | 
            +
            			fprintf(stderr, "[P4] CallSSOMethod returned %d\n", a);
         | 
| 803 | 
            +
             | 
| 804 | 
            +
            		if( a < CSS_PASS || a > CSS_SKIP )
         | 
| 805 | 
            +
            			rb_raise(eP4, "P4::SSOHandler::authorize returned out of range response");
         | 
| 806 | 
            +
            		answer = (ClientSSOStatus) a;
         | 
| 807 | 
            +
            	} else if( Qtrue == rb_obj_is_kind_of(res, rb_cArray) ) {
         | 
| 808 | 
            +
            		VALUE resval1 = rb_ary_shift(res);
         | 
| 809 | 
            +
            		Check_Type( resval1, T_FIXNUM );
         | 
| 810 | 
            +
            		int a = NUM2INT(resval1);
         | 
| 811 | 
            +
            		if( a < CSS_PASS || a > CSS_SKIP )
         | 
| 812 | 
            +
            			rb_raise(eP4, "P4::SSOHandler::authorize returned out of range response");
         | 
| 813 | 
            +
            		answer = (ClientSSOStatus) a;
         | 
| 814 | 
            +
             | 
| 815 | 
            +
            		VALUE resval2 = rb_ary_shift(res);
         | 
| 816 | 
            +
            		if( resval2 != Qnil )
         | 
| 817 | 
            +
            		{
         | 
| 818 | 
            +
            			Check_Type( resval2, T_STRING );
         | 
| 819 | 
            +
            			result.Set(StringValuePtr(resval2));
         | 
| 820 | 
            +
            			if (P4RDB_COMMANDS)
         | 
| 821 | 
            +
            				fprintf(stderr, "[P4] CallSSOMethod returned %d, %s\n", a, result.Text());
         | 
| 822 | 
            +
            		}
         | 
| 823 | 
            +
             | 
| 824 | 
            +
            	} else {
         | 
| 825 | 
            +
            		Check_Type( res, T_STRING );
         | 
| 826 | 
            +
            		answer = CSS_PASS;
         | 
| 827 | 
            +
             | 
| 828 | 
            +
            		result.Set(StringValuePtr(res));
         | 
| 829 | 
            +
            		if (P4RDB_COMMANDS)
         | 
| 830 | 
            +
            			fprintf(stderr, "[P4] CallSSOMethod returned %s\n", result.Text());
         | 
| 831 | 
            +
             | 
| 832 | 
            +
            	}
         | 
| 833 | 
            +
             | 
| 834 | 
            +
            	return answer;
         | 
| 835 | 
            +
            }
         | 
| 836 | 
            +
             | 
| 837 | 
            +
            ClientSSOStatus
         | 
| 838 | 
            +
            ClientUserRuby::Authorize( StrDict &vars, int maxLength, StrBuf &strbuf )
         | 
| 745 839 | 
             
            {
         | 
| 746 | 
            -
             | 
| 840 | 
            +
            	ssoVars.Clear();
         | 
| 841 | 
            +
             | 
| 842 | 
            +
            	if( ssoHandler != Qnil )
         | 
| 843 | 
            +
            	{
         | 
| 844 | 
            +
            		ClientSSOStatus res = CallSSOMethod( specMgr->StrDictToHash(&vars), maxLength, strbuf );
         | 
| 845 | 
            +
            		if( res != CSS_SKIP )
         | 
| 846 | 
            +
            			return res;
         | 
| 847 | 
            +
            		if (P4RDB_COMMANDS)
         | 
| 848 | 
            +
            			fprintf(stderr, "[P4] Authorize skipped result from SSO Handler\n" );
         | 
| 849 | 
            +
            	}
         | 
| 747 850 |  | 
| 748 | 
            -
             | 
| 749 | 
            -
             | 
| 851 | 
            +
            	if( !ssoEnabled )
         | 
| 852 | 
            +
            		return CSS_SKIP;
         | 
| 750 853 |  | 
| 751 | 
            -
             | 
| 752 | 
            -
             | 
| 854 | 
            +
            	if( ssoEnabled < 0 )
         | 
| 855 | 
            +
            		return CSS_UNSET;
         | 
| 753 856 |  | 
| 754 | 
            -
             | 
| 755 | 
            -
             | 
| 756 | 
            -
             | 
| 757 | 
            -
             | 
| 857 | 
            +
            	if( ssoResultSet )
         | 
| 858 | 
            +
            	{
         | 
| 859 | 
            +
            		strbuf.Clear();
         | 
| 860 | 
            +
            			VALUE resval = ssoResult;
         | 
| 758 861 |  | 
| 759 | 
            -
             | 
| 760 | 
            -
             | 
| 761 | 
            -
             | 
| 862 | 
            +
            		//if( P4RDB_CALLS )
         | 
| 863 | 
            +
            		//    std::cerr << "[P4] ClientSSO::Authorize(). Using supplied input"
         | 
| 864 | 
            +
            		//              << std::endl;
         | 
| 762 865 |  | 
| 763 | 
            -
            		if (Qtrue == rb_obj_is_kind_of( | 
| 764 | 
            -
            			resval = rb_ary_shift( | 
| 866 | 
            +
            		if (Qtrue == rb_obj_is_kind_of(ssoResult, rb_cArray)) {
         | 
| 867 | 
            +
            			resval = rb_ary_shift(ssoResult);
         | 
| 765 868 | 
             
            		}
         | 
| 766 869 |  | 
| 767 870 | 
             
            		if( resval != Qnil ) {
         | 
| @@ -771,111 +874,106 @@ P4ClientSSO::Authorize( StrDict &vars, int maxLength, StrBuf &strbuf ) | |
| 771 874 | 
             
            			strbuf.Set(StringValuePtr(str));
         | 
| 772 875 | 
             
            		}
         | 
| 773 876 |  | 
| 774 | 
            -
             | 
| 775 | 
            -
             | 
| 776 | 
            -
             | 
| 877 | 
            +
            		return ssoResultSet == 2 ? CSS_FAIL
         | 
| 878 | 
            +
            				: CSS_PASS;
         | 
| 879 | 
            +
            	}
         | 
| 777 880 |  | 
| 778 | 
            -
             | 
| 779 | 
            -
             | 
| 881 | 
            +
            	ssoVars.CopyVars( vars );
         | 
| 882 | 
            +
            	return CSS_EXIT;
         | 
| 780 883 | 
             
            }
         | 
| 781 884 |  | 
| 782 885 | 
             
            VALUE
         | 
| 783 | 
            -
             | 
| 886 | 
            +
            ClientUserRuby::EnableSSO( VALUE e )
         | 
| 784 887 | 
             
            {
         | 
| 785 | 
            -
             | 
| 786 | 
            -
             | 
| 787 | 
            -
             | 
| 788 | 
            -
             | 
| 789 | 
            -
             | 
| 790 | 
            -
             | 
| 791 | 
            -
             | 
| 792 | 
            -
             | 
| 793 | 
            -
             | 
| 794 | 
            -
             | 
| 795 | 
            -
             | 
| 796 | 
            -
             | 
| 797 | 
            -
             | 
| 798 | 
            -
             | 
| 799 | 
            -
             | 
| 800 | 
            -
             | 
| 801 | 
            -
             | 
| 888 | 
            +
            	if( e == Qnil )
         | 
| 889 | 
            +
            	{
         | 
| 890 | 
            +
            		ssoEnabled = 0;
         | 
| 891 | 
            +
            		return Qtrue;
         | 
| 892 | 
            +
            	}
         | 
| 893 | 
            +
             | 
| 894 | 
            +
            	if( e == Qtrue )
         | 
| 895 | 
            +
            	{
         | 
| 896 | 
            +
            		ssoEnabled = 1;
         | 
| 897 | 
            +
            		return Qtrue;
         | 
| 898 | 
            +
            	}
         | 
| 899 | 
            +
             | 
| 900 | 
            +
            	if( e == Qfalse )
         | 
| 901 | 
            +
            	{
         | 
| 902 | 
            +
            		ssoEnabled = -1;
         | 
| 903 | 
            +
            		return Qtrue;
         | 
| 904 | 
            +
            	}
         | 
| 802 905 |  | 
| 803 906 | 
             
            	return Qfalse;
         | 
| 804 907 | 
             
            }
         | 
| 805 908 |  | 
| 806 909 | 
             
            VALUE
         | 
| 807 | 
            -
             | 
| 910 | 
            +
            ClientUserRuby::SSOEnabled()
         | 
| 808 911 | 
             
            {
         | 
| 809 | 
            -
             | 
| 810 | 
            -
             | 
| 811 | 
            -
             | 
| 812 | 
            -
             | 
| 813 | 
            -
             | 
| 814 | 
            -
             | 
| 815 | 
            -
             | 
| 816 | 
            -
             | 
| 817 | 
            -
             | 
| 818 | 
            -
             | 
| 819 | 
            -
             | 
| 820 | 
            -
             | 
| 912 | 
            +
            	if( ssoEnabled == 1 )
         | 
| 913 | 
            +
            	{
         | 
| 914 | 
            +
            		return Qtrue;
         | 
| 915 | 
            +
            	}
         | 
| 916 | 
            +
            	else if( ssoEnabled == -1 )
         | 
| 917 | 
            +
            	{
         | 
| 918 | 
            +
            		return Qfalse;
         | 
| 919 | 
            +
            	}
         | 
| 920 | 
            +
            	else
         | 
| 921 | 
            +
            	{
         | 
| 922 | 
            +
            		return Qnil;
         | 
| 923 | 
            +
            	}
         | 
| 821 924 | 
             
            }
         | 
| 822 925 |  | 
| 823 926 | 
             
            VALUE
         | 
| 824 | 
            -
             | 
| 927 | 
            +
            ClientUserRuby::SetSSOPassResult( VALUE i )
         | 
| 825 928 | 
             
            {
         | 
| 826 | 
            -
             | 
| 827 | 
            -
             | 
| 929 | 
            +
            	ssoResultSet = 1;
         | 
| 930 | 
            +
            	return SetSSOResult( i );
         | 
| 828 931 | 
             
            }
         | 
| 829 932 |  | 
| 830 933 | 
             
            VALUE
         | 
| 831 | 
            -
             | 
| 934 | 
            +
            ClientUserRuby::GetSSOPassResult()
         | 
| 832 935 | 
             
            {
         | 
| 833 | 
            -
             | 
| 834 | 
            -
             | 
| 835 | 
            -
             | 
| 836 | 
            -
             | 
| 837 | 
            -
             | 
| 838 | 
            -
             | 
| 839 | 
            -
             | 
| 840 | 
            -
             | 
| 936 | 
            +
            	if( ssoResultSet == 1 )
         | 
| 937 | 
            +
            	{
         | 
| 938 | 
            +
            		return ssoResult;
         | 
| 939 | 
            +
            	}
         | 
| 940 | 
            +
            	else
         | 
| 941 | 
            +
            	{
         | 
| 942 | 
            +
            		return Qnil;
         | 
| 943 | 
            +
            	}
         | 
| 841 944 | 
             
            }
         | 
| 842 945 |  | 
| 843 946 | 
             
            VALUE
         | 
| 844 | 
            -
             | 
| 947 | 
            +
            ClientUserRuby::SetSSOFailResult( VALUE i )
         | 
| 845 948 | 
             
            {
         | 
| 846 | 
            -
             | 
| 847 | 
            -
             | 
| 949 | 
            +
            	ssoResultSet = 2;
         | 
| 950 | 
            +
            	return SetSSOResult( i );
         | 
| 848 951 | 
             
            }
         | 
| 849 952 |  | 
| 850 953 | 
             
            VALUE
         | 
| 851 | 
            -
             | 
| 954 | 
            +
            ClientUserRuby::GetSSOFailResult()
         | 
| 852 955 | 
             
            {
         | 
| 853 | 
            -
             | 
| 854 | 
            -
             | 
| 855 | 
            -
             | 
| 856 | 
            -
             | 
| 857 | 
            -
             | 
| 858 | 
            -
             | 
| 859 | 
            -
             | 
| 860 | 
            -
             | 
| 956 | 
            +
            	if( ssoResultSet == 2 )
         | 
| 957 | 
            +
            	{
         | 
| 958 | 
            +
            		return ssoResult;
         | 
| 959 | 
            +
            	}
         | 
| 960 | 
            +
            	else
         | 
| 961 | 
            +
            	{
         | 
| 962 | 
            +
            		return Qnil;
         | 
| 963 | 
            +
            	}
         | 
| 861 964 | 
             
            }
         | 
| 862 965 |  | 
| 863 966 | 
             
            VALUE
         | 
| 864 | 
            -
             | 
| 967 | 
            +
            ClientUserRuby::SetSSOResult( VALUE i )
         | 
| 865 968 | 
             
            {
         | 
| 866 | 
            -
            	 | 
| 969 | 
            +
            	if (P4RDB_CALLS) fprintf(stderr, "[P4] P4ClientSSO::SetResult()\n");
         | 
| 867 970 |  | 
| 868 | 
            -
            	 | 
| 971 | 
            +
            	ssoResult = i;
         | 
| 869 972 | 
             
            	return Qtrue;
         | 
| 870 973 | 
             
            }
         | 
| 871 974 |  | 
| 872 975 | 
             
            VALUE
         | 
| 873 | 
            -
             | 
| 976 | 
            +
            ClientUserRuby::GetSSOVars()
         | 
| 874 977 | 
             
            {
         | 
| 875 | 
            -
             | 
| 876 | 
            -
            }
         | 
| 877 | 
            -
             | 
| 878 | 
            -
            void
         | 
| 879 | 
            -
            P4ClientSSO::GCMark() {
         | 
| 880 | 
            -
            	if (result != Qnil) rb_gc_mark( result );
         | 
| 978 | 
            +
                	return specMgr->StrDictToHash( &ssoVars );
         | 
| 881 979 | 
             
            }
         | 
    
        data/ext/P4/clientuserruby.h
    CHANGED
    
    | @@ -42,40 +42,7 @@ | |
| 42 42 | 
             
            class SpecMgr;
         | 
| 43 43 | 
             
            class ClientProgress;
         | 
| 44 44 |  | 
| 45 | 
            -
            class  | 
| 46 | 
            -
            {
         | 
| 47 | 
            -
                public:
         | 
| 48 | 
            -
                    P4ClientSSO( SpecMgr *s );
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                // Client SSO methods overridden here
         | 
| 51 | 
            -
                virtual ClientSSOStatus Authorize( StrDict &vars, int maxLength,
         | 
| 52 | 
            -
                                                   StrBuf &result );
         | 
| 53 | 
            -
             | 
| 54 | 
            -
                // Local methods
         | 
| 55 | 
            -
                VALUE EnableSSO( VALUE e );
         | 
| 56 | 
            -
                VALUE SSOEnabled();
         | 
| 57 | 
            -
                VALUE SetPassResult( VALUE i );
         | 
| 58 | 
            -
                VALUE GetPassResult();
         | 
| 59 | 
            -
                VALUE SetFailResult( VALUE i );
         | 
| 60 | 
            -
                VALUE GetFailResult();
         | 
| 61 | 
            -
                VALUE GetSSOVars();
         | 
| 62 | 
            -
             | 
| 63 | 
            -
            	void GCMark();
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                private:
         | 
| 66 | 
            -
             | 
| 67 | 
            -
                VALUE SetResult( VALUE i );
         | 
| 68 | 
            -
             | 
| 69 | 
            -
                int         ssoEnabled;
         | 
| 70 | 
            -
                int         resultSet;
         | 
| 71 | 
            -
             | 
| 72 | 
            -
                StrBufDict  ssoVars;
         | 
| 73 | 
            -
                SpecMgr *   specMgr;
         | 
| 74 | 
            -
             | 
| 75 | 
            -
                VALUE       result;
         | 
| 76 | 
            -
            };
         | 
| 77 | 
            -
             | 
| 78 | 
            -
            class ClientUserRuby: public ClientUser, public KeepAlive {
         | 
| 45 | 
            +
            class ClientUserRuby: public ClientUser, public ClientSSO, public KeepAlive {
         | 
| 79 46 | 
             
            public:
         | 
| 80 47 | 
             
            	ClientUserRuby(SpecMgr *s);
         | 
| 81 48 |  | 
| @@ -136,13 +103,18 @@ public: | |
| 136 103 |  | 
| 137 104 | 
             
            	// SSO handler support
         | 
| 138 105 |  | 
| 139 | 
            -
             | 
| 140 | 
            -
             | 
| 141 | 
            -
             | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 106 | 
            +
            	virtual ClientSSOStatus Authorize( StrDict &vars, int maxLength, StrBuf &result );
         | 
| 107 | 
            +
            	VALUE EnableSSO( VALUE e );
         | 
| 108 | 
            +
            	VALUE SSOEnabled();
         | 
| 109 | 
            +
            	VALUE SetSSOPassResult( VALUE i );
         | 
| 110 | 
            +
            	VALUE GetSSOPassResult();
         | 
| 111 | 
            +
            	VALUE SetSSOFailResult( VALUE i );
         | 
| 112 | 
            +
            	VALUE GetSSOFailResult();
         | 
| 113 | 
            +
            	VALUE GetSSOVars();
         | 
| 114 | 
            +
            	VALUE SetRubySSOHandler( VALUE handler );
         | 
| 115 | 
            +
            	VALUE GetRubySSOHandler() {
         | 
| 116 | 
            +
            		return ssoHandler;
         | 
| 117 | 
            +
            	}
         | 
| 146 118 |  | 
| 147 119 | 
             
            	// override from KeepAlive
         | 
| 148 120 | 
             
            	virtual int IsAlive() {
         | 
| @@ -155,6 +127,8 @@ private: | |
| 155 127 | 
             
            	void ProcessOutput(const char * method, VALUE data);
         | 
| 156 128 | 
             
            	void ProcessMessage(Error * e);
         | 
| 157 129 | 
             
            	bool CallOutputMethod(const char * method, VALUE data);
         | 
| 130 | 
            +
            	VALUE SetSSOResult( VALUE i );
         | 
| 131 | 
            +
            	ClientSSOStatus CallSSOMethod(VALUE vars, int maxLength, StrBuf &result);
         | 
| 158 132 |  | 
| 159 133 | 
             
            private:
         | 
| 160 134 | 
             
            	StrBuf cmd;
         | 
| @@ -167,11 +141,18 @@ private: | |
| 167 141 | 
             
            	VALUE cOutputHandler;
         | 
| 168 142 | 
             
            	VALUE progress;
         | 
| 169 143 | 
             
            	VALUE cProgress;
         | 
| 144 | 
            +
            	VALUE cSSOHandler;
         | 
| 170 145 | 
             
            	int debug;
         | 
| 171 146 | 
             
            	int apiLevel;
         | 
| 172 147 | 
             
            	int alive;
         | 
| 173 148 | 
             
            	int rubyExcept;
         | 
| 174 149 | 
             
            	bool track;
         | 
| 175 | 
            -
             | 
| 150 | 
            +
            	
         | 
| 151 | 
            +
            	// SSO handler support
         | 
| 152 | 
            +
            	int         ssoEnabled;
         | 
| 153 | 
            +
            	int         ssoResultSet;
         | 
| 154 | 
            +
            	StrBufDict  ssoVars;
         | 
| 155 | 
            +
            	VALUE       ssoResult;
         | 
| 156 | 
            +
            	VALUE 	    ssoHandler;
         | 
| 176 157 | 
             
            };
         | 
| 177 158 |  | 
    
        data/ext/P4/extconf.rb
    CHANGED
    
    | @@ -444,15 +444,11 @@ end | |
| 444 444 | 
             
            # directory name where we can download files from.
         | 
| 445 445 | 
             
            def p4_platform_label
         | 
| 446 446 | 
             
              case RbConfig::CONFIG["target_os"].downcase
         | 
| 447 | 
            -
                when /nt|mswin|mingw/
         | 
| 447 | 
            +
                when /nt|mswin|mingw|cygwin|msys/
         | 
| 448 448 | 
             
                  # Ruby on windows is only MinGW via Rubyinstaller.org, though this may
         | 
| 449 449 | 
             
                  # not work on all rubies.
         | 
| 450 | 
            -
                   | 
| 451 | 
            -
             | 
| 452 | 
            -
                    'mingw64'
         | 
| 453 | 
            -
                  else
         | 
| 454 | 
            -
                    'mingwx86'
         | 
| 455 | 
            -
                  end
         | 
| 450 | 
            +
                  # There are too many permutations of Windows p4api, to automate.
         | 
| 451 | 
            +
                  raise 'Automatic fetching of p4api from perforce FTP is not supported on Windows'
         | 
| 456 452 | 
             
                when /darwin19|darwin[2-9][0-9]/
         | 
| 457 453 | 
             
                  "macosx1015#{p4_cpu(:darwin)}"
         | 
| 458 454 | 
             
                when /darwin/      
         | 
| @@ -460,9 +456,7 @@ def p4_platform_label | |
| 460 456 | 
             
                when /solaris/
         | 
| 461 457 | 
             
                  "solaris10#{p4_cpu(:solaris)}"
         | 
| 462 458 | 
             
                when /linux/
         | 
| 463 | 
            -
                  "linux26#{p4_cpu(:linux)}"
         | 
| 464 | 
            -
                when /cygwin/
         | 
| 465 | 
            -
                  raise 'cygwin is not supported for the --download-p4api option'
         | 
| 459 | 
            +
                  "linux26#{p4_cpu(:linux)}"    
         | 
| 466 460 | 
             
              end
         | 
| 467 461 | 
             
            end
         | 
| 468 462 |  | 
    
        data/ext/P4/p4.cpp
    CHANGED
    
    | @@ -878,6 +878,20 @@ static VALUE p4_set_sso_failresult( VALUE self, VALUE result ) | |
| 878 878 | 
             
                Data_Get_Struct( self, P4ClientApi, p4 );
         | 
| 879 879 | 
             
                return p4->SetSSOFailResult( result );
         | 
| 880 880 | 
             
            }
         | 
| 881 | 
            +
            static VALUE p4_get_ssohandler( VALUE self )
         | 
| 882 | 
            +
            {
         | 
| 883 | 
            +
                P4ClientApi	*p4;
         | 
| 884 | 
            +
                Data_Get_Struct( self, P4ClientApi, p4 );
         | 
| 885 | 
            +
                return p4->GetSSOHandler();
         | 
| 886 | 
            +
            }
         | 
| 887 | 
            +
             | 
| 888 | 
            +
            static VALUE p4_set_ssohandler( VALUE self, VALUE handler )
         | 
| 889 | 
            +
            {
         | 
| 890 | 
            +
                P4ClientApi	*p4;
         | 
| 891 | 
            +
                Data_Get_Struct( self, P4ClientApi, p4 );
         | 
| 892 | 
            +
                p4->SetSSOHandler( handler );
         | 
| 893 | 
            +
                return Qtrue;
         | 
| 894 | 
            +
            }
         | 
| 881 895 |  | 
| 882 896 | 
             
            /*******************************************************************************
         | 
| 883 897 | 
             
             * P4::MergeData methods. Construction/destruction defined elsewhere
         | 
| @@ -1416,6 +1430,8 @@ void	Init_P4() | |
| 1416 1430 | 
             
                rb_define_method( cP4, "ssopassresult=", RUBY_METHOD_FUNC(p4_set_sso_passresult), 1);
         | 
| 1417 1431 | 
             
                rb_define_method( cP4, "ssofailresult", RUBY_METHOD_FUNC(p4_get_sso_failresult), 0);
         | 
| 1418 1432 | 
             
                rb_define_method( cP4, "ssofailresult=", RUBY_METHOD_FUNC(p4_set_sso_failresult), 1);
         | 
| 1433 | 
            +
                rb_define_method( cP4, "ssohandler", RUBY_METHOD_FUNC(p4_get_ssohandler), 0);
         | 
| 1434 | 
            +
                rb_define_method( cP4, "ssohandler=", RUBY_METHOD_FUNC(p4_set_ssohandler), 1);
         | 
| 1419 1435 |  | 
| 1420 1436 |  | 
| 1421 1437 | 
             
                // P4::MergeData class
         | 
    
        data/ext/P4/p4clientapi.cpp
    CHANGED
    
    | @@ -715,6 +715,17 @@ P4ClientApi::SetProgress( VALUE progress ) { | |
| 715 715 | 
             
                return ui.SetProgress( progress );
         | 
| 716 716 | 
             
            }
         | 
| 717 717 |  | 
| 718 | 
            +
            VALUE
         | 
| 719 | 
            +
            P4ClientApi::SetSSOHandler( VALUE h )
         | 
| 720 | 
            +
            {
         | 
| 721 | 
            +
                if ( P4RDB_COMMANDS )
         | 
| 722 | 
            +
                    fprintf( stderr, "[P4] Received SSO handler object\n" );
         | 
| 723 | 
            +
             | 
| 724 | 
            +
                ui.SetRubySSOHandler( h );
         | 
| 725 | 
            +
             | 
| 726 | 
            +
                return Qtrue;
         | 
| 727 | 
            +
            }
         | 
| 728 | 
            +
             | 
| 718 729 |  | 
| 719 730 | 
             
            void
         | 
| 720 731 | 
             
            P4ClientApi::GCMark()
         | 
    
        data/ext/P4/p4clientapi.h
    CHANGED
    
    | @@ -179,6 +179,8 @@ public: | |
| 179 179 | 
             
                VALUE GetSSOPassResult();
         | 
| 180 180 | 
             
                VALUE SetSSOFailResult( VALUE r );
         | 
| 181 181 | 
             
                VALUE GetSSOFailResult();
         | 
| 182 | 
            +
                VALUE SetSSOHandler( VALUE handler );
         | 
| 183 | 
            +
                VALUE GetSSOHandler() { return ui.GetRubySSOHandler(); }
         | 
| 182 184 |  | 
| 183 185 | 
             
                // Ruby garbage collection
         | 
| 184 186 | 
             
                void  GCMark();
         | 
    
        data/lib/2.6/P4.so
    CHANGED
    
    | Binary file | 
    
        data/lib/2.7/P4.so
    CHANGED
    
    | Binary file | 
    
        data/lib/3.0/P4.so
    CHANGED
    
    | Binary file | 
    
        data/lib/P4/version.rb
    CHANGED
    
    
    
        data/lib/P4.rb
    CHANGED
    
    | @@ -118,6 +118,13 @@ class P4 | |
| 118 118 | 
             
              PROG_FAILDONE         = 2
         | 
| 119 119 | 
             
              PROG_FLUSH            = 3
         | 
| 120 120 |  | 
| 121 | 
            +
              # SSO Handler return values constants
         | 
| 122 | 
            +
              SSO_PASS	            = 0  # SSO succeeded (result is an authentication token)
         | 
| 123 | 
            +
            	SSO_FAIL	            = 1  # SSO failed (result will be logged as error message)
         | 
| 124 | 
            +
            	SSO_UNSET	            = 2  # Client has no SSO support
         | 
| 125 | 
            +
            	SSO_EXIT	            = 3  # Stop login process
         | 
| 126 | 
            +
            	SSO_SKIP	            = 4  # Fall back to default P4API behavior
         | 
| 127 | 
            +
             | 
| 121 128 | 
             
              # Mappings for P4#each_<spec>
         | 
| 122 129 | 
             
              # Hash of type vs. key
         | 
| 123 130 | 
             
              SpecTypes = {
         | 
| @@ -669,4 +676,13 @@ class P4 | |
| 669 676 | 
             
                  HANDLED
         | 
| 670 677 | 
             
                end
         | 
| 671 678 | 
             
              end
         | 
| 679 | 
            +
             | 
| 680 | 
            +
              #*****************************************************************************
         | 
| 681 | 
            +
              # P4::SSOHandler class.
         | 
| 682 | 
            +
              #*****************************************************************************
         | 
| 683 | 
            +
              class SSOHandler
         | 
| 684 | 
            +
                def authorize(vars, maxLength)
         | 
| 685 | 
            +
                  [ SSO_SKIP, "" ]
         | 
| 686 | 
            +
                end
         | 
| 687 | 
            +
              end
         | 
| 672 688 | 
             
            end # class P4
         | 
    
        data/lib/P4.so
    CHANGED
    
    | Binary file | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: p4ruby
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2021.1. | 
| 4 | 
            +
              version: 2021.1.2196401
         | 
| 5 5 | 
             
            platform: x64-mingw32
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Perforce Software, Inc.
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021- | 
| 11 | 
            +
            date: 2021-10-14 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies: []
         | 
| 13 13 | 
             
            description: Ruby extensions to the C++ Perforce API.
         | 
| 14 14 | 
             
            email: support@perforce.com
         |