Skip to content

Commit

Permalink
Login page added to the fdp metadata level
Browse files Browse the repository at this point in the history
  • Loading branch information
rkaliyaperumal committed Feb 20, 2017
1 parent 8a74f66 commit 5d4abbc
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ public void addResourceHandlers(final ResourceHandlerRegistry registry) {
registry.setOrder(Integer.MIN_VALUE + 2).
addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");

registry.setOrder(Integer.MIN_VALUE + 3).
addResourceHandler("/resources/**")
.addResourceLocations("/WEB-INF/static/");
}

@Override
Expand Down
67 changes: 67 additions & 0 deletions src/main/java/nl/dtls/fairdatapoint/api/controller/Login.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* The MIT License
* Copyright © 2017 DTL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package nl.dtls.fairdatapoint.api.controller;

/**
*
* @author Rajaram Kaliyaperumal <rr.kaliyaperumal@gmail.com>
*/
public class Login {

private String userName;
private String password;

/**
* @return the userName
*/
public String getUserName() {
return userName;
}

/**
* @param userName the userName to set
*/
public void setUserName(String userName) {
this.userName = userName;
}

/**
* @return the password
*/
public String getPassword() {
return password;
}

/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import nl.dtls.fairdatapoint.service.FairMetadataServiceException;
import org.eclipse.rdf4j.rio.RDFFormat;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.ModelAttribute;
import springfox.documentation.annotations.ApiIgnore;

/**
Expand Down Expand Up @@ -131,9 +132,27 @@ public FDPMetadata getFDPMetaData(final HttpServletRequest request,
@ApiIgnore
@RequestMapping(method = RequestMethod.GET,
produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView getHtmlFdpMetadata(HttpServletRequest request) throws
public ModelAndView getLoginFdpMetadata(HttpServletRequest request) throws
FairMetadataServiceException, ResourceNotFoundException,
MetadataException {
ModelAndView mav = new ModelAndView("login");
mav.addObject("error", null);
return mav;
}

@ApiIgnore
@RequestMapping(method = RequestMethod.POST,
produces = MediaType.TEXT_HTML_VALUE)
public ModelAndView getHtmlFdpMetadata(HttpServletRequest request,
@ModelAttribute("login") Login login) throws
FairMetadataServiceException, ResourceNotFoundException,
MetadataException {
if(!login.getUserName().equalsIgnoreCase("admin") ||
!login.getPassword().equalsIgnoreCase("admin")) {
ModelAndView mav = new ModelAndView("login");
mav.addObject("error", "Invalid username or password");
return mav;
}
ModelAndView mav = new ModelAndView("repository");
LOGGER.info("Request to get FDP metadata");
LOGGER.info("GET : " + request.getRequestURL());
Expand Down
73 changes: 73 additions & 0 deletions src/main/webapp/WEB-INF/static/css/login.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* The MIT License
* Copyright © 2017 DTL
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
@import "bourbon";

body {
background: #eee !important;
}

.wrapper {
margin-top: 80px;
margin-bottom: 80px;
}

.form-signin {
max-width: 380px;
padding: 15px 35px 45px;
margin: 0 auto;
background-color: #fff;
border: 1px solid rgba(0,0,0,0.1);

.form-signin-heading,
.checkbox {
margin-bottom: 30px;
}

.checkbox {
font-weight: normal;
}

.form-control {
position: relative;
font-size: 16px;
height: auto;
padding: 10px;
@include box-sizing(border-box);

&:focus {
z-index: 2;
}
}

input[type="text"] {
margin-bottom: -1px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}

input[type="password"] {
margin-bottom: 20px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
}
33 changes: 33 additions & 0 deletions src/main/webapp/WEB-INF/templates/login.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Login -->
<link rel="stylesheet" href="fdp/resources/css/login.css" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous">
</script>
<title>Login</title>
</head>
<body>
<div class="wrapper">
<form class="form-signin" method="POST">
<h2 class="form-signin-heading">Please login</h2>
<input type="text" class="form-control" name="userName" placeholder="Username" required="" autofocus="" />
<input type="password" class="form-control" name="password" placeholder="Password" required=""/>
<button class="btn btn-lg btn-primary btn-block" type="submit" value="/">Login</button>
{{#if error}}
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Error: </span>
{{error}}
</div>
{{/if}}
</form>
</div>
</body>
</html>

0 comments on commit 5d4abbc

Please sign in to comment.