Question: I need help with fixing my 10 errors from ServerApplication.java file. I bolded the code that I put in. ----------------------------------------------------------------------------------------------- ServerApplication.java ----------------------------------------------------------------------------------------------- package com.snhu.sslserver; import

I need help with fixing my 10 errors from ServerApplication.java file.

I bolded the code that I put in.

-----------------------------------------------------------------------------------------------

ServerApplication.java

-----------------------------------------------------------------------------------------------

package com.snhu.sslserver;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

@SpringBootApplication

public class ServerApplication {

public static void main(String[] args) {

SpringApplication.run(ServerApplication.class, args);

}

}

@RestController

class ServerController{

//FIXME: Add hash function to return the checksum value for the data string that should contain your name.

@RequestMapping("/hash")

public String myHash(){

String data = "Hello Joe Smith!";

String[] splitname = data.split("");

String firstname = splitname [0];

String lastname = splitname[splitname.length - 1 ];

String name = firstname+" "+lastname;

MessageDigest md = MessageDigest.getInstance("SHA-256");

byte[] sha256 = md.digest(name.getBytes(StandardCharsets.UTF_8));

return bytesToHex (sha256);

public String bytesToHex(byte[] sha256){

BigInteger hex = new BigInteger(1, sha256);

StringBuilder checksum = new StringBuilder(hex.toString(16));

while (checksum.length()

checksum.insert(0, '0');

}

return checksum.toString();

}

return "

data:"+data;

}

}

-----------------------------------------------------------------------------------------------

ServerApplicationTests.java

-----------------------------------------------------------------------------------------------

package com.snhu.server;

import org.junit.jupiter.api.Test;

import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest

class ServerApplicationTests {

@Test

void contextLoads() {

}

}

-----------------------------------------------------------------------------------------------

pom.xml

-----------------------------------------------------------------------------------------------

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

org.springframework.boot

spring-boot-starter-parent

2.2.4.RELEASE

com.snhu

ssl-server

0.0.1-SNAPSHOT

ssl-server

ssl-server skeleton for CS-305

1.8

org.springframework.boot

spring-boot-starter-data-rest

org.springframework.boot

spring-boot-starter-web

org.springframework.boot

spring-boot-starter-test

test

org.junit.vintage

junit-vintage-engine

org.springframework.boot

spring-boot-maven-plugin

I need help with fixing my 10 errors from ServerApplication.java file. I

bolded the code that I put in. ----------------------------------------------------------------------------------------------- ServerApplication.java ----------------------------------------------------------------------------------------------- package com.snhu.sslserver;

import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @SpringBootApplication public class ServerApplication

{ public static void main(String[] args) { SpringApplication.run(ServerApplication.class, args); } } @RestController

