12 my $ref = decode_json($json);
13 return $ref->{'gssweb'}{'token'};
18 my ($target_server, $itoken) = @_;
23 $status = GSSAPI::Name->import( $target,
25 GSSAPI::OID::gss_nt_hostbased_service) or last;
26 our $ctx = GSSAPI::Context->new() unless $ctx;
28 $status = GSSAPI::OID->from_str($mech, '{ 1.3.6.1.5.5.15.1.1.17 }') or last;
29 my $iflags = GSSAPI::GSS_C_MUTUAL_FLAG | GSSAPI::GSS_C_SEQUENCE_FLAG | GSSAPI::GSS_C_REPLAY_FLAG;
30 my $bindings = GSS_C_NO_CHANNEL_BINDINGS;
31 my $creds = GSS_C_NO_CREDENTIAL;
34 $status = $ctx->init($creds,$target,
35 $mech,$iflags,$itime,$bindings,$itoken,
36 undef, $otoken,undef,undef);
39 return undef unless $otoken;
41 my $out = "token:" . encode_base64($otoken) ."nonce: 42\n";
46 my ($url, $gssname) = @ARGV;
47 my $www = WWW::Mechanize->new('autocheck' => 0);
49 my $response_token = undef;
52 $www->post($url, 'Content' => token_body($gssname, $response_token));
53 my $status = $www->status();
56 print "authenticated: response is ".$www->content()."\n";
57 if (token_body($gssname, parse_token($www->content()))) {
58 print "Expecting gss success but did not get it!\n";
60 } elsif ($status == 401) {
62 $response_token = parse_token($www->content());
64 print "Unexpected response status: $status\n";
65 print $www->content();