Finalizing edit and create methods and forms

This commit is contained in:
Katerina Iatropoulou 2020-11-03 13:25:29 +00:00
parent 52f6ab3ac4
commit e947a9c7c3
6 changed files with 31 additions and 17 deletions

View File

@ -16,6 +16,7 @@ public class OverviewServlet extends HttpServlet {
boolean isAuthenticated = !SecurityContextHolder.getContext().getAuthentication().getPrincipal().toString()
.equals("anonymousUser");
System.out.println("Authenticated ? " + isAuthenticated);
if (isAuthenticated) {
OIDCAuthenticationToken authentication = (OIDCAuthenticationToken) SecurityContextHolder.getContext().getAuthentication();

View File

@ -126,7 +126,12 @@ public class RegisterServiceServlet extends HttpServlet {
} else {
request.getSession().setAttribute("key_radio", "value");
Key key = serviceResponse.getJwks().keys[0];
Key key;
if (serviceResponse.getJwks()!= null) {
key = serviceResponse.getJwks().keys[0];
} else {
key = new Key();
}
System.out.println("Service response keys " + serviceResponse.getJwksUri());
Gson gson = new GsonBuilder().setPrettyPrinting().create();
request.getSession().setAttribute("value", gson.toJson(key));
@ -234,7 +239,8 @@ public class RegisterServiceServlet extends HttpServlet {
try {
registeredServicesUtils.addRegistedService(registeredService);
request.getSession().setAttribute("success", "Your service has been successfully registered!");
request.getSession().setAttribute("success", "Your service has been successfully registered!The id of your service is " +
serviceResponse.getClientId());
} catch (SQLException sqle) {
logger.error("Fail to save service.", sqle);
@ -280,7 +286,8 @@ public class RegisterServiceServlet extends HttpServlet {
return;
}
request.getSession().setAttribute("success", "Your service with name '" + name + "' was successfully updated");
request.getSession().setAttribute("success", "Your service with name " + name + " was successfully updated.The id of your service " +
"is " + serviceResponse.getClientId());
}
} else {

View File

@ -13,7 +13,7 @@ public class ServiceRequest {
String[] scope = new String[]{"openid"};
String[] grantTypes = new String[] {"client_credentials"};
boolean allowIntrospection = true;
String tokenEndpointAuthMethod = "PRIVATE KEY";
String tokenEndpointAuthMethod = "PRIVATE_KEY";
String tokenEndpointAuthSigningAlg = "RS256";
String jwksType;
String jwksUri;

View File

@ -28,9 +28,9 @@
<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">
<div class="uk-offcanvas-content uk-height-viewport">Ï
<!-- MENU STARTS HERE -->
<c:import url="header.jsp"/>
<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="">

View File

@ -43,7 +43,6 @@
</div>
<!-- CENTER SIDE -->
<div class="uk-width-2-3@l uk-width-2-3@m">
>>>>>> ${param.id}
<c:choose>
<c:when test="${not empty param.id}">
<h4 class="uk-margin-remove-top uk-text-bold uk-text-primary">Edit service</h4>
@ -169,7 +168,7 @@
<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 id="create" type="submit" class="uk-button uk-button-primary">
<button id="create" type="submit" class="uk-button uk-button-primary" onclick="return validate();">
<c:choose>
<c:when test="${not empty param.id}">
Edit service
@ -224,13 +223,15 @@
function validate() {
var isValid = true;
var create = $('#create');
//create.prop('disabled', true);
create.prop('disabled', true);
var name = $("#first_name");
if (name.val() !== undefined) {
if ($.trim(name.val()).length <= 0) {
if (nameTouched) {
name.addClass('uk-form-danger');
$("#first_name_error").show();
$("#first_name").get(0).scrollIntoView();
}
isValid = false;
} else {
@ -270,7 +271,7 @@
}
}
if (isValid) {
//create.prop('disabled', false);
create.prop('disabled', false);
}
return isValid;
}

View File

@ -21,7 +21,7 @@
<link href="images/favicon/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon"/>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
</head>
<body class="" style="">
<body class="" style="" onload="success();">
<div class="uk-offcanvas-content uk-height-viewport">
<jsp:include page="header.jsp"/>
<!-- CONTENT STARTS HERE -->
@ -41,10 +41,6 @@
<div class="uk-grid" uk-grid>
<div class="uk-width-expand@m">
<h4 class="uk-margin-remove-top uk-text-bold uk-text-primary">Registered services</h4>
<c:if test="${success != null}">
<div class="uk-text-success uk-margin-small-bottom">${success}</div>
<c:remove var="success" scope="session"/>
</c:if>
<c:if test="${message != null}">
<div class="uk-text-danger uk-margin-small-bottom">${message}</div>
<c:remove var="message" scope="session"/>
@ -87,7 +83,7 @@
<li>
<div class="uk-grid uk-child-width-1-4 uk-text-muted" uk-grid>
<div>Name</div>
<div>id</div>
<div>Service Id</div>
<div>Creation Date</div>
<div>Actions</div>
</div>
@ -164,13 +160,22 @@
</c:forEach>
</ul>
</c:if>
</div>
</div>
<!-- END OF CENTER SIDE -->
</div>
</div>
<script>
function success() {
if('${success}' !=='')
UIkit.modal.confirm('${success}');
}
</script>
<c:remove var="success" scope="session"/>
<!-- CONTENT ENDS HERE -->
<c:import url="footer.jsp"/>
</div>
</body>
</html>