Merge branch 'hashPassword' into 'master'

Add password hashing & deploy heroku

See merge request cse1105/2018-2019/oopp-group-43/template!89
This commit is contained in:
Ceren Ugurlu
2019-04-14 16:37:56 +00:00
10 changed files with 85 additions and 35 deletions

View File

@@ -39,8 +39,8 @@ test {
} }
bootJar { bootJar {
baseName = 'gs-consuming-rest' baseName = 'greenify'
version = '0.1.0' version = '1.0.0'
} }
repositories { repositories {
@@ -48,6 +48,7 @@ repositories {
} }
dependencies { dependencies {
compile "org.bouncycastle:bcprov-jdk16:1.46", "org.bouncycastle:bcpg-jdk16:1.46", "org.bouncycastle:bcmail-jdk16:1.46", "org.bouncycastle:bctsp-jdk16:1.46"
compile("org.springframework.boot:spring-boot-starter") compile("org.springframework.boot:spring-boot-starter")
compile("org.springframework:spring-web") compile("org.springframework:spring-web")
compile("com.fasterxml.jackson.core:jackson-databind") compile("com.fasterxml.jackson.core:jackson-databind")

View File

@@ -36,6 +36,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import java.io.IOException; import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@@ -197,7 +198,7 @@ public class RegisterWindowController {
* @param event the click of the sign up button * @param event the click of the sign up button
*/ */
@FXML @FXML
public void handleSignUpButton(ActionEvent event) throws IOException { public void handleSignUpButton(ActionEvent event) throws IOException, NoSuchAlgorithmException {
//set the window to the current window (for displaying the alerts) //set the window to the current window (for displaying the alerts)
Window owner = signUpButton.getScene().getWindow(); Window owner = signUpButton.getScene().getWindow();
//check if the username field is empty //check if the username field is empty

View File

@@ -20,6 +20,7 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import java.io.IOException; import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.Objects; import java.util.Objects;
/** /**
@@ -52,7 +53,8 @@ public class UserController {
* @throws IOException an exception for logging in the user * @throws IOException an exception for logging in the user
*/ */
@FXML @FXML
protected void handleLoginButtonAction(ActionEvent event) throws IOException { protected void handleLoginButtonAction(ActionEvent event)
throws IOException, NoSuchAlgorithmException {
Window owner = loginButton.getScene().getWindow(); //get the current window Window owner = loginButton.getScene().getWindow(); //get the current window
if (usernameField.getText().isEmpty()) { if (usernameField.getText().isEmpty()) {
AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!", AlertHelper.showAlert(Alert.AlertType.ERROR, owner, "Log-in Error!",

View File

@@ -2,6 +2,7 @@ package greenify.client.rest;
import greenify.common.UserDto; import greenify.common.UserDto;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.client.RestTemplateBuilder; import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
@@ -12,6 +13,9 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder; import org.springframework.web.util.UriComponentsBuilder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -19,6 +23,9 @@ import java.util.Map;
public class UserService { public class UserService {
public UserDto currentUser; public UserDto currentUser;
@Value( "${server.address:http://localhost:8080}" )
String serverAddress = "http://localhost:8080";
@Autowired @Autowired
RestTemplate restTemplate; RestTemplate restTemplate;
@@ -36,16 +43,17 @@ public class UserService {
@SuppressWarnings("Duplicates") @SuppressWarnings("Duplicates")
//this suppressWarnings is to get rid of the errors of duplicate code //this suppressWarnings is to get rid of the errors of duplicate code
//because the methods are very similar //because the methods are very similar
public UserDto registerUser(String name, String password) { public UserDto registerUser(String name, String password) throws NoSuchAlgorithmException {
//headers for http //headers for http
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
//set the accept header in JSON value //set the accept header in JSON value
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
//connect to the server with the needed url //connect to the server with the needed url
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/registerUser") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/registerUser")
.queryParam("name", name) .queryParam("name", name)
//getting the name from the database //getting the name from the database
.queryParam("password", password); .queryParam("password", hashPassword(password));
//getting the password from the database //getting the password from the database
//create a http entity to be sent //create a http entity to be sent
@@ -67,13 +75,14 @@ public class UserService {
* @return a userDTO * @return a userDTO
*/ */
@SuppressWarnings("Duplicates") @SuppressWarnings("Duplicates")
public UserDto loginUser(String name, String password) { public UserDto loginUser(String name, String password) throws NoSuchAlgorithmException {
//this method is almost the same as the registerUser one, but with a different link //this method is almost the same as the registerUser one, but with a different link
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/loginUser") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/loginUser")
.queryParam("name", name) .queryParam("name", name)
.queryParam("password", password); .queryParam("password", hashPassword(password));
new HttpEntity<>(headers); new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
UserDto result = this.restTemplate.getForObject(builder.build() UserDto result = this.restTemplate.getForObject(builder.build()
@@ -92,7 +101,7 @@ public class UserService {
public void updateInput(String name, String inputName, String value) { public void updateInput(String name, String inputName, String value) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/setInput") UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(serverAddress + "/setInput")
.queryParam("name", name) .queryParam("name", name)
.queryParam("inputName", inputName) .queryParam("inputName", inputName)
.queryParam("value",value); .queryParam("value",value);
@@ -112,7 +121,8 @@ public class UserService {
public void updateExtraInput(String name, String inputName, String value) { public void updateExtraInput(String name, String inputName, String value) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/setExtraInput") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/setExtraInput")
.queryParam("name", name) .queryParam("name", name)
.queryParam("inputName", inputName) .queryParam("inputName", inputName)
.queryParam("value", value); .queryParam("value", value);
@@ -131,7 +141,8 @@ public class UserService {
public double getFootprint(String name) { public double getFootprint(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getFootprint") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/getFootprint")
.queryParam("name", name); .queryParam("name", name);
new HttpEntity<>(headers); new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
@@ -149,7 +160,7 @@ public class UserService {
public double getFirstFootprint(String name) { public double getFirstFootprint(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getFirst") UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(serverAddress + "/getFirst")
.queryParam("name", name); .queryParam("name", name);
new HttpEntity<>(headers); new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
@@ -168,7 +179,8 @@ public class UserService {
public Float saveFootprint(String name) { public Float saveFootprint(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/saveFootprint") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/saveFootprint")
.queryParam("name", name); .queryParam("name", name);
new HttpEntity<>(headers); new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
@@ -187,7 +199,8 @@ public class UserService {
public Float saveFirstFootprint(String name) { public Float saveFirstFootprint(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/saveFirstFootprint") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/saveFirstFootprint")
.queryParam("name", name); .queryParam("name", name);
new HttpEntity<>(headers); new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
@@ -205,7 +218,8 @@ public class UserService {
public List<String> getFriendNames(String name) { public List<String> getFriendNames(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getFriends") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/getFriends")
.queryParam("name", name); .queryParam("name", name);
new HttpEntity<>(headers); new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
@@ -223,7 +237,8 @@ public class UserService {
public void addFriend(String name, String friend) { public void addFriend(String name, String friend) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/addFriend") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/addFriend")
.queryParam("name", name) .queryParam("name", name)
.queryParam("friend",friend); .queryParam("friend",friend);
HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<?> entity = new HttpEntity<>(headers);
@@ -241,7 +256,8 @@ public class UserService {
public void removeFriend(String name, String friend) { public void removeFriend(String name, String friend) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/removeFriend") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/removeFriend")
.queryParam("name", name) .queryParam("name", name)
.queryParam("friend",friend); .queryParam("friend",friend);
HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<?> entity = new HttpEntity<>(headers);
@@ -258,7 +274,8 @@ public class UserService {
public Map<String, String> getInputs(String name) { public Map<String, String> getInputs(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getInputs") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/getInputs")
.queryParam("name", name); .queryParam("name", name);
HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<?> entity = new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
@@ -275,7 +292,8 @@ public class UserService {
public Map<String, String> getExtraInputs(String name) { public Map<String, String> getExtraInputs(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getExtraInputs") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/getExtraInputs")
.queryParam("name", name); .queryParam("name", name);
HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<?> entity = new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
@@ -293,7 +311,8 @@ public class UserService {
public Map getAchievements(String name) { public Map getAchievements(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getAchievements") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/getAchievements")
.queryParam("name", name); .queryParam("name", name);
HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<?> entity = new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
@@ -310,7 +329,8 @@ public class UserService {
public Map<String, String> getResults(String name) { public Map<String, String> getResults(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getResults") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/getResults")
.queryParam("name", name); .queryParam("name", name);
HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<?> entity = new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
@@ -325,7 +345,8 @@ public class UserService {
public List<String> getAllUsers() { public List<String> getAllUsers() {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/getAllUsers"); UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/getAllUsers");
HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<?> entity = new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
List<String> result = this.restTemplate.getForObject(builder List<String> result = this.restTemplate.getForObject(builder
@@ -341,11 +362,27 @@ public class UserService {
public void deleteAccount(String name) { public void deleteAccount(String name) {
HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("http://localhost:8080/deleteAccount") UriComponentsBuilder builder = UriComponentsBuilder
.fromHttpUrl(serverAddress + "/deleteAccount")
.queryParam("name", name); .queryParam("name", name);
HttpEntity<?> entity = new HttpEntity<>(headers); HttpEntity<?> entity = new HttpEntity<>(headers);
System.out.println(builder.build().encode().toUri()); System.out.println(builder.build().encode().toUri());
ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build() ResponseEntity<String> authenticateResponse = this.restTemplate.getForEntity(builder.build()
.encode().toUri(), String.class); .encode().toUri(), String.class);
} }
public String hashPassword(String password)
throws NoSuchAlgorithmException {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] encodedHash = digest.digest(password.getBytes(StandardCharsets.UTF_8));
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < encodedHash.length; i++) {
String hex = Integer.toHexString(0xff & encodedHash[i]);
if (hex.length() == 1) {
hexString.append('0');
}
hexString.append(hex);
}
return hexString.toString();
}
} }

View File

@@ -614,12 +614,12 @@
</ImageView> </ImageView>
</graphic> </graphic>
</Button> </Button>
<Button fx:id="removeFriend" contentDisplay="RIGHT" layoutX="575.0" layoutY="150.0" mnemonicParsing="false" onAction="#openRemoveFriend" prefHeight="74.0" prefWidth="200.0" style="-fx-border-radius: 20px; -fx-padding: 0px 0px 0px 0px; -fx-background-color: transparent;" text="Remove friend" textFill="#29721a"> <Button fx:id="removeFriend" contentDisplay="RIGHT" layoutX="560.0" layoutY="150.0" mnemonicParsing="false" onAction="#openRemoveFriend" prefHeight="74.0" prefWidth="200.0" style="-fx-border-radius: 20px; -fx-padding: 0px 0px 0px 0px; -fx-background-color: transparent;" text="Remove friend" textFill="#29721a">
<font> <font>
<Font name="Corbel Bold" size="14.0" /> <Font name="Corbel Bold" size="14.0" />
</font> </font>
<graphic> <graphic>
<ImageView fitHeight="74.0" fitWidth="64.0" pickOnBounds="true" preserveRatio="true"> <ImageView fitHeight="70.0" fitWidth="60.0" pickOnBounds="true" preserveRatio="true">
<image> <image>
<Image url="@../icons/remove_friend.png" /> <Image url="@../icons/remove_friend.png" />
</image> </image>

View File

@@ -30,7 +30,7 @@ public class UserServiceTest {
@Test @Test
public void userRegisterTest() throws Exception { public void userRegisterTest() throws Exception {
UserDto testUser = new UserDto(1L, "Eric"); UserDto testUser = new UserDto(1L, "Eric");
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/registerUser?name=Eric&password=password"), Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/registerUser?name=Eric&password=5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"),
UserDto.class)) UserDto.class))
.thenReturn(testUser); .thenReturn(testUser);
@@ -41,7 +41,7 @@ public class UserServiceTest {
@Test @Test
public void userLoginTest() throws Exception { public void userLoginTest() throws Exception {
UserDto testUser = new UserDto(1L, "Eric"); UserDto testUser = new UserDto(1L, "Eric");
Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/loginUser?name=Eric&password=password"), Mockito.when(restTemplate.getForObject(new java.net.URI("http://localhost:8080/loginUser?name=Eric&password=5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"),
UserDto.class)) UserDto.class))
.thenReturn(testUser); .thenReturn(testUser);
UserDto user = userService.loginUser("Eric", "password"); UserDto user = userService.loginUser("Eric", "password");

View File

@@ -7,6 +7,19 @@ buildscript {
} }
} }
plugins {
id "com.heroku.sdk.heroku-gradle" version "1.0.4"
}
heroku {
appName = "greenify43"
includes = ["${buildDir}/libs/greenify-server-1.0.0.jar"]
includeBuildDir = false
processTypes(
web: "java -Dserver.port=\$PORT -jar src/Server/build/libs/greenify-server-1.0.0.jar"
)
}
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'idea' apply plugin: 'idea'
@@ -16,8 +29,8 @@ apply plugin: 'jacoco'
apply plugin: 'checkstyle' apply plugin: 'checkstyle'
bootJar { bootJar {
baseName = 'gs-rest-service' baseName = 'greenify-server'
version = '0.1.0' version = '1.0.0'
} }
test { test {

View File

@@ -209,7 +209,6 @@ public class User {
throw new ApplicationException("Cannot add yourself as a friend"); throw new ApplicationException("Cannot add yourself as a friend");
} else { } else {
friends.add(user); friends.add(user);
System.out.print("Friend added!");
} }
} }
@@ -222,7 +221,6 @@ public class User {
throw new ApplicationException("This user is not your friend!"); throw new ApplicationException("This user is not your friend!");
} else { } else {
friends.remove(user); friends.remove(user);
System.out.print("Friend removed");
} }
} }

View File

@@ -114,7 +114,6 @@ public class UserController {
*/ */
@RequestMapping("/getFirst") @RequestMapping("/getFirst")
public Float getFirstFootprint(@RequestParam(value = "name") String name) { public Float getFirstFootprint(@RequestParam(value = "name") String name) {
System.out.println("hello");
Float footprint = userService.getFirstFootprint(name); Float footprint = userService.getFirstFootprint(name);
return footprint; return footprint;
} }

View File

@@ -63,7 +63,6 @@ public class CalculatorService {
.indexOf("<result_grand_total>") .indexOf("<result_grand_total>")
+ 20, response.getBody().indexOf("</result_grand_total>")); + 20, response.getBody().indexOf("</result_grand_total>"));
// to do: in not HTTP 200 or exception case throws exception // to do: in not HTTP 200 or exception case throws exception
System.out.println(Float.parseFloat(result));
return Float.parseFloat(result); return Float.parseFloat(result);
} }