9 use URI::Encode qw(uri_encode);
14 my $ref = decode_json($json);
15 return decode_base64($ref->{'gssweb'}{'token'});
20 my ($target_server, $itoken) = @_;
25 $status = GSSAPI::Name->import( $target,
27 GSSAPI::OID::gss_nt_hostbased_service) or last;
28 our $ctx = GSSAPI::Context->new() unless $ctx;
30 $status = GSSAPI::OID->from_str($mech, '{ 1.3.6.1.5.5.15.1.1.17 }') or last;
31 my $iflags = GSSAPI::GSS_C_MUTUAL_FLAG | GSSAPI::GSS_C_SEQUENCE_FLAG | GSSAPI::GSS_C_REPLAY_FLAG;
32 my $bindings = GSS_C_NO_CHANNEL_BINDINGS;
33 my $creds = GSS_C_NO_CREDENTIAL;
36 $status = $ctx->init($creds,$target,
37 $mech,$iflags,$itime,$bindings,$itoken,
38 undef, $otoken,undef,undef);
41 return undef unless $otoken;
42 print "Pre-encoding token: $otoken\n";
43 my $encoded_token = encode_base64($otoken);
44 chomp($encoded_token);
45 my $out = "token=" . uri_encode($encoded_token, {encode_reserved => 1}) ."&nonce=42";
50 my ($url, $gssname) = @ARGV;
51 my $www = WWW::Mechanize->new('autocheck' => 0);
53 my $response_token = undef;
56 $www->post($url, 'Content' => token_body($gssname, $response_token));
57 my $status = $www->status();
60 print "authenticated: response is ".$www->content()."\n";
61 if (token_body($gssname, parse_token($www->content()))) {
62 print "Expecting gss success but did not get it!\n";
64 } elsif ($status == 401) {
66 $response_token = parse_token($www->content());
68 print "Unexpected response status: $status\n";
69 print $www->content();