File: webid_check.vsp

package info (click to toggle)
virtuoso-opensource 7.2.5.1%2Bdfsg1-0.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 285,240 kB
  • sloc: ansic: 641,220; sql: 490,413; xml: 269,570; java: 83,893; javascript: 79,900; cpp: 36,927; sh: 31,653; cs: 25,702; php: 12,690; yacc: 10,227; lex: 7,601; makefile: 7,129; jsp: 4,523; awk: 1,697; perl: 1,013; ruby: 1,003; python: 326
file content (90 lines) | stat: -rw-r--r-- 2,421 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?vsp
  declare info, res, cb, mod, exp, webid, ret_url any;
  cb := {?'callback'};
  if (not length (cb))
    {
      goto html;
    }
  if (strchr (cb, '?') is null)
    cb := cb || '?';
  else
    cb := cb || '&';
  mod := exp := '';
  if (not is_http_ctx ())
    res := 'noCert';
  else
    { 
      info := get_certificate_info (9);
      if (info is null)
        res := 'noCert';
      else if (FOAF_SSL_AUTH_GEN (null, 1, 0))
        {
          webid := FOAF_SSL_WEBID_GET ();
	  res := 'success'; 
        }
      else
	res := 'noVerified';
      if (info is not null)
        { 
      	  mod := info[1];
          exp := bin2hex (info[2]);
	}
    }
   if (res = 'success')
     {
       ret_url := sprintf ('%swebid=%U', cb, webid);
     }
   else
     {
       ret_url := sprintf ('%serror=%U', cb, res);
     }
   ret_url := ret_url || sprintf ('&ts=%U', date_iso8601 (now ()));  
   ret_url := ret_url || sprintf ('&signature=%U', sha1_digest (ret_url));  
   http_status_set (302);
   http_header (sprintf ('Location: %s\r\n', ret_url));
   return;
html:
?>
<html>
  <head>
   <title>WebId Identity Provider</title>
   <style type="text/css">
      #qrcode {
        float: right;
        clear: right;
        margin-right: 20px;
      }
    </style>      
  </head>
  <body>
    <h1>WebId Identity Provider</h1>
    <?vsp declare qrimg, ua any;
     ua := http_request_header (lines, 'User-Agent');
     qrimg := ODS.ODS_API.qrcode (sprintf ('http://%{WSHost}s%s', http_path ()));
     if (qrimg is not null and strcasestr (ua, 'Mobile') is null) {
    ?>
    <div id="qrcode"><img alt="QRcode image" src="data:image/jpg;base64,<?V qrimg ?>"/></div>
    <?vsp
      } ?>
    <div>
      This will send a redirection to the URL you have specified in the input, including a signed assertion by this service about your WebID.
    </div>
    <div>
    <form method="get">
    Requesting service endpoint: <input type="text" value="" size="120" name="callback" /> <input type="submit" name="Log in" value="go"/>
    </form>
    </div>
    <div>
	The return values are:
	<ul>
	  <li>webid: the webid have been verified</li>
	  <li>error: error code if verification fails </li>
	  <li>ts: timestamp in ISO 8601 format</li>
	  <li>signature: SHA1 digest over returning URL</li>
	</ul>
    </div>
    <div>
      <a href="http://ods.openlinksw.com/wiki/ODS/ODSWebIDIdpProxy">Help</a>
    </div>
  </body>
</html>