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