Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
b6b27db
Change of layout
Mar 13, 2017
8dc1384
Modified some tests + Added empty methods to signup validate
alexandersokolov Mar 15, 2017
77000ef
Remove login components on login, and display username
Mar 15, 2017
a15a93d
Merge branch 'SignUp' of https://github.com/mnosoudi/dominus.git into…
Mar 15, 2017
38307c2
Wrote email and password methods to enforce format rules.
adamwoodland Mar 15, 2017
2e5278f
Merge branch 'SignUp' of https://github.com/mnosoudi/dominus.git into…
adamwoodland Mar 15, 2017
0b39e99
Added logic for two methods that validate the signup
alexandersokolov Mar 15, 2017
33df1d2
fixed the authorizer logic
Mar 15, 2017
18718f3
Merge branch 'SignUp' of https://github.com/mnosoudi/dominus.git into…
Mar 15, 2017
d91dc42
Centered the vertical layout in MainLayout
Mar 15, 2017
ddec775
designer css file
Mar 15, 2017
2480528
Merge pull request #4 from mnosoudi/SignUp
rdpi Mar 17, 2017
f277dc4
Fixed the layout of the sign up form
Mar 17, 2017
20eb765
Fixed the layout of the sign up page: Cassie + Ryan
Mar 18, 2017
32a3a76
Moved UI logic (notifications) from Authorizer into MainLayout
Mar 18, 2017
c637528
Merge branch 'SignUp' of https://github.com/mnosoudi/dominus.git into…
Mar 18, 2017
129c97a
Merge pull request #5 from mnosoudi/SignUp
rdpi Mar 18, 2017
ded65cb
Added upload button on signup view; pair programming: Kelvin
Mar 19, 2017
c0ba05a
Connected the Sign-up form validation logic with the UI
alexandersokolov Mar 19, 2017
cdc6997
Merge remote-tracking branch 'origin/VerifyLandlord' into VerifyLandlord
alexandersokolov Mar 19, 2017
7fbf125
Delete .classpath
rdpi Mar 19, 2017
9d2eb74
Delete .project
rdpi Mar 19, 2017
5478035
Started writing TestBench class. Pair programming: Adam Woodland &
adamwoodland Mar 19, 2017
9644de8
Testbench commit 2. Pair programming by Armani & Rami
Mar 19, 2017
5447311
Mainlayout - Changed the login button style(bacground-color)
Mar 20, 2017
d624132
Using ChromeDriver for TestBench class. Pair programming: Adam Woodland
adamwoodland Mar 20, 2017
6c18c3e
Merge branch 'VerifyLandlord' of https://github.com/mnosoudi/dominus.…
adamwoodland Mar 20, 2017
8076a43
Using ChromeDriver for TestBench. Pair programming: Adam Woodland &
adamwoodland Mar 20, 2017
0b34f78
SignUpViewTest - added two tests for Validating Landlord
Mar 20, 2017
58e44b5
Added four tests in TestBench. Pair programming: Adam Woodland & Alex
adamwoodland Mar 20, 2017
d768304
Merge branch 'VerifyLandlord' of https://github.com/mnosoudi/dominus.…
adamwoodland Mar 20, 2017
38be4a8
Modified travis.yml
adamwoodland Mar 22, 2017
797a6ff
created a login view page
Kelvin-Mich Mar 26, 2017
dc94c58
Added a Login View and form
Kelvin-Mich Mar 26, 2017
bb058e9
Changed the Authorizer class to login successfully on the new UI
Kelvin-Mich Apr 2, 2017
7efa5fe
Created tests for UI interaction. Adam Woodland & Armani Nosoudi
adamwoodland Apr 6, 2017
a25297c
Changed Landlord Registration TextField - Adam & Cassie
adamwoodland Apr 6, 2017
071ac3b
Added MySQL connector
adamwoodland Apr 7, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
language: java
before_install: "./.travis.before_install.sh"
script: "./.travis.script.sh"
install:
- mvn install
jdk:
Expand All @@ -10,4 +12,4 @@ deploy:
app: dominus-app
on:
repo: mnosoudi/dominus
branch: searchbar_background
branch: VerifyLandlord
8 changes: 8 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,14 @@
<artifactId>easymock</artifactId>
<version>3.4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>



</dependencies>

Expand Down
106 changes: 41 additions & 65 deletions src/main/java/com/dominus/dominus/Authorizer.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.dominus.dominus;

