index.html 22 KB
Newer Older
matthias.lang's avatar
matthias.lang committed
1
2
3
4
5
6
7
<!DOCTYPE html>
<html lang="en">
<head>

  <!-- Basic Page Needs
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <meta charset="utf-8">
8
  <title>KIT-CA Zertifikatsuche</title>
matthias.lang's avatar
matthias.lang committed
9
10
11
12
13
14
15
16
17
18
19
20
21
  <meta name="description" content="">
  <meta name="author" content="">

  <!-- Mobile Specific Metas
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <meta name="viewport" content="width=device-width, initial-scale=1">

  <!-- FONT
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">

  <!-- CSS
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
22
23
  <link rel="stylesheet" href="css/normalize.css">
  <link rel="stylesheet" href="css/skeleton.css">
matthias.lang's avatar
matthias.lang committed
24
  <link rel="stylesheet" href="css/font-awesome.min.css">
matthias.lang's avatar
matthias.lang committed
25
26

  <style>
matthias.lang's avatar
matthias.lang committed
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
    th.active .arrow {
        opacity: 1;
    }

    .arrow {
        display: inline-block;
        vertical-align: middle;
        width: 0;
        height: 0;
        margin-left: 5px;
        opacity: 0.66;
    }

    .arrow.asc {
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
        border-bottom: 4px solid;
    }

    .arrow.dsc {
        border-top: 4px solid;
        border-left: 4px solid transparent;
        border-right: 4px solid transparent;
    }

    .good { color: green; }
    .neutral { color: orange; }
    .bad { color: red; }
    .valid { color: black; }
    .invalid { color: grey; }

    .icon {
        line-height: 1em !important;
        height: 1em;
        width: 1em;
        text-align: center;
        vertical-align: middle;
        padding: 5px;
        border-radius: 4px;
        border: 1px solid #b3e0da;
        background-color: #b3e0da;
        color: #FFF;
    }

    .icon-active {
        background-color: #009682;
        border-color: #009682;
        color: #FFF;
    }

    .icon:hover {
        background-color: #bbb;
        border-color: #bbb;
    }

    /* TODO: asd*/
    .fa {
        font-size: 1.33333333em;
        line-height: 0.75em;
        vertical-align: -15%;
    }
matthias.lang's avatar
matthias.lang committed
88
89
90
91
92
93
  </style>

  <!-- Favicon
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
  <link rel="icon" type="image/png" href="images/favicon.png">

matthias.lang's avatar
matthias.lang committed
94
95

  <script src="https://unpkg.com/vue/dist/vue.js"></script>
96
  <script src="https://unpkg.com/vue-resource/dist/vue-resource.min.js"></script>
97
  <script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
98
99


matthias.lang's avatar
matthias.lang committed
100

matthias.lang's avatar
matthias.lang committed
101
102
103
</head>
<body>

matthias.lang's avatar
matthias.lang committed
104
105


matthias.lang's avatar
matthias.lang committed
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
    <div class="container">

        <div class="row" style="margin-bottom: 4em; margin-top: 5%"">
            <div class="one-half column">
                <h1>Zertifikatsuche</h1>
            </div>
            <div class="one-half column" style="text-align: right">
                <img src="images/KIT-CA-Logo.svg" height="60px" alt="KIT-CA Logo" />
            </div>
        </div>
        <div class="row">
            <div class="u-full-width">
                <p>Bitte geben Sie den Namen oder die exakte E-Mail-Adresse aus dem Zertifikat ein, das Sie suchen.</p>
            </div>
        </div>


        <div id="ca-search">
            <form v-on:submit.prevent="search()" style="margin-bottom: 0">
                <div class="row">
                    <div class="ten columns">
matthias.lang's avatar
matthias.lang committed
127
                        <input name="q" class="u-full-width" type="text" placeholder="Name oder E-Mail-Adresse" id="query" v-model="query" autofocus>
matthias.lang's avatar
matthias.lang committed
128
129
130
131
132
133
134
135
136
137
                    </div>
                    <div class="two columns">
                        <button class="button-primary" type="submit" @click="search()" v-if="!loading" required>Suchen</button>
                        <button class="button-primary" type="button" disabled="disabled" v-if="loading">Suche...</button>
                    </div>
                </div>
            </form>

            <div class="row">
                <div class="ten columns">
138
139
140
141
142
143
144
145
146
147
148
149
                    <span v-for="category in filterShow" class="one-third column" v-if="!category.hideInPublicSearch || visitorLoggedIn">
                        <strong>{{ category.name }}:</strong><br/>
                        <span v-for="filter in category.filters" v-if="!filter.hideInPublicSearch || visitorLoggedIn">
                            <span @click="filter.buttonState = !filter.buttonState"
                            class="icon fa"
                            :title="filter.displayName"
                            v-bind:class="[filter.displayIcon, { 'icon-active': filter.buttonState }]"
                            style="margin: 5px"
                            >
                                <!-- <small>{{ filter.resultCount}}</small> -->
                            </span>
                        </span>