D A *Server Application.java X ServerApplication Tests.java 1 package com.snhu.sslserver; 2 # Package Explorer X BE 8 module5 skel_student src/main/java t com.snhu.sslserver Server Application.java src/main/resources static templates application.properties keystore keystore.p12 src/test/java # com.snhu.server > Server Application Tests.java > JRE System Library [JavaSE-1.8] > Maven Dependencies src main test target W HELP.md e mynw Comvnw.cmd M pom.xml 36 import org.springframework.boot.SpringApplication;0) 7 8 9 @SpringBootApplication 10 public class Server Application { 11 120 public static void main(String[] args) { 13 SpringApplication.run(Server Application.class, args); 14 } 15 16} 17 18 @RestController 19 class ServerController{ 220 //FIXME: Add hash function to return the checksum value for the data string that should contain your name. 21 @RequestMapping("/hash") 22 23 public String myHash() { 24 String data = "Hello Joe Smith!"; String[] splitname = data.split(""); String firstname = splitname [0]; String lastname = splitname [splitname.length - 1 ]; 28 String name = firstname+" "+lastname; x29 MessageDigest md = MessageDigest.getInstance("SHA-256"); 30 byte[] sha256 = md. digest(name.getBytes(Standardcharsets. UTF_8)); 431 return bytes To Hex (sha256); 32 X 33 public String bytesToHex(byte[] sha256.){ BigInteger hex = new BigInteger(1, sha256); 35 StringBuilder checksum = new StringBuilder (hex.toString(16)); 36 while (checksum.length() data:"+data; 42 } 43} 25 26 27 234 Problems x @ Javadoc Declaration 10 errors, 2 warnings, O others Description Resource Path Location Type v Errors (10 items) The method bytes To Hex(byte[]) is undefined for the type ServerController Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 31 Java Problem Syntax error on token ")".; expected Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 33 Java Problem Syntax error on token "C",; expected Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 33 Java Problem S Standard Charsets cannot be resolved to a variable Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 30 Java Problem MessageDigest cannot be resolved to a type Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 29 Java Problem x MessageDigest cannot be resolved ServerApplication.java /module5_skel_student/src/main/java/com/snhu/sslserver line 29 Java Problem * Illegal modifier for parameter bytes To Hex; only final is permitted Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 33 Java Problem Duplicate local variable sha256 Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 33 Java Problem BigInteger cannot be resolved to a type ServerApplication.java /module5_skel_student/src/main/java/com/snhu/sslserver line 34 Java Problem to BigInteger cannot be resolved to a type Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 34 Java Problem > Warnings (2 items) Server Application.java ServerApplication Tests.java X 1 package com.snhu.server; 2 36 import org.junit.jupiter.api. Test;0 5 6 @SpringBootTest 7 class Server ApplicationTests { 90 19 11 12 13 } 14 @Test void contextLoads() { } Package Explorer X BE 8 v module5_skel_student src/main/java com.snhu.sslserver Server Application.java vsrc/main/resources static templates application.properties keystore keystore.p12 src/test/java com.snhu.server > Server Application Tests.java > JRE System Library [JavaSE-1.8] > Maven Dependencies src main test B target W HELP.md mynw mynw.cmd M pom.xml 02 Problems x @ Javadoc Declaration 10 errors, 2 warnings, 0 others Description Resource Path Location Type v Errors (10 items) The method bytes To Hex(byte[]) is undefined for the type Server Controller Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 31 Java Problem Syntax error on token")".; expected Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 33 Java Problem Syntax error on token "C",; expected Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 33 Java Problem E Standard Charsets cannot be resolved to a variable Server Application.java/module5_skel_student/src/main/java/com/snhu/sslserver line 30 Java Problem MessageDigest cannot be resolved to a type Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 29 Java Problem MessageDigest cannot be resolved Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 29 Java Problem Illegal modifier for parameter bytes To Hex; only final is permitted ServerApplication.java /module5_skel_student/src/main/java/com/snhu/ssiserver line 33 Java Problem Duplicate local variable sha256 Server Application.java /module5_skel_student/src/main/java/com/shu/sslserver line 33 Java Problem BigInteger cannot be resolved to a type Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 34 Java Problem BigInteger cannot be resolved to a type Server Application.java /module5_skel_student/src/main/java/com/snhu/sslserver line 34 Java Problem > Warnings (2 items) Overview The cryptographic hash function has great utility for sharing information. In a commercial environment where the organization needs to distribute programs or documentation to customers, the organization can use the hash value to ensure the customer receives unaltered information. The common term for producing a hash value for a data file is a checksum. Producing a checksum for files that customers will download allows your customers to check for transmission errors and prevents an attacker from disguising a malicious file as your original file. To do this, you will need to produce a cryptographic hash function that is not susceptible to collisions. For example, certain older algorithm ciphers have been found to be "hackable"; that is, a hacker can produce a checksum for a malicious version of a file that equates to the same checksum as the original file. In this assignment, you will need to research options to find and produce a cryptographic hash function that will not be susceptible to collisions. Specifically, you will deploy an appropriate algorithm cipher to encrypt and produce a checksum verification in order to increase the layers of security for a software application. Prompt A business you are working with has a public key that they are hoping to distribute to clients. Their clients want to download the public key from a website and verify the key with a checksum. To accomplish this, you will need to code a simple string checksum verification program. In addition, you will need to document your process by completing the provided template. Algorithm Cipher: Review the scenario and the Java Security Standard Algorithm Names, which is a standard list of algorithm ciphers provided by Oracle. Recommend an appropriate encryption algorithm cipher that avoids collisions. Document your recommendation in the template provided. Justification: Justify your reasoning for the recommended algorithm cipher by providing a brief, high-level overview of the encryption algorithm cipher. Consider what it means to avoid collisions. Why is this important? Document your recommendation in the template provided. Generate Checksum: Refactor the code to encrypt a text string and generate a checksum verification. First, download the code base and upload it to Eclipse as a new project. Refactor the code to add your first and last name as a unique data string. You will submit your refactored code for your instructor to review. Then generate the checksum by following these steps: 1. Create an object of Message Digest class using the java.security.Message Digest library. 2. Initialize the object with your selection for an appropriate algorithm cipher. 3. Use the digest() method of the class to generate a hash value of byte type from the unique data string (your first and last name). 4. Convert the hash value to hex using the bytesToHex function. 5. Create a RESTFul route using the @RequestMapping method to generate and return the required information, which includes the hash value, to the web browser. Verification: Demonstrate that a hash value has been created for the unique text string (your first and last name) by executing the Java code. Then use your web browser to connect to the RESTful API server. This should show your first and last name as the unique data string in the browser, the name of the algorithm cipher you used, and the checksum hash value. Capture a screenshot of the web browser with your unique information and add it to the template provided. An example of the expected output is shown below: localhost:844hash --> CW Of httos/localhost 8443anh data:This is Your First and Last Name Nante of Cipher Algorithun Used Check Sun Value:3011724b684510085525786837e3ee772bee1a911302080393e9bdelegats

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!