Project

General

Profile

1
<%--
2
  Created by IntelliJ IDEA.
3
  User: sofia
4
  Date: 19/10/2017
5
  Time: 4:30 μμ
6
  To change this template use File | Settings | File Templates.
7
--%>
8
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
9
<!DOCTYPE html>
10
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
11
<html lang="en-gb" dir="ltr" vocab="http://schema.org/">
12
<head>
13
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
14
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
15
    <meta name="viewport" content="width=device-width, initial-scale=1">
16
    <base href=".">
17
    <title>OpenAIRE - Register</title>
18
    <script src="./js/jquery.js"></script>
19
    <script src="./js/uikit.js"></script>
20
    <script src="./js/uikit-icons-max.js"></script>
21
    <link rel="stylesheet" style="text/css" href="./css/theme.css">
22
    <link rel="stylesheet" style="text/css" href="./css/custom.css">
23
    <link rel="stylesheet" style="text/css" href="./css/aai-custom.css">
24
    <link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png">
25
    <link rel="icon" type="image/png" sizes="96x96" href="images/favicon//favicon-96x96.png">
26
    <link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
27
    <link href="images/favicon/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon"/>
28
</head>
29
<body class="" style="">
30
<div class="uk-offcanvas-content uk-height-viewport">
31
    <jsp:include page="header.jsp"/>
32
    <!-- CONTENT STARTS HERE -->
33
    <div class="first_page_section uk-section-default uk-section uk-padding-remove-vertical">
34
        <div class="first_page_banner_headline uk-grid-collapse uk-flex-middle uk-margin-remove-vertical uk-grid"
35
             uk-grid="">
36
        </div>
37
    </div>
38
    <div class=" uk-section  uk-margin-small-top uk-container uk-container-large" id="tm-main">
39
        <div class="uk-grid ">
40
            <div class="uk-width-1-4@m">
41
                <div class="uk-card uk-card-default uk-card-body">
42
                    <div class="uk-h4">API Access</div>
43
                    <ul class="uk-nav uk-nav-default">
44
                        <li class=""><a href="./personalToken">Personal token</a></li>
45
                        <li class=""><a href="./registeredServices">Registered services</a></li>
46
                    </ul>
47
                </div>
48
            </div>
49
            <!-- CENTER SIDE -->
50
            <div class="uk-width-2-3@l uk-width-2-3@m">
51
                <h4 class="uk-margin-remove-top uk-text-bold uk-text-primary">Add a new service</h4>
52
                <!-- REGISTER FORM -->
53
                <div id="registerForm">
54
                    <form action="registerService" method="POST" role="form" class="m-t uk-form-horizontal"
55
                          id="register_form">
56
                        <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
57
                        <div class="alert alert-success" aria-hidden="true" style="display: none;"></div>
58
                        <div class="alert alert-danger" aria-hidden="true" style="display: none;"></div>
59
                        <span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${message}</span>
60
                        <c:remove var="message" scope="session"/>
61
                        <h4 class="uk-text-bold uk-text-center">General</h4>
62
                        <div class="uk-margin-medium-top">
63
                            <label class="uk-form-label uk-text-bold" for="first_name">Name*</label>
64
                            <input id="first_name" name="first_name" type="text" placeholder="Name (*)"
65
                                   class="form-control" value=${first_name}>
66
                            <span class="uk-text-danger uk-text-small">
67
                                Please enter a name for your service.</span>
68
                            <c:remove var="msg_first_name_error_display" scope="session"/>
69
                        </div>
70
                        <div class="uk-margin-medium-top">
71
                            <label class="uk-form-label uk-text-bold" for="description">Description</label>
72
                            <textarea id="description" name="description" type="textarea" placeholder="Description:"
73
                                      class="form-control uk-textarea" rows="3" value=${description}></textarea>
74
                        </div>
75
                        <hr class="uk-margin-medium uk-divider">
76
                        <h4 class="uk-text-bold uk-text-center">Access</h4>
77
                        <div class="uk-margin-medium-top">
78
                            <label class="uk-form-label uk-text-bold">Scope</label>
79
                            <input disabled value="openid" class="uk-input">
80
                        </div>
81
                        <div class="uk-margin-medium-top">
82
                            <label class="uk-form-label uk-text-bold">Grant Types</label>
83
                            <input disabled value="client credentials" class="uk-input">
84
                        </div>
85
                        <hr class="uk-margin-medium uk-divider">
86
                        <h4 class="uk-text-bold uk-text-center">Credentials</h4>
87
                        <div class="uk-margin-medium-top">
88
                            <label class="uk-form-label uk-text-bold">Authentication Method</label>
89
                            <input disabled value="Asymmetrically-signed JWT assertion" class="uk-input">
90
                        </div>
91
                        <div class="uk-margin-medium-top">
92
                            <label class="uk-form-label uk-text-bold">Token Endpoint Authentication
93
                                Signing Algorithm</label>
94
                            <input disabled value="RSASSA using SHA-256 hash algorithm" class="uk-input">
95
                        </div>
96
                        <div class="uk-margin-medium-top">
97
                            <label class="uk-form-label uk-text-bold">Public Key Set</label>
98
                            <span class="uk-float-right">
99
                                <span class="uk-margin-small-right">
100
                                    <input id="by_value" class="uk-radio uk-margin-small-right" type="radio" name="key_radio" value="value" ${(key_radio == 'value' || key_radio == '' || key_radio == null) ? 'checked' : ''}>
101
                                    <label class="clickable" for="by_value">By Value</label>
102
                                </span>
103
                                <span>
104
                                    <input id="by_uri" class="uk-radio uk-margin-small-right" type="radio" name="key_radio" value="uri" ${key_radio == 'uri' ? 'checked' : ''}>
105
                                    <label class="clickable" for="by_uri">By URI</label>
106
                                </span>
107
                            </span>
108
                            <div id="value_input">
109
                                <textarea id="value" name="value" type="textarea" placeholder='{"kty": ..., "e": ... , "use": ... , "kid": ..., "alg": ... , "n": ...}'
110
                                          class="form-control uk-textarea" rows="10">${value}</textarea>
111
                                <span class="uk-text-danger uk-text-small">Please provide a valid JSON.</span>
112
                            </div>
113
                            <div id="uri_input" style="display:none;">
114
                                <input id="uri" name="uri" type="text" placeholder="https://" class="form-control" value="${jwksUri}">
115
                                <span class="uk-text-danger uk-text-small">Please provide a valid URI (do not forget the protocol! https://...)</span>
116
                            </div>
117
                        </div>
118
                        <div class="uk-flex uk-flex-right uk-margin-medium-top">
119
                            <a type="submit" class="uk-button uk-button-default uk-margin-small-right"
120
                               href="./registeredServices">Cancel</a>
121
                            <button type="submit" class="uk-button uk-button-primary" onclick="return validate();">
122
                                Add new service
123
                            </button>
124
                        </div>
125
                    </form>
126
                </div>
127
                <!-- END OF REGISTER FORM -->
128
                </ul>
129
            </div>
130
            <!-- END OF CENTER SIDE -->
131
        </div>
132
    </div>
133
    <!-- CONTENT ENDS HERE -->
134
    <!-- FOOTER STARTS HERE-->
135
    <div class="custom-footer" style="z-index: 200;">
136
        <div class="uk-section-primary uk-section uk-section-small">
137
            <div class="uk-container">
138
                <div class="uk-grid-margin uk-grid uk-grid-stack" uk-grid="">
139
                    <div class="uk-width-1-1@m uk-first-column">
140
                        <div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-center">
141
                            <img alt="OpenAIRE" class="el-image" src="./images/Logo_Horizontal_white_small.png">
142
                        </div>
143
                        <div class="footer-license uk-margin uk-margin-remove-bottom uk-text-center uk-text-lead">
144
                            <div><a href="http://creativecommons.org/licenses/by/4.0/" target="_blank"
145
                                    rel="license"><img alt="Creative" src="./images/80x15.png"
146
                                                       style="height: auto; max-width: 100%; vertical-align: middle;"></a>&nbsp;UNLESS
147
                                OTHERWISE INDICATED, ALL MATERIALS CREATED BY THE OPENAIRE CONSORTIUM ARE LICENSED UNDER
148
                                A&nbsp;<a href="http://creativecommons.org/licenses/by/4.0/" rel="license">CREATIVE
149
                                    COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE</a>.
150
                            </div>
151
                            <div>OPENAIRE IS POWERED BY&nbsp;<a href="http://www.d-net.research-infrastructures.eu/">D-NET</a>.
152
                            </div>
153
                        </div>
154
                        <div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-right">
155
                            <a class="uk-totop uk-icon" href="#" uk-scroll="" uk-totop="">
156
                            </a>
157
                        </div>
158
                    </div>
159
                </div>
160
            </div>
161
        </div>
162
    </div>
163
</div>
164
</body>
165
</html>
166
<script>
167
    $('input[type=radio][name=key_radio]').change(function () {
168
        if (this.value == 'uri') {
169
            $("#uri_input").show();
170
            $("#value_input").hide();
171

    
172
        } else if (this.value == 'value') {
173
            $("#uri_input").hide();
174
            $("#value_input").show();
175
        }
176
    });
177

    
178
    function validate() {
179
        var isValid = false;
180
        if ($("#first_name").val() != undefined) {
181
            if ($.trim($("#first_name").val()).length <= 0) {
182
                $("#first_name").addClass('uk-input aai-form-danger');
183
                $(".msg_first_name_error").show();
184
                return false;
185
            } else {
186
                $(".msg_first_name_error").hide();
187
                $("#first_name").removeClass('aai-form-danger');
188
            }
189
        }
190

    
191
        if ($('input[type=radio][name=key_radio]:checked').val() === 'value') {
192
            isValid = validateJSON();
193
            if (!isValid) {
194
                $("#value_input").addClass('uk-input aai-form-danger');
195
                $(".msg_key_value_error_display").show();
196
                return false;
197
            }
198
        }
199

    
200
        if ($('input[type=radio][name=key_radio]:checked').val() === 'uri') {
201
            isValid = validateURI();
202
            if (!isValid) {
203
                $("#uri_input").addClass('uk-input aai-form-danger');
204
                $(".msg_key_uri_error_display").show();
205
                return false;
206
            }
207
        }
208

    
209
    }
210

    
211
    function validateJSON() {
212
        if ($("#value").val() != undefined && $("#value").val() !== "") {
213
            if (/^[\],:{}\s]*$/.test($("#value").val().replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
214
                return true;
215

    
216
            } else {
217
                return false;
218
            }
219
        }
220
        return false;
221
    }
222

    
223
    function validateURI() {
224
        if ($("#uri").val() != undefined && $("#uri").val() !== "") {
225
            return /^(?:(?:(?:https):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test($("#uri").val());
226
        }
227
        return false;
228
    }
229

    
230
    $("#first_name").focusin(function () {
231
        $(this).removeClass('aai-form-danger');
232
        $(".msg_first_name_error").fadeOut();
233
    });
234

    
235
    $("#value_input").focusin(function () {
236
        $(this).removeClass('aai-form-danger');
237
        $(".msg_key_value_error").fadeOut();
238
    });
239

    
240
    $("#uri_input").focusin(function () {
241
        $(this).removeClass('aai-form-danger');
242
        $(".msg_key_uri_error").fadeOut();
243
    });
244
</script>
(14-14/26)