10 use URI::Encode qw(uri_encode);
15 my $ref = decode_json($json);
16 return decode_base64($ref->{'gssweb'}{'token'}) or die "No token\n";
21 my ($target_server, $itoken) = @_;
26 $status = GSSAPI::Name->import( $target,
28 GSSAPI::OID::gss_nt_hostbased_service) or last;
29 our $ctx = GSSAPI::Context->new() unless $ctx;
31 $status = GSSAPI::OID->from_str($mech, '{ 1.3.6.1.5.5.15.1.1.17 }') or last;
32 my $iflags = GSSAPI::GSS_C_MUTUAL_FLAG | GSSAPI::GSS_C_SEQUENCE_FLAG | GSSAPI::GSS_C_REPLAY_FLAG;
33 my $bindings = GSS_C_NO_CHANNEL_BINDINGS;
34 my $creds = GSS_C_NO_CREDENTIAL;
37 $status = $ctx->init($creds,$target,
38 $mech,$iflags,$itime,$bindings,$itoken,
39 undef, $otoken,undef,undef);
42 return undef unless $otoken;
43 print "Pre-encoding token: $otoken\n";
44 my $encoded_token = encode_base64($otoken, '');
45 chomp($encoded_token);
46 my $out = "token=" . uri_encode($encoded_token, {encode_reserved => 1}) ."&nonce=42";
51 my ($url, $gssname) = @ARGV;
52 my $www = WWW::Mechanize->new('autocheck' => 0);
53 $www->conn_cache(LWP::ConnCache->new);
55 my $response_token = undef;
58 $www->post($url, 'Content' => token_body($gssname, $response_token));
59 my $status = $www->status();
62 print "authenticated: response is ".$www->content()."\n";
63 if (token_body($gssname, parse_token($www->content()))) {
64 print "Expecting gss success but did not get it!\n";
66 } elsif ($status == 401) {
68 $response_token = parse_token($www->content());
70 print "Unexpected response status: $status\n";
71 print $www->content();