matthias.lang's avatar
matthias.lang committed
150
                    </span>
151
152
153
154
155
156
157
158
159
                </div>
                <div class="two columns">
                    <div class="row">
                        <div class="twelve columns" style="text-align: right;">
                            <span class="button" type="submit" @click="getShibSessionData()" v-if="visitorLoggedIn" required>Hallo, {{ visitorGivenName }} {{ visitorSn }}</span>
                            <a :href="'/Shibboleth.sso/Login?target=/?q=' + query"><span class="button" v-if="!visitorLoggedIn" required>Nicht eingeloggt</span></a>
                        </div>
                    </div>

matthias.lang's avatar
matthias.lang committed
160
161
162
163
164
165
166
167
168
169
                </div>

            </div>

            <div class="alert alert-danger" role="alert" v-if="error">
                <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
                 &#x26A0; {{ error }}
            </div>

            <div class="row" style="margin-top: 4em">
170
                <em>Zeige {{ filteredData.length }} von {{ resultData.length }} Treffern</em>
matthias.lang's avatar
matthias.lang committed
171
172
            </div>

173
            <table class="u-full-width" v-if="filteredData.length">
matthias.lang's avatar
matthias.lang committed
174
175
                <thead>
                    <tr>
176
                        <th />
matthias.lang's avatar
matthias.lang committed
177
                        <th v-for="entry in tableHeaders"
178
                                v-if="!entry.hideInPublicSearch || visitorLoggedIn"
matthias.lang's avatar
matthias.lang committed
179
180
181
182
183
184
185
186
187
188
                                @click="sortBy(entry.field)"
                                :class="{ active: sortKey == entry.field }">
                            {{ entry.description }}
                            <span class="arrow" :class="sortOrders[entry.field] > 0 ? 'asc' : 'dsc'">
                            </span>
                        </th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="entry in filteredData" style="vertical-align: top">
189
190
191
192
193
194
                        <td style="text-align: right">
                            <a :href="'https://api.ca.kit.edu/redirect/getcert/' + entry.serial">
                                <i class="fa fa-download" title="Download"></i>
                            </a>
                                <i class="fa fa-info-circle" aria-hidden="true"></i>
                        </td>
Heiko Reese's avatar
Heiko Reese committed
195
                        <td>
196
                            {{entry.cn}} <span v-if="entry.ou">({{entry.ou}})</span></b><br/>
197
                            <small>S/N: {{entry.serial}}</small>
Heiko Reese's avatar
Heiko Reese committed
198
199
200
201
                        </td>
                        <td>
                            <span v-for="email in entry.emailaddresses">{{email}} </span> <!-- TODO: -->
                        </td>
202
203
204
                        <td>
                                <span :title="entry.notafter">{{ entry.notafterduration }}</span>
                        </td>
Heiko Reese's avatar
Heiko Reese committed
205
206
207
208
209
210
                        <td>
                            <i v-if="entry.valid=='valid'"   :title="entry.valid" class="fa fa-check good"></i>
                            <i v-if="entry.valid=='expired'" :title="entry.valid" class="fa fa-times neutral"></i>
                            <i v-if="entry.valid=='revoked'" :title="entry.valid" class="fa fa-ban bad"></i>
                        </td>
                        <td>
matthias.lang's avatar
matthias.lang committed
211
212
213
214
215
216
                            <i v-if="entry.type=='Benutzer'"    class="fa fa-user"  :title="entry.type"></i>
                            <i v-if="entry.type=='Gruppe'"      class="fa fa-users" :title="entry.type"></i>
                            <i v-if="entry.type=='Pseudonym'"   class="fa fa-user-secret"   :title="entry.type"></i>
                            <i v-if="entry.type=='Extern'"      class="fa fa-user-plus" :title="entry.type"></i>
                            <i v-if="entry.type=='Unbekannt'"   class="fa fa-question-circle"   :title="entry.type"></i>
                            <i v-if="entry.type=='Server'"      class="fa fa-server"    :title="entry.type"></i>
Heiko Reese's avatar
Heiko Reese committed
217
                        </td>
218
                        <td v-if="visitorLoggedIn">
matthias.lang's avatar
matthias.lang committed
219
                            <i v-if="entry.public=='public'"  class="fa fa-eye" :title="entry.public"></i>
220
221
                            <i v-if="entry.public=='private'" class="fa fa-eye-slash" :title="entry.public"></i>
                            <i v-if="entry.public=='unknown'" class="fa fa-low-vision" :title="entry.public"></i>
Heiko Reese's avatar
Heiko Reese committed
222
                        </td>
matthias.lang's avatar
matthias.lang committed
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
                    </tr>
                </tbody>
            </table>


        </div>
    </div>


    <script type="text/javascript">
        var caSearch = new Vue({
            el: '#ca-search',
            data: {
                tableHeaders: [
                    {'field': 'cn',                 'description': 'Name'},
                    {'field': 'emailaddresses',     'description': 'E-Mail'},
                    {'field': 'notafterepoch',      'description': 'Ablaufdatum'},
                    {'field': 'valid',              'description': ''},
                    {'field': 'type',               'description': ''},
242
                    {'field': 'public',             'description': '', 'hideInPublicSearch': true},
matthias.lang's avatar
matthias.lang committed
243
244
245
246
247
248
249
250
                ],
                resultData: [],
                loading: false,
                error: false,
                query: '',
                sortKey: String,
                sortOrders: {},
                visitorLoggedIn: false,
251
252
253
                visitorGivenName: null,
                visitorSn: null,
                visitorMail: null,
matthias.lang's avatar
matthias.lang committed
254
255
256
257
258
259
260
261
                filterShow: {
                    'validity': {
                        'name': 'Gültigkeit',
                        'filters': {
                            'v_valid': {
                                'displayName': 'gültig',
                                'displayIcon': 'fa-check',
                                filterfunction: function(element) {return element.valid != 'valid' },
262
263
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
264
265
266
267
268
                            },
                            'v_expired': {
                                'displayName': 'abgelaufen',
                                'displayIcon': 'fa-times',
                                filterfunction: function(element) {return element.valid != 'expired' },
269
270
                                'buttonState': false,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
271
272
273
274
275
                            },
                            'v_revoked': {
                                'displayName': 'gesperrt',
                                'displayIcon': 'fa-ban',
                                filterfunction: function(element) {return element.valid != 'revoked' },
276
277
278
                                'buttonState': false,
                                'resultCount': 0
                            }
matthias.lang's avatar
matthias.lang committed
279
280
281
282
283
284
285
286
287
                        }
                    },
                    'types': {
                        'name': 'Typ',
                        'filters': {
                            't_user': {
                                'displayName': 'Nutzer',
                                'displayIcon': 'fa-user',
                                filterfunction: function(element) {return element.type != 'Benutzer' },
288
289
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
290
291
292
293
294
                            },
                            't_pseudonym': {
                                'displayName': 'PN',
                                'displayIcon': 'fa-user-secret',
                                filterfunction: function(element) {return element.type != 'Pseudonym' },
295
296
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
297
298
299
300
301
                            },
                            't_group': {
                                'displayName': 'Gruppe',
                                'displayIcon': 'fa-users',
                                filterfunction: function(element) {return element.type != 'Gruppe' },
302
303
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
304
305
306
307
308
                            },
                            't_extern': {
                                'displayName': 'Extern',
                                'displayIcon': 'fa-user-plus',
                                filterfunction: function(element) {return element.type != 'Extern' },
309
310
                                'buttonState': false,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
311
312
313
314
                            },
                            't_server': {
                                'displayName': 'Server',
                                'displayIcon': 'fa-server',
315
                                'hideInPublicSearch': true,
matthias.lang's avatar
matthias.lang committed
316
                                filterfunction: function(element) {return element.type != 'Server' },
317
318
319
320
                                'buttonState': false,
                                'resultCount': 0
                            }
                        }
matthias.lang's avatar
matthias.lang committed
321
322
323
                    },
                    'visibility': {
                        'name': 'Veröffentlicht',
324
                        'hideInPublicSearch': true,
matthias.lang's avatar
matthias.lang committed
325
326
327
328
329
                        'filters': {
                            'vis_public': {
                                'displayName': 'öffentlich',
                                'displayIcon': 'fa-eye',
                                filterfunction: function(element) {return element.public != 'public' },
330
331
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
332
333
334
335
336
                            },
                            'vis_private': {
                                'displayName': 'nicht-öffentlich',
                                'displayIcon': 'fa-eye-slash',
                                filterfunction: function(element) {return element.public == 'public' },
337
338
                                'buttonState': true,
                                'resultCount': 0
matthias.lang's avatar
matthias.lang committed
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
                            }
                        }
                    }

                }


            },
            computed: {
                filteredData: function () {
                    var sortKey = this.sortKey
                    var order = this.sortOrders[sortKey] || 1
                    var data = this.resultData

                    // filter
                    for (var filterCategory in this.filterShow) {
                        for (var elem in this.filterShow[filterCategory].filters) {             // TODO: UUGLLYYYYY. Fix it.
                            var filter = this.filterShow[filterCategory].filters[elem]
                            if (filter.buttonState == false) {
                                data = data.filter(filter.filterfunction)
                            }
                        }
                    }

                    // sort
                    if (sortKey) {
                        data = data.slice().sort(function (a, b) {
                            a = a[sortKey]
                            b = b[sortKey]
                            return (a === b ? 0 : a > b ? 1 : -1) * order
                        })
                    }

                    return data
                }

            },
            methods: {
                search: function() {
                    this.error = '';
                    this.resultData = [];

                    // Let the UI know we're busy
                    this.loading = true;

384
385
386
387
388
                    if (this.visitorLoggedIn) {
                        url = location.protocol + '//' + location.host + '/search/v1/json?q=';
                    } else {
                        url = location.protocol + '//' + location.host + '/pubsearch/v1/json?q=';
                    }
matthias.lang's avatar
matthias.lang committed
389
390

                    // Query our API
391
392
393
394
395
396
                    this.$http.get(url + encodeURIComponent(this.query)).then(
                        function(response) {
                            response.body.error ? this.error = response.body.error : this.resultData = response.body.results;
                            // Let the UI know we're done
                            this.loading = false;
                            //this.query = '';
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413



                            // bin search results
                            this.resultData.forEach(
                                function(entry) {
                                    for (var filterCategory in this.filterShow) {
                                        for (var elem in this.filterShow[filterCategory].filters) {
                                            var filter = this.filterShow[filterCategory].filters[elem]
                                            if (!filter.filterfunction(entry)) {
                                                filter.resultCount++;
                                            }
                                        }
                                    }
                                }, this
                            )

414
415
                        }
                    );
matthias.lang's avatar
matthias.lang committed
416
                    // TODO: error handling
417
418


matthias.lang's avatar
matthias.lang committed
419
420
                },

421
422
423
424
425
426
427
428
                // provisorium. TODO: replace with URLSearchParams polyfill or VueRouter
                getUrlParameter: function(name) {
                    name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]');
                    var regex = new RegExp('[\\?&]' + name + '=([^&#]*)');
                    var results = regex.exec(location.search);
                    return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' '));
                },

matthias.lang's avatar
matthias.lang committed
429

430
431
                getShibSessionData: function() {
                    url = location.protocol + '//' + location.host + '/Shibboleth.sso/Session';
matthias.lang's avatar
matthias.lang committed
432
433
434



435
436
437
                    // Query our API
                    this.$http.get(url).then(
                        function(response) {
438
439
                            //var res = JSON.parse(response.body); //TODO: this is only needed for local development
                            var res = response.body; //TODO
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
                            if (res.hasOwnProperty('expiration') && res.hasOwnProperty('attributes')) {
                                this.visitorLoggedIn = true;

                                res.attributes.forEach(
                                    function(item) {
                                        switch (item.name) {
                                            case 'givenName':
                                                this.visitorGivenName = item.values[0];
                                                break;
                                            case 'sn':
                                                this.visitorSn        = item.values[0];
                                                break;
                                            case 'mail':
                                                this.visitorMail      = item.values[0];
                                                break;
                                        }
                                    }, this
                                );

                                if (this.query == '') {
                                    this.query = this.visitorMail;
                                    this.search();
                                }
                            } else {
                                this.visitorLoggedIn = false;
                            }
                        },
                        function(response) {
                            // handle error
matthias.lang's avatar
matthias.lang committed
469

470
                            console.log('error')
matthias.lang's avatar
matthias.lang committed
471
                        }
472
473
                    );
/*
matthias.lang's avatar
matthias.lang committed
474
475
476
477
478
479
480
481
                    }, response => {    // error callback
                        if (response.status == 401) {
                            this.visitorLoggedIn = false;
                            this.visitorName     = null;
                            this.visitorEmail    = null;
                        } else {
                            this.error = "Couldn't figure out whether or not you're logged in. Will assume that you're not."
                        }
482
                        */
matthias.lang's avatar
matthias.lang committed
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
                },

                sortBy: function (key) {
                    this.sortKey = key
                    this.sortOrders[key] = this.sortOrders[key] * -1
                }
            },

            created: function () {
                var sortOrders = {};
                this.tableHeaders.forEach(function (key) {
                    sortOrders[key.field] = 1;
                });
                this.sortOrders = sortOrders;

498
                this.getShibSessionData();
499
500
501
502
503
504
505
506
507
508

                if (this.getUrlParameter('filter') == 'none') {
                    // disable all filters
                    for (var filterCategory in this.filterShow) {
                        for (var elem in this.filterShow[filterCategory].filters) {
                            this.filterShow[filterCategory].filters[elem].buttonState = true
                        }
                    }
                }
                this.query = this.getUrlParameter('q')
509
                if (this.query != '') {
510
511
512
                    this.search()
                }

matthias.lang's avatar
matthias.lang committed
513
514
515
516
            }
        });

    </script>
matthias.lang's avatar
matthias.lang committed
517

Heiko Reese's avatar
Heiko Reese committed
518
</body>