import java.util.Base64;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import javax.crypto.SecretKey;
Expand Down Expand Up @@ -29,83 +28,60 @@ public boolean authorize(String username, String password) throws NoSuchAlgorith
Pattern pattern = Pattern.compile("\\b[a-zA-Z][a-zA-Z0-9\\-._]{7,}\\b");
Matcher unamematcher = pattern.matcher(username);
Matcher pwdmatcher = pattern.matcher(password);
boolean success = false;

//Displays success message if there are no errors
try
{
if(!unamematcher.find() || !pwdmatcher.find()){
throw new InvalidInputException();
if(unamematcher.matches() && pwdmatcher.matches()){
String hashedpass;
hashedpass = hashIt(password);
if(login(username, hashedpass))
VaadinSession.getCurrent().setAttribute("user", username);
success = true;
}
//hash password
//check username and hashed password against database
//if they match, login (bool?)
String hashedpass;
hashedpass = hashIt(password);
login(username, hashedpass);
//Returns true if login is good
return true;

}
catch(InvalidInputException ex)
{
loginError("Invalid username or password");
//Returns false if there was an error
return false;
}



else
success = false;
return success;
}

//displays error message when invalid input is entered
public void loginError(String errorMessage)
{
Notification notif = new Notification(
"Login Error",
errorMessage,
Notification.Type.ERROR_MESSAGE);
notif.setDelayMsec(2000);
//position message in the top left corner
notif.setPosition(Position.TOP_LEFT);
notif.show(Page.getCurrent());
}



//password hasher method
public String hashIt(String b) throws NoSuchAlgorithmException{
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
//one-way encryption for database
messageDigest.update(b.getBytes());
String encryptedString = new String(messageDigest.digest());
return encryptedString;
}
public String hashIt(String password)
{
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(password.getBytes());
byte[] bytes = md.digest();
//convert string to hex
StringBuilder sb = new StringBuilder();
for(int i=0; i< bytes.length ;i++)
{
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
}
return sb.toString();
}
catch (NoSuchAlgorithmException e)
{
return null;
}
}





public void login(String username, String password)
public boolean login(String username, String password)
{
//dummy database
try {
String hashedpass = hashIt("test12345");
if(username.equals("username123") && password.equals(hashedpass)){
VaadinSession.getCurrent().setAttribute("user", username);
Notification notif = new Notification(
"Login",
"Login was Successful",
Notification.Type.HUMANIZED_MESSAGE);
notif.setDelayMsec(2000);
notif.setPosition(Position.TOP_LEFT);
notif.show(Page.getCurrent());
}
else
loginError("Username and Password do not match");
}
catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}

String hashedpass = hashIt("test12345");
if(username.equals("username123") && password.equals(hashedpass))
return true;
else
return false;
}

public void logout(){
VaadinSession.getCurrent().setAttribute("user", null);
}
}

73 changes: 73 additions & 0 deletions src/main/java/com/dominus/dominus/LoginView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
*
*/
package com.dominus.dominus;

import java.security.NoSuchAlgorithmException;

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener.ViewChangeEvent;
import com.vaadin.server.VaadinSession;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;

