[Users | Trunk]: Add login in all pages. Change form ui

This commit is contained in:
Konstantinos Triantafyllou 2020-10-21 10:23:46 +00:00
parent 77cd9864e5
commit a153f36a66
5 changed files with 203 additions and 264 deletions

View File

@ -45,6 +45,9 @@ public class RegisterServiceServlet extends HttpServlet {
checkNumberOfRegisteredServices(request, response, authentication);
response.setContentType("text/html");
StringBuilder name = new StringBuilder().append(authentication.getUserInfo().getGivenName().charAt(0));
name.append(authentication.getUserInfo().getFamilyName().charAt(0));
request.getSession().setAttribute("name", name.toString());
request.getRequestDispatcher("./registerService.jsp").include(request, response);
}

View File

@ -73,6 +73,9 @@ public class RegisteredServicesServlet extends HttpServlet {
}
boolean reachedLimit = reachedMaximumNumberOfServices(registeredServices);
StringBuilder name = new StringBuilder().append(authentication.getUserInfo().getGivenName().charAt(0));
name.append(authentication.getUserInfo().getFamilyName().charAt(0));
request.getSession().setAttribute("name", name.toString());
request.getSession().setAttribute("reachedLimit", reachedLimit);
request.getSession().setAttribute("test", "TEST");
System.out.println("REACHED LIMIT??? " + reachedLimit);

View File

@ -47,3 +47,14 @@ h6, .aai-h6 {
a:hover, .uk-link:hover {
color: #222080;
}
.uk-form-label {
font-size: 16px;
width: auto !important;
margin-top: 0 !important;
float: none !important;
}
.clickable {
cursor: pointer;
}

View File

@ -7,7 +7,7 @@
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="en-gb" dir="ltr" vocab="http://schema.org/">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
@ -24,60 +24,15 @@
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="images/favicon//favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon/favicon-16x16.png">
<link href="images/favicon/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
<link href="images/favicon/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon"/>
</head>
<body class="" style="">
<div class="uk-offcanvas-content uk-height-viewport">
<!-- MENU STARTS HERE -->
<!-- MAIN MENU STARTS HERE -->
<div class="tm-header tm-header-transparent" uk-header="">
<div class="uk-container uk-container-expand">
<nav class="uk-navbar" uk-navbar="{&quot;align&quot;:&quot;left&quot;}">
<div class="uk-navbar-center">
<div class="uk-logo uk-navbar-item">
<img alt="OpenAIRE" class="uk-responsive-height" src="./images/Logo_Horizontal.png">
</div>
</div>
<!-- user menu -->
<div class=uk-navbar-right>
<ul class="uk-navbar-nav user_actions">
<c:choose>
<c:when test="${not authenticated}">
<li><a href="./openid_connect_login"> Sign in </a></li>
</c:when>
<c:otherwise>
<li>
<a class="login uk-icon" aria-expanded="false">
<svg height="60" width="60">
<span uk-icon="icon: user; ratio: 2"></span></svg>
</a>
</c:otherwise>
</c:choose>
<div class="uk-navbar-dropdown uk-navbar-dropdown-bottom-right" id="userMenu" style="left: 344.433px; top: 100px;">
<div class="uk-navbar-dropdown-grid uk-child-width-1-1 uk-grid uk-grid-stack" uk-grid="">
<div class="uk-first-column uk-height-max-medium uk-overflow-auto">
<ul class="uk-nav uk-navbar-dropdown-nav">
<li class=""><a href="./personalToken">Personal token</a></li>
<li class=""><a href="./registeredServices">Registered services</a></li>
<li class="uk-nav-divider "></li>
<li>
<a href="./openid_logout" id="logout">Log out</a>
</li>
</ul>
</div>
</div>
</div>
</li>
</ul>
</div>
<!-- USER MENU ENDS HERE -->
</nav>
</div>
</div>
<!-- MENU ENDS HERE -->
<jsp:include page="header.jsp"/>
<!-- CONTENT STARTS HERE -->
<div class="first_page_section uk-section-default uk-section uk-padding-remove-vertical">
<div class="first_page_banner_headline uk-grid-collapse uk-flex-middle uk-margin-remove-vertical uk-grid" uk-grid="">
<div class="first_page_banner_headline uk-grid-collapse uk-flex-middle uk-margin-remove-vertical uk-grid"
uk-grid="">
</div>
</div>
<div class=" uk-section uk-margin-small-top uk-container uk-container-large" id="tm-main">
@ -93,75 +48,123 @@
</div>
<!-- CENTER SIDE -->
<div class="uk-width-2-3@l uk-width-2-3@m">
<h2 class="uk-h2 uk-margin-small-bottom">Add a new service</h2>
<div class="middle-box text-center loginscreen animated fadeInDown ">
<div class="k-width-1-1@m uk-width-1-1@s uk-text-center">
<h4 class="uk-margin-remove-top uk-text-bold uk-text-primary">Add a new service</h4>
<!-- REGISTER FORM -->
<div id="registerForm">
<form action="registerService" method="POST" role="form" class="m-t uk-form-horizontal" id="register_form">
<form action="registerService" method="POST" role="form" class="m-t uk-form-horizontal"
id="register_form">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<div class="alert alert-success" aria-hidden="true" style="display: none;"></div>
<div class="alert alert-danger" aria-hidden="true" style="display: none;"></div>
<span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${message}</span>
<c:remove var="message" scope="session" />
<h5 class="uk-h5">General</h5>
<div class="uk-margin">
<label class="uk-form-label" for="form-horizontal-text">Name(*)</label>
<span class="msg_first_name_error uk-text-danger uk-text-small uk-float-left" style='${msg_first_name_error_display}'>Please enter a name for your service.</span>
<input id="first_name" name="first_name" type="text" placeholder="Name (*)" class="form-control" value="${first_name}">
<c:remove var="msg_first_name_error_display" scope="session" />
<c:remove var="first_name" scope="session" />
<c:remove var="message" scope="session"/>
<h4 class="uk-text-bold uk-text-center">General</h4>
<div class="uk-margin-medium-top">
<label class="uk-form-label uk-text-bold" for="first_name">Name*</label>
<input id="first_name" name="first_name" type="text" placeholder="Name (*)"
class="form-control" value=${first_name}>
<span class="uk-text-danger uk-text-small">
Please enter a name for your service.</span>
<c:remove var="msg_first_name_error_display" scope="session"/>
</div>
<div class="uk-margin">
<label class="uk-form-label" for="form-horizontal-text">Description</label>
<textarea id="description" name="description" type="textarea" placeholder="Description:" class="form-control uk-textarea" rows="3" value=${description}></textarea>
<c:remove var="organization" scope="session" />
<div class="uk-margin-medium-top">
<label class="uk-form-label uk-text-bold" for="description">Description</label>
<textarea id="description" name="description" type="textarea" placeholder="Description:"
class="form-control uk-textarea" rows="3" value=${description}></textarea>
</div>
<hr class="uk-margin-remove-top">
<h5 class="uk-h5">Access</h5>
<div class="uk-margin">
<label class="uk-form-label" for="form-horizontal-text">Scope</label>
<input disabled value="openid" class="uk-input"></input>
<hr class="uk-margin-medium uk-divider">
<h4 class="uk-text-bold uk-text-center">Access</h4>
<div class="uk-margin-medium-top">
<label class="uk-form-label uk-text-bold">Scope</label>
<input disabled value="openid" class="uk-input">
</div>
<div class="uk-margin">
<label class="uk-form-label" for="form-horizontal-text">Grant Types</label>
<input disabled value="client credentials" class="uk-input"></input>
<div class="uk-margin-medium-top">
<label class="uk-form-label uk-text-bold">Grant Types</label>
<input disabled value="client credentials" class="uk-input">
</div>
<hr class="uk-margin-remove-top">
<h5 class="uk-h5">Credentials</h5>
<div class="uk-margin">
<label class="uk-form-label" for="form-horizontal-text">Authentication Method</label>
<input disabled value="Asymmetrically-signed JWT assertion" class="uk-input"></input>
<hr class="uk-margin-medium uk-divider">
<h4 class="uk-text-bold uk-text-center">Credentials</h4>
<div class="uk-margin-medium-top">
<label class="uk-form-label uk-text-bold">Authentication Method</label>
<input disabled value="Asymmetrically-signed JWT assertion" class="uk-input">
</div>
<div class="uk-margin">
<label class="uk-form-label" for="form-horizontal-text">Token Endpoint Authentication Signing Algorithm</label>
<input disabled value="RSASSA using SHA-256 hash algorithm" class="uk-input"></input>
<div class="uk-margin-medium-top">
<label class="uk-form-label uk-text-bold">Token Endpoint Authentication
Signing Algorithm</label>
<input disabled value="RSASSA using SHA-256 hash algorithm" class="uk-input">
</div>
<div class="uk-margin">
<label class="uk-form-label" for="form-horizontal-text">Public Key Set</label>
<label><input class="uk-radio" type="radio" name="key_radio" value="value" ${(key_radio == 'value' || key_radio == '') ? 'checked' : ''} >By Value</label>
<label><input class="uk-radio" type="radio" name="key_radio" value="${uri}" ${key_radio == 'uri' ? 'checked' : ''} >By URI</label><br>
<div class="uk-margin-medium-top">
<label class="uk-form-label uk-text-bold">Public Key Set</label>
<span class="uk-float-right">
<span class="uk-margin-small-right">
<input id="by_value" class="uk-radio uk-margin-small-right" type="radio" name="key_radio" value="value" checked>
<label class="clickable" for="by_value">By Value</label>
</span>
<span>
<input id="by_uri" class="uk-radio uk-margin-small-right" type="radio" name="key_radio" value="uri">
<label class="clickable" for="by_uri">By URI</label>
</span>
</span>
<div id="value_input">
<span class="msg_key_value_error uk-text-danger uk-text-small uk-float-left" style='${msg_key_value_error_display}'>Please provide a valid JSON.</span>
<textarea id="value" name="value" type="textarea" placeholder='{"keys":[]}' class="form-control uk-textarea" rows="10" value="${value}"></textarea>
<textarea id="value" name="value" type="textarea" placeholder='{"keys":[]}'
class="form-control uk-textarea" rows="10">{"keys":[]}</textarea>
<span class="uk-text-danger uk-text-small">Please provide a valid JSON.</span>
</div>
<div id="uri_input" style="display:none;">
<span class="msg_key_uri_error uk-text-danger uk-text-small uk-float-left" style='${msg_key_uri_error_display}'>Please provide a valid URI (do not forget the protocol! https://...)</span>
<input id="uri" name="uri" type="text" placeholder="https://" class="form-control" value=${uri}>
<input id="uri" name="uri" type="text" placeholder="https://" class="form-control" value="${jwksUri}">
<span class="uk-text-danger uk-text-small">Please provide a valid URI (do not forget the protocol! https://...)</span>
</div>
</div>
<hr class="uk-margin-remove-top">
<div class="uk-width-1-1 uk-grid-margin uk-first-column">
<a type="submit" class="uk-button uk-button-default" href="./registeredServices">Cancel</a>
<button type="submit" class="uk-button uk-button-primary" onclick="return validate();">Add new service</button>
<div class="uk-flex uk-flex-right uk-margin-medium-top">
<a type="submit" class="uk-button uk-button-default uk-margin-small-right"
href="./registeredServices">Cancel</a>
<button type="submit" class="uk-button uk-button-primary" onclick="return validate();">
Add new service
</button>
</div>
</form>
</div>
<!-- END OF REGISTER FORM -->
<script>
$('input[type=radio][name=key_radio]').change(function() {
</ul>
</div>
<!-- END OF CENTER SIDE -->
</div>
</div>
<!-- CONTENT ENDS HERE -->
<!-- FOOTER STARTS HERE-->
<div class="custom-footer" style="z-index: 200;">
<div class="uk-section-primary uk-section uk-section-small">
<div class="uk-container">
<div class="uk-grid-margin uk-grid uk-grid-stack" uk-grid="">
<div class="uk-width-1-1@m uk-first-column">
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-center">
<img alt="OpenAIRE" class="el-image" src="./images/Logo_Horizontal_white_small.png">
</div>
<div class="footer-license uk-margin uk-margin-remove-bottom uk-text-center uk-text-lead">
<div><a href="http://creativecommons.org/licenses/by/4.0/" target="_blank"
rel="license"><img alt="Creative" src="./images/80x15.png"
style="height: auto; max-width: 100%; vertical-align: middle;"></a>&nbsp;UNLESS
OTHERWISE INDICATED, ALL MATERIALS CREATED BY THE OPENAIRE CONSORTIUM ARE LICENSED UNDER
A&nbsp;<a href="http://creativecommons.org/licenses/by/4.0/" rel="license">CREATIVE
COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE</a>.
</div>
<div>OPENAIRE IS POWERED BY&nbsp;<a href="http://www.d-net.research-infrastructures.eu/">D-NET</a>.
</div>
</div>
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-right">
<a class="uk-totop uk-icon" href="#" uk-scroll="" uk-totop="">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
$('input[type=radio][name=key_radio]').change(function () {
if (this.value == 'uri') {
$("#uri_input").show();
$("#value_input").hide();
@ -174,8 +177,8 @@
function validate() {
var isValid = false;
if($("#first_name").val() != undefined) {
if($.trim($("#first_name").val()).length <= 0) {
if ($("#first_name").val() != undefined) {
if ($.trim($("#first_name").val()).length <= 0) {
$("#first_name").addClass('uk-input aai-form-danger');
$(".msg_first_name_error").show();
return false;
@ -185,7 +188,7 @@
}
}
if ($('input[type=radio][name=key_radio]:checked').val()==='value') {
if ($('input[type=radio][name=key_radio]:checked').val() === 'value') {
isValid = validateJSON();
if (!isValid) {
$("#value_input").addClass('uk-input aai-form-danger');
@ -194,7 +197,7 @@
}
}
if ($('input[type=radio][name=key_radio]:checked').val()==='uri') {
if ($('input[type=radio][name=key_radio]:checked').val() === 'uri') {
isValid = validateURI();
if (!isValid) {
$("#uri_input").addClass('uk-input aai-form-danger');
@ -206,10 +209,8 @@
}
function validateJSON() {
if ($("#value").val() != undefined && $("#value").val()!=="") {
if (/^[\],:{}\s]*$/.test($("#value").val().replace(/\\["\\\/bfnrtu]/g, '@').
replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').
replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
if ($("#value").val() != undefined && $("#value").val() !== "") {
if (/^[\],:{}\s]*$/.test($("#value").val().replace(/\\["\\\/bfnrtu]/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
return true;
} else {
@ -220,7 +221,7 @@
}
function validateURI() {
if ($("#uri").val() != undefined && $("#uri").val()!=="") {
if ($("#uri").val() != undefined && $("#uri").val() !== "") {
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());
}
return false;
@ -240,37 +241,4 @@
$(this).removeClass('aai-form-danger');
$(".msg_key_uri_error").fadeOut();
});
</script>
</div>
</ul>
</div>
</div>
<!-- END OF CENTER SIDE -->
</div>
</div>
<!-- CONTENT ENDS HERE -->
<!-- FOOTER STARTS HERE-->
<div class="custom-footer" style="z-index: 200;">
<div class="uk-section-primary uk-section uk-section-small">
<div class="uk-container">
<div class="uk-grid-margin uk-grid uk-grid-stack" uk-grid="">
<div class="uk-width-1-1@m uk-first-column">
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-center">
<img alt="OpenAIRE" class="el-image" src="./images/Logo_Horizontal_white_small.png">
</div>
<div class="footer-license uk-margin uk-margin-remove-bottom uk-text-center uk-text-lead">
<div><a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" rel="license"><img alt="Creative" src="./images/80x15.png" style="height: auto; max-width: 100%; vertical-align: middle;"></a>&nbsp;UNLESS OTHERWISE INDICATED, ALL MATERIALS CREATED BY THE OPENAIRE CONSORTIUM ARE LICENSED UNDER A&nbsp;<a href="http://creativecommons.org/licenses/by/4.0/" rel="license">CREATIVE COMMONS ATTRIBUTION 4.0 INTERNATIONAL LICENSE</a>.</div>
<div>OPENAIRE IS POWERED BY&nbsp;<a href="http://www.d-net.research-infrastructures.eu/">D-NET</a>.</div>
</div>
<div class="uk-margin uk-margin-remove-top uk-margin-remove-bottom uk-text-right">
<a class="uk-totop uk-icon" href="#" uk-scroll="" uk-totop="">
</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
</script>

View File

@ -23,53 +23,7 @@
</head>
<body class="" style="">
<div class="uk-offcanvas-content uk-height-viewport">
<!-- MENU STARTS HERE -->
<!-- MAIN MENU STARTS HERE -->
<div class="tm-header tm-header-transparent" uk-header="">
<div class="uk-container uk-container-expand">
<nav class="uk-navbar" uk-navbar="{&quot;align&quot;:&quot;left&quot;}">
<div class="uk-navbar-center">
<div class="uk-logo uk-navbar-item">
<img alt="OpenAIRE" class="uk-responsive-height" src="./images/Logo_Horizontal.png">
</div>
</div>
<!-- user menu -->
<div class=uk-navbar-right>
<ul class="uk-navbar-nav user_actions">
<c:choose>
<c:when test="${not authenticated}">
<li><a href="./openid_connect_login"> Sign in </a></li>
</c:when>
<c:otherwise>
<li>
<a class="login uk-icon" aria-expanded="false">
<svg height="60" width="60">
<span uk-icon="icon: user; ratio: 2"></span></svg>
</a>
</c:otherwise>
</c:choose>
<div class="uk-navbar-dropdown uk-navbar-dropdown-bottom-right" id="userMenu" style="left: 344.433px; top: 100px;">
<div class="uk-navbar-dropdown-grid uk-child-width-1-1 uk-grid uk-grid-stack" uk-grid="">
<div class="uk-first-column uk-height-max-medium uk-overflow-auto">
<ul class="uk-nav uk-navbar-dropdown-nav">
<li class=""><a href="./personalToken">Personal token</a></li>
<li class=""><a href="./registeredServices">Registered services</a></li>
<li class="uk-nav-divider "></li>
<li>
<a href="./openid_logout" id="logout">Log out</a>
</li>
</ul>
</div>
</div>
</div>
</li>
</ul>
</div>
<!-- USER MENU ENDS HERE -->
</nav>
</div>
</div>
<!-- MENU ENDS HERE -->
<jsp:include page="header.jsp"/>
<!-- CONTENT STARTS HERE -->
<div class="first_page_section uk-section-default uk-section uk-padding-remove-vertical">
<div class="first_page_banner_headline uk-grid-collapse uk-flex-middle uk-margin-remove-vertical uk-grid" uk-grid="">