[Users | Trunk]: Add header.jsp. Change personal token page

This commit is contained in:
Konstantinos Triantafyllou 2020-10-20 14:27:03 +00:00
parent 1bd9397c0e
commit 84006bd941
4 changed files with 262 additions and 191 deletions

View File

@ -53,12 +53,15 @@ public class PersonalTokenServlet extends HttpServlet {
throws ServletException, IOException {
response.setContentType("text/html");
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
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("accessToken", authentication.getAccessTokenValue());
request.getSession().setAttribute("refreshToken", authentication.getRefreshTokenValue());
request.getRequestDispatcher("./personal.jsp").include(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();
String refreshToken = authentication.getRefreshTokenValue();
List<String> oldRefreshTokens = null;
@ -71,7 +74,7 @@ public class PersonalTokenServlet extends HttpServlet {
logger.error("Error deleting old refresh tokens.", e);
//TODO should I let user know?
}
request.setAttribute("display_refresh_token", "display:block");
request.getSession().setAttribute("showRefreshToken", true);
response.sendRedirect("./personalToken");
}

View File

@ -1,11 +1,16 @@
.aai-form-danger,.aai-form-danger:focus {
color:#f0506e;
border-color:#f0506e
:root {
--primary-color: #222080;
--secondary-color: #4686E5;
}
.aai-form-danger, .aai-form-danger:focus {
color: #f0506e;
border-color: #f0506e
}
h6, .aai-h6 {
text-transform: initial !important;
font-variant: small-caps;
text-transform: initial !important;
font-variant: small-caps;
}
.custom-footer {
@ -24,14 +29,21 @@ h6, .aai-h6 {
.uk-navbar-nav > li > a::before {
background-color: transparent !important;
}
.login svg{
fill: #222080;
.login svg {
fill: var(--primary-color);
}
.login:hover circle {
fill: var(--secondary-color);
}
.login text {
stroke: #fff;
fill: #fff;
font-weight: 400;
}
a:hover, .uk-link:hover{
a:hover, .uk-link:hover {
color: #222080;
}

View File

@ -0,0 +1,52 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<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" aria-expanded="false">
<svg height="60" width="60">
<circle cx="30" cy="30" r="20" stroke-width="2"></circle>
<text dy=".4em" font-size="16" text-anchor="middle" x="50%" y="50%"
class="ng-star-inserted">
${name}
</text>
</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>

View File

@ -1,203 +1,207 @@
<!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">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OpenAIRE - Personal token</title>
<script src="./js/jquery.js"></script>
<script src="./js/uikit.js"></script>
<script src="./js/uikit-icons-max.js"></script>
<script>
function copy(id) {
var element = document.getElementById(id);
if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(element);
range.select();
} else if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(element);
selection.removeAllRanges();
selection.addRange(range);
}
try {
document.execCommand('copy');
UIkit.notification({message: 'Copied to clipboard!', status: 'primary', pos: 'top-right'});
}
catch (err) {
console.error('unable to copy text');
}
}
</script>
<link rel="stylesheet" style="text/css" href="./css/theme.css">
<link rel="stylesheet" style="text/css" href="./css/custom.css">
<link rel="stylesheet" style="text/css" href="./css/aai-custom.css">
<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" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OpenAIRE - Personal token</title>
<script src="./js/jquery.js"></script>
<script src="./js/uikit.js"></script>
<script src="./js/uikit-icons-max.js"></script>
<script>
function copy(id) {
var element = document.getElementById(id);
if (document.body.createTextRange) {
range = document.body.createTextRange();
range.moveToElementText(element);
range.select();
} else if (window.getSelection) {
selection = window.getSelection();
range = document.createRange();
range.selectNodeContents(element);
selection.removeAllRanges();
selection.addRange(range);
}
try {
document.execCommand('copy');
UIkit.notification({message: 'Copied to clipboard!', status: 'primary', pos: 'top-right'});
} catch (err) {
console.error('unable to copy text');
}
}
</script>
<link rel="stylesheet" style="text/css" href="./css/theme.css">
<link rel="stylesheet" style="text/css" href="./css/custom.css">
<link rel="stylesheet" style="text/css" href="./css/aai-custom.css">
<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"/>
</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 -->
<!-- CONTENT STARTS HERE -->
<div class="uk-offcanvas-content uk-height-viewport">
<jsp:include page="header.jsp"/>
<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>
<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">
<div class="uk-grid ">
<div class="uk-width-1-4@m">
<div class="uk-card uk-card-default uk-card-body">
<div class="uk-h4">API Access</div>
<ul class="uk-nav uk-nav-default">
<li class="uk-active"><a href="./personalToken">Personal token</a></li>
<li class=""><a href="./registeredServices">Registered services</a></li>
<%--<li class="uk-parent">
<a href="#">Parent</a>
<ul class="uk-nav-sub">
<li><a href="#">Sub item</a></li>
<li>
<a href="#">Sub item</a>
<ul>
<li><a href="#">Sub item</a></li>
<li><a href="#">Sub item</a></li>
<div class="uk-grid ">
<div class="uk-width-1-4@m">
<div class="uk-card uk-card-default uk-card-body">
<div class="uk-h4">API Access</div>
<ul class="uk-nav uk-nav-default">
<li class="uk-active"><a href="./personalToken">Personal token</a></li>
<li class=""><a href="./registeredServices">Registered services</a></li>
<%--<li class="uk-parent">
<a href="#">Parent</a>
<ul class="uk-nav-sub">
<li><a href="#">Sub item</a></li>
<li>
<a href="#">Sub item</a>
<ul>
<li><a href="#">Sub item</a></li>
<li><a href="#">Sub item</a></li>
</ul>
</li>
</ul>
</li>--%>
</ul>
</li>
</ul>
</li>--%>
</ul>
</div>
</div>
<!-- CENTER SIDE -->
<div class="uk-width-2-3@l uk-width-2-3@m">
<div>
<span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${message}</span>
<c:remove var="message" scope="session" />
<form id="revoke" name="revoke" action="./personalToken" method="post">
<!-- <a class=" uk-text-danger uk-float-right" title="Revoke access token" onClick="document.revoke.submit();"><span uk-icon="refresh" ></span></a> -->
<a class=" uk-float-right uk-margin-small-left" onclick="copy('accessToken')" title="Copy access token"><span uk-icon="icon:copy"></span></a>
<div class="uk-h5">Your personal access token is</div>
<pre><code id="accessToken">${accessToken}</code></pre>
<span uk-icon="icon:info"></span> Your access token is <b>valid for an hour</b>.
</form>
</div>
<div class="uk-alert-danger uk-alert uk-margin-large-top" >
<p>Do not share your personal access token. Send your personal access token only over HTTPS.</p>
</div>
<div class="uk-alert-primary uk-alert" >
<span uk-icon="icon:info"></span> For further information on how to use the tokens please visit the <a href="">OpenAIRE API Authentication documentation</a>.
</div>
<div>
<!--<a class=" uk-text-danger uk-float-right" title="Revoke refresh token"><span uk-icon="refresh"></span></a>-->
<div class="uk-h5">Do you need a refresh token?</div>
<p>OpenAIRE refresh token <b>expires after 1 month</b> and allows you to programmatically get a new access token. </p>
<button type="submit" class="uk-button uk-button-primary" uk-toggle="target: #refreshWarning">Get a refresh token</button>
<div id="refreshTokenDiv" style="${display_refresh_token}">
<c:remove var="display_refresh_token" scope="session"/>
<div class="uk-alert-warning uk-alert" >
Please copy your refresh token and store it confidentially. You will not be able to retrieve it.
</div>
<div class="uk-alert-danger uk-alert uk-margin-large-top" >
<p>Do not share your refresh token. Send your personal access token only over HTTPS.</p>
</div>
<a class="uk-float-right uk-margin-small-left" onclick="copy('refreshToken')" title="Copy refresh token"><span uk-icon="icon: copy"></span></a>
<pre><code id="refreshToken">${refreshToken}</code></pre>
</div>
</div>
<!-- This is the modal -->
<div id="refreshWarning" uk-modal>
<div class="uk-modal-dialog uk-modal-body">
<form id="refreshForm" action="./personalToken" method="POST">
<h2 class="uk-modal-title">Get refresh token</h2>
<p>In case you already have a refresh token, it will no longer be valid. Do you want to proceed?</p>
<p class="uk-text-right">
<button class="uk-button uk-button-default uk-modal-close" type="button">Cancel</button>
<button class="uk-button uk-button-primary" type="button" onclick="submit();">Get refresh token</button>
</p>
<!-- CENTER SIDE -->
<div class="uk-width-2-3@l uk-width-2-3@m">
<div>
<span id="server_error" class="uk-text-danger uk-text-small uk-float-left">${message}</span>
<c:remove var="message" scope="session"/>
<div class="uk-alert-primary uk-margin-remove-top uk-alert uk-flex uk-flex-middle">
<span uk-icon="info"></span>
<span class="uk-margin-small-left">
For further information on how to use the tokens please visit the
<a href="">OpenAIRE API Authentication documentation</a>.
</span>
</div>
<form id="revoke" name="revoke" action="./personalToken" method="post">
<!-- <a class=" uk-text-danger uk-float-right" title="Revoke access token" onClick="document.revoke.submit();"><span uk-icon="refresh" ></span></a> -->
<h4 class="uk-margin-remove-top uk-text-bold uk-text-primary">Your personal access token is</h4>
<div class="uk-flex uk-flex-middle uk-margin-bottom">
<div class="uk-width-expand">
<pre class="uk-margin-remove-bottom"><code id="accessToken">${accessToken}</code></pre>
</div>
<div class="uk-width-auto uk-padding-small uk-text-center">
<a onclick="copy('accessToken')"
title="Copy access token"><span uk-icon="copy"></span>
</a>
</div>
</div>
<div class="uk-flex uk-flex-middle">
<span uk-icon="info"></span>
<span class="uk-margin-small-left">
Your access token is <span class="uk-text-bold">valid for an hour</span>.
</span>
</div>
<div class="uk-text-danger uk-flex uk-flex-middle uk-margin-small-top">
<span uk-icon="warning"></span>
<span class="uk-margin-small-left">
Do not share your personal access token. Send your personal access token only over HTTPS.
</span>
</div>
</form>
</div>
</div>
</div>
<div class="uk-section">
<!--<a class=" uk-text-danger uk-float-right" title="Revoke refresh token"><span uk-icon="refresh"></span></a>-->
<c:choose>
<c:when test="${showRefreshToken == true}">
<h4 class="uk-margin-remove-top uk-text-bold uk-text-primary">Your refresh token is</h4>
<div class="uk-flex uk-flex-middle uk-margin-bottom">
<div class="uk-width-expand">
<pre class="uk-margin-remove-bottom"><code id="refreshToken">${refreshToken}</code></pre>
</div>
<div class="uk-width-auto uk-padding-small uk-text-center">
<a onclick="copy('refreshToken')"
title="Copy refreshToken token"><span uk-icon="copy"></span>
</a>
</div>
</div>
<div class="uk-flex uk-flex-middle">
<span uk-icon="info"></span>
<span class="uk-margin-small-left">OpenAIRE refresh token <span class="uk-text-bold">expires after 1 month</span> and allows you to programmatically get a new access token.</span>
</div>
<div class="uk-text-danger uk-flex uk-flex-middle uk-margin-small-top">
<span uk-icon="warning"></span>
<div class="uk-margin-small-left">
<div>Please copy your refresh token and store it confidentially. You will not be able to retrieve it.</div>
<div>Do not share your refresh token. Send your refresh token only over HTTPS.</div>
</div>
</div>
</c:when>
<c:otherwise>
<h4 class="uk-margin-remove-top uk-text-bold uk-text-primary">Do you need a refresh token?</h4>
<div class="uk-flex uk-flex-middle">
<span uk-icon="info"></span>
<span class="uk-margin-small-left">OpenAIRE refresh token <span class="uk-text-bold">expires after 1 month</span> and allows you to programmatically get a new access token.</span>
</div>
<button type="submit" class="uk-button uk-button-primary uk-margin-medium-top" uk-toggle="target: #refreshWarning">Get a
refresh token
</button>
</c:otherwise>
</c:choose>
<!-- END OF CENTER SIDE -->
</div>
</div>
<!-- This is the modal -->
<div id="refreshWarning" uk-modal>
<div class="uk-modal-dialog uk-modal-body">
<form id="refreshForm" action="./personalToken" method="POST">
<h2 class="uk-modal-title">Get refresh token</h2>
<p>In case you already have a refresh token, it will no longer be valid. Do you want to
proceed?</p>
<p class="uk-text-right">
<button class="uk-button uk-button-default uk-modal-close" type="button">Cancel</button>
<button class="uk-button uk-button-primary uk-margin-small-left" type="button" onclick="submit();">Get
refresh token
</button>
</p>
</form>
</div>
</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 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>
</div> <!-- FOOTER ENDS HERE -->
</div>
</div>
</body>
</html>