/**
* @author Kelvin
*
*/
public class LoginView extends LoginViewDesign implements View {

/**
*
*/
public static final String VIEW_NAME = "login";

MainLayout jMain = new MainLayout();


public LoginView(){

btnLogin.addClickListener(new Button.ClickListener() {

Authorizer authorize = new Authorizer();

@Override
public void buttonClick(Button.ClickEvent event) {
// TODO Auto-generated method stub
try {
if(authorize.authorize(userName.getValue(), password.getValue())){
//login successful
getUI().getNavigator().navigateTo("search");
Notification.show("Login Successful", Notification.Type.HUMANIZED_MESSAGE);
//reset UI Components
userName.setValue("");
password.setValue("");
} else{
Notification.show("Incorrect Login Details!!!", Notification.Type.ERROR_MESSAGE);
}
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
});


btnSignup.addClickListener(new Button.ClickListener() {

@Override
public void buttonClick(Button.ClickEvent event) {
// TODO Auto-generated method stub
getUI().getNavigator().navigateTo("signup");
}
});
}
@Override
public void enter(ViewChangeEvent event) {
// TODO Auto-generated method stub

}
}
37 changes: 37 additions & 0 deletions src/main/java/com/dominus/dominus/LoginViewDesign.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package com.dominus.dominus;

import com.vaadin.annotations.AutoGenerated;
import com.vaadin.annotations.DesignRoot;
import com.vaadin.ui.Button;
import com.vaadin.ui.FormLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.Panel;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.declarative.Design;

/**
* !! DO NOT EDIT THIS FILE !!
*
* This class is generated by Vaadin Designer and will be overwritten.
*
* Please make a subclass with logic and additional interfaces as needed,
* e.g class LoginView extends LoginDesign implements View { }
*/
@DesignRoot
@AutoGenerated
@SuppressWarnings("serial")
public class LoginViewDesign extends VerticalLayout {
protected Panel loginPanel;
protected FormLayout formLayout;
protected TextField userName;
protected PasswordField password;
protected HorizontalLayout hLayout;
protected Button btnLogin;
protected Button btnSignup;

public LoginViewDesign() {
Design.read(this);
}
}
98 changes: 73 additions & 25 deletions src/main/java/com/dominus/dominus/MainLayout.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@
import com.vaadin.navigator.Navigator;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewDisplay;
import com.vaadin.server.Page;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinSession;
import com.vaadin.shared.Position;
import com.vaadin.ui.Button;
import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.Notification;
import com.vaadin.ui.PasswordField;
import com.vaadin.ui.UI;

Expand All @@ -25,36 +30,54 @@ public MainLayout() {
navigator = new Navigator(UI.getCurrent(), (ViewDisplay) this);
addNavigatorView(SearchView.VIEW_NAME, SearchView.class, search);
addNavigatorView(SignUpView.VIEW_NAME, SignUpView.class, signup);
addNavigatorView(LoginView.VIEW_NAME, LoginView.class, login);
if (navigator.getState().isEmpty()) {
navigator.navigateTo(SearchView.VIEW_NAME);
}

Authorizer authorizer = new Authorizer();
final PasswordField tmpPassword = new PasswordField();
password.addFocusListener(new FocusListener() {
public void focus (FieldEvents.FocusEvent event) {
menu.replaceComponent(password, tmpPassword);
tmpPassword.focus();
}
});

tmpPassword.addBlurListener(new BlurListener () {
public void blur (FieldEvents.BlurEvent event) {
password.setValue(tmpPassword.getValue());
if (password.getValue().isEmpty()) {
menu.replaceComponent(tmpPassword, password);
}
}
});

login.addClickListener(event -> {
try {
authorizer.authorize(username.getValue(), password.getValue());
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
});

// Authorizer authorizer = new Authorizer();
// final PasswordField tmpPassword = new PasswordField();
// password.addFocusListener(new FocusListener() {
// public void focus (FieldEvents.FocusEvent event) {
// menu.replaceComponent(password, tmpPassword);
// tmpPassword.focus();
// }
// });
//
// tmpPassword.addBlurListener(new BlurListener () {
// public void blur (FieldEvents.BlurEvent event) {
// password.setValue(tmpPassword.getValue());
// if (password.getValue().isEmpty()) {
// menu.replaceComponent(tmpPassword, password);
// }
// }
// });

Button logout = new Button("Logout");
//login.addStyleName("friendly");

// login.addClickListener(event -> {
// try {
// if(authorizer.authorize(username.getValue(), password.getValue())){
// loginSuccess();
// menu.removeComponent(signup);
// menu.removeComponent(username);
// menu.removeComponent(password);
// menu.removeComponent(login);
// menu.removeComponent(tmpPassword);
// Label label = new Label("Signed in as " + (String) VaadinSession.getCurrent().getAttribute("user"));
// menu.addComponent(label);
// menu.addComponent(logout);
// }
// else
// loginError();
// } catch (NoSuchAlgorithmException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// });
}

private void doNavigate(String viewName) {
Expand Down Expand Up @@ -90,4 +113,29 @@ public void showView(View view) {
throw new IllegalArgumentException("View is not a Component");
}
}

//displays error message when invalid input is entered
public void loginError()
{
Notification notif = new Notification(
"Login Error",
"Wrong username or password",
Notification.Type.ERROR_MESSAGE);
notif.setDelayMsec(2000);
//position message in the top left corner
notif.setPosition(Position.TOP_LEFT);
notif.show(Page.getCurrent());
}

public void loginSuccess()
{
Notification notif = new Notification(
"Login",
"Login was Successful",
Notification.Type.HUMANIZED_MESSAGE);
notif.setDelayMsec(2000);
notif.setPosition(Position.TOP_LEFT);
notif.show(Page.getCurrent());
}

}
Loading