From c8330cec5337070ebcd9c5290d639222fcbe00ab Mon Sep 17 00:00:00 2001 From: sunilsinghc11 Date: Fri, 13 Sep 2024 09:52:09 -0400 Subject: [PATCH] Initial Clean Commit --- .github/workflows/build-maven.yml | 4 +- pom.xml-ORIG | 131 ------------------ .../java/org/yann/demo/DemoApplication.java | 44 ------ .../main/java/org/yann/demo/Greeting.java | 4 - .../java/org/yann/demo/SecurityConfig.java | 113 --------------- .../demo/controller/GreetingController.java | 21 --- .../yann/demo/controller/HomeController.java | 14 -- .../yann/demo/controller/LoginController.java | 37 ----- .../demo/controller/UploadController.java | 44 ------ .../yann/demo/controller/UserController.java | 44 ------ .../java/org/yann/demo/error/ApiError.java | 52 ------- .../yann/demo/error/RestExceptionHandler.java | 31 ----- .../java/org/yann/demo/model/Gallery.java | 8 -- .../main/java/org/yann/demo/model/Image.java | 20 --- .../main/java/org/yann/demo/model/User.java | 75 ---------- .../yann/demo/repository/UserRepository.java | 11 -- .../security/MyDaoAuthenticationProvider.java | 15 -- .../org/yann/demo/security/MyUserDetails.java | 57 -------- .../demo/security/MyUserDetailsService.java | 34 ----- .../demo/service/FileStorageServiceImpl.java | 54 -------- .../org/yann/demo/service/ImageService.java | 25 ---- .../org/yann/demo/service/UserService.java | 37 ----- .../main/resources/application.properties | 16 --- src-ORIG/main/resources/credentials.txt | 3 - src-ORIG/main/resources/sql/data.sql | 5 - src-ORIG/main/resources/sql/schema.sql | 8 -- .../resources/templates/fragments/footer.html | 11 -- .../resources/templates/fragments/header.html | 23 --- .../main/resources/templates/homepage.html | 24 ---- src-ORIG/main/resources/templates/img.html | 8 -- .../main/resources/templates/uploadform.html | 20 --- src-ORIG/main/resources/templates/user.html | 34 ----- .../org/yann/demo/DemoApplicationTests.java | 13 -- 33 files changed, 2 insertions(+), 1038 deletions(-) delete mode 100644 pom.xml-ORIG delete mode 100644 src-ORIG/main/java/org/yann/demo/DemoApplication.java delete mode 100644 src-ORIG/main/java/org/yann/demo/Greeting.java delete mode 100644 src-ORIG/main/java/org/yann/demo/SecurityConfig.java delete mode 100644 src-ORIG/main/java/org/yann/demo/controller/GreetingController.java delete mode 100644 src-ORIG/main/java/org/yann/demo/controller/HomeController.java delete mode 100644 src-ORIG/main/java/org/yann/demo/controller/LoginController.java delete mode 100644 src-ORIG/main/java/org/yann/demo/controller/UploadController.java delete mode 100644 src-ORIG/main/java/org/yann/demo/controller/UserController.java delete mode 100644 src-ORIG/main/java/org/yann/demo/error/ApiError.java delete mode 100644 src-ORIG/main/java/org/yann/demo/error/RestExceptionHandler.java delete mode 100644 src-ORIG/main/java/org/yann/demo/model/Gallery.java delete mode 100644 src-ORIG/main/java/org/yann/demo/model/Image.java delete mode 100644 src-ORIG/main/java/org/yann/demo/model/User.java delete mode 100644 src-ORIG/main/java/org/yann/demo/repository/UserRepository.java delete mode 100644 src-ORIG/main/java/org/yann/demo/security/MyDaoAuthenticationProvider.java delete mode 100644 src-ORIG/main/java/org/yann/demo/security/MyUserDetails.java delete mode 100644 src-ORIG/main/java/org/yann/demo/security/MyUserDetailsService.java delete mode 100644 src-ORIG/main/java/org/yann/demo/service/FileStorageServiceImpl.java delete mode 100644 src-ORIG/main/java/org/yann/demo/service/ImageService.java delete mode 100644 src-ORIG/main/java/org/yann/demo/service/UserService.java delete mode 100644 src-ORIG/main/resources/application.properties delete mode 100644 src-ORIG/main/resources/credentials.txt delete mode 100644 src-ORIG/main/resources/sql/data.sql delete mode 100644 src-ORIG/main/resources/sql/schema.sql delete mode 100644 src-ORIG/main/resources/templates/fragments/footer.html delete mode 100644 src-ORIG/main/resources/templates/fragments/header.html delete mode 100644 src-ORIG/main/resources/templates/homepage.html delete mode 100644 src-ORIG/main/resources/templates/img.html delete mode 100644 src-ORIG/main/resources/templates/uploadform.html delete mode 100644 src-ORIG/main/resources/templates/user.html delete mode 100644 src-ORIG/test/java/org/yann/demo/DemoApplicationTests.java diff --git a/.github/workflows/build-maven.yml b/.github/workflows/build-maven.yml index b03f9b8..3979e4f 100644 --- a/.github/workflows/build-maven.yml +++ b/.github/workflows/build-maven.yml @@ -24,7 +24,7 @@ jobs: DOCKER_CLI_EXPERIMENTAL: enabled JFROG_PLATFORM_REPO: 'mgm-project-maven-virtual' JF_PROJECT: mgm-project - + steps: - name: Check out repository uses: actions/checkout@v4 @@ -49,7 +49,7 @@ jobs: env: JF_URL: https://psazuse.jfrog.io JF_PROJECT: mgm-project - run: jf mvn clean package deploy + run: jf mvn package deploy - name: Audit with JFrog Xray run: jf audit . diff --git a/pom.xml-ORIG b/pom.xml-ORIG deleted file mode 100644 index b743cf8..0000000 --- a/pom.xml-ORIG +++ /dev/null @@ -1,131 +0,0 @@ - - - 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.2.3 - - - - org.yann - demo - 0.0.1-SNAPSHOT - demo - Demo project for Spring Boot - - 18 - - - - - org.springframework.boot - spring-boot-starter-actuator - - - - org.springframework.boot - spring-boot-starter-web - - - - org.springframework.boot - spring-boot-starter-test - test - - - - org.springframework.boot - spring-boot-starter-thymeleaf - - - - org.springframework.boot - spring-boot-devtools - true - - - - org.springframework.boot - spring-boot-starter-security - - - - com.h2database - h2 - runtime - - - - org.springframework.boot - spring-boot-starter-data-jpa - - - - org.springframework.boot - spring-boot-starter-jdbc - - - - - org.apache.commons - commons-text - 1.9 - - - - - - - org.apache.tomcat.embed - tomcat-embed-core - 10.1.13 - - - - - com.thoughtworks.xstream - xstream - 1.4.20 - - - - - org.yaml - snakeyaml - 1.30 - - - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/src-ORIG/main/java/org/yann/demo/DemoApplication.java b/src-ORIG/main/java/org/yann/demo/DemoApplication.java deleted file mode 100644 index 7373c92..0000000 --- a/src-ORIG/main/java/org/yann/demo/DemoApplication.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.yann.demo; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -@SpringBootApplication -@RestController -public class DemoApplication { - - public static void main(String[] args) { - SpringApplication.run(DemoApplication.class, args); - } - - @GetMapping("/hello") - public String hello(@RequestParam(value = "name", defaultValue = "World") String name) { - return String.format("Hello %s!", name); - } - - // @PostConstruct - // private void initDb() { - // System.out.println(String.format("****** Creating table: %s, and Inserting test data ******", "Employees")); - - // String sqlStatements[] = { - // "drop table employees if exists", - // "create table employees(id serial,first_name varchar(255),last_name varchar(255))", - // "insert into employees(first_name, last_name) values('Donald','Trump')", - // "insert into employees(first_name, last_name) values('Barack','Obama')" - // }; - - // Arrays.asList(sqlStatements).forEach(sql -> { - // jdbcTemplate.execute(sql); - // }); - - // // Fetch data using SELECT statement and print results - // } - - // @Bean(initMethod = "start", destroyMethod = "stop") - // public Server inMemoryH2DatabaseServer() throws SQLException { - // return Server.createTcpServer("-tcp", "-tcpAllowOthers", "-tcpPort", "9091"); - // } -} diff --git a/src-ORIG/main/java/org/yann/demo/Greeting.java b/src-ORIG/main/java/org/yann/demo/Greeting.java deleted file mode 100644 index e143c7c..0000000 --- a/src-ORIG/main/java/org/yann/demo/Greeting.java +++ /dev/null @@ -1,4 +0,0 @@ -package org.yann.demo; - -public record Greeting(long id, String content) { } - diff --git a/src-ORIG/main/java/org/yann/demo/SecurityConfig.java b/src-ORIG/main/java/org/yann/demo/SecurityConfig.java deleted file mode 100644 index 8779219..0000000 --- a/src-ORIG/main/java/org/yann/demo/SecurityConfig.java +++ /dev/null @@ -1,113 +0,0 @@ -package org.yann.demo; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.Customizer; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -import org.springframework.security.config.annotation.web.configuration.WebSecurityCustomizer; -import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -// import org.yann.demo.repository.UserRepository; -// import org.springframework.security.core.userdetails.User; -// import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -// import org.springframework.security.core.userdetails.jdbc.JdbcDaoImpl; -import org.springframework.security.crypto.factory.PasswordEncoderFactories; -import org.springframework.security.crypto.password.PasswordEncoder; -import org.springframework.security.provisioning.InMemoryUserDetailsManager; -import org.springframework.security.web.SecurityFilterChain; -import org.springframework.security.web.util.matcher.AntPathRequestMatcher; - -@Configuration -@EnableWebSecurity -public class SecurityConfig { - // extends WebSecurityConfiguration{ - - // private UserRepository userRepository; - - /** - * @param http - * @return - * @throws Exception - */ - @Bean - public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { - http - .csrf(AbstractHttpConfigurer::disable) - .authorizeHttpRequests((authorize) -> { - - authorize - // .anyRequest().permitAll() - .requestMatchers("/hello").permitAll() - .requestMatchers("/h2-console/**").permitAll() - .anyRequest().authenticated(); - } - ) - .httpBasic(Customizer.withDefaults()) - .formLogin(Customizer.withDefaults()) - .logout(logout -> logout - .invalidateHttpSession(true) - .deleteCookies("JESSIONID")); - - return http.build(); - } - - @Bean - WebSecurityCustomizer webSecurityCustomizer() { - return web -> web.ignoring() - .requestMatchers(new AntPathRequestMatcher("/h2-console/**")); - } - - @Bean - public UserDetailsService userDetailsService() { - UserDetails userDetails = User.builder() - .username("user") - .password(passwordEncoder().encode("password")) - .roles("USER") - .build(); - - return new InMemoryUserDetailsManager(userDetails); - } - - - // @Bean - // public AuthenticationManager authenticationManager( - // UserDetailsService userDetailsService, - // PasswordEncoder passwordEncoder) { - // DaoAuthenticationProvider authenticationProvider = new DaoAuthenticationProvider(); - // authenticationProvider.setUserDetailsService(userDetailsService); - // authenticationProvider.setPasswordEncoder(passwordEncoder); - - // return new ProviderManager(authenticationProvider); - // } - - - // @Bean - // DataSource dataSource() { - // return new EmbeddedDatabaseBuilder() - // .setType(EmbeddedDatabaseType.H2) - // // .addScript(JdbcDaoImpl.DEFAULT_USER_SCHEMA_DDL_LOCATION) - // .build(); - // } - - - // @Bean - // public AuthenticationManager authenticationManager( - // UserDetailsService userDetailsService, - // PasswordEncoder passwordEncoder) throws Exception { - - // DaoAuthenticationProvider authenticationProvider = new MyDaoAuthenticationProvider(); - // authenticationProvider.setUserDetailsService(userDetailsService); - // authenticationProvider.setPasswordEncoder(passwordEncoder); // Inject password encoder if needed - - // return new ProviderManager(authenticationProvider); - // } - - @Bean - public PasswordEncoder passwordEncoder() { - return PasswordEncoderFactories.createDelegatingPasswordEncoder(); - } - -} diff --git a/src-ORIG/main/java/org/yann/demo/controller/GreetingController.java b/src-ORIG/main/java/org/yann/demo/controller/GreetingController.java deleted file mode 100644 index cc90c98..0000000 --- a/src-ORIG/main/java/org/yann/demo/controller/GreetingController.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.yann.demo.controller; - -import java.util.concurrent.atomic.AtomicLong; - -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.yann.demo.Greeting; - -@RestController -public class GreetingController { - - private static final String template = "Hello, %s!"; - private final AtomicLong counter = new AtomicLong(); - - @GetMapping("/greeting") - public Greeting greeting(@RequestParam(value = "name", defaultValue = "World") String name) { - return new Greeting(counter.incrementAndGet(), String.format(template, name)); - } - -} diff --git a/src-ORIG/main/java/org/yann/demo/controller/HomeController.java b/src-ORIG/main/java/org/yann/demo/controller/HomeController.java deleted file mode 100644 index 6065c21..0000000 --- a/src-ORIG/main/java/org/yann/demo/controller/HomeController.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.yann.demo.controller; - -import org.springframework.web.bind.annotation.GetMapping; - -import org.springframework.stereotype.Controller; - -@Controller -public class HomeController { - - @GetMapping("/") - public String index() { - return "homepage"; - } -} diff --git a/src-ORIG/main/java/org/yann/demo/controller/LoginController.java b/src-ORIG/main/java/org/yann/demo/controller/LoginController.java deleted file mode 100644 index 959ffde..0000000 --- a/src-ORIG/main/java/org/yann/demo/controller/LoginController.java +++ /dev/null @@ -1,37 +0,0 @@ -// package org.yann.demo.controller; - -// import org.springframework.http.ResponseEntity; -// import org.springframework.security.authentication.AuthenticationManager; -// import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; -// import org.springframework.stereotype.Controller; -// import org.springframework.web.bind.annotation.PostMapping; -// import org.springframework.web.bind.annotation.RequestBody; - -// @Controller - -// public class LoginController { - -// private final AuthenticationManager authenticationManager; - -// public LoginController(AuthenticationManager authenticationManager) { -// this.authenticationManager = authenticationManager; -// } - -// // @PostMapping("/login") -// // public ResponseEntity login(@RequestBody LoginRequest loginRequest) { -// // UsernamePasswordAuthenticationToken authenticationRequest = -// // UsernamePasswordAuthenticationToken.unauthenticated(loginRequest.username(), loginRequest.password()); -// // org.springframework.security.core.Authentication authenticationResponse = -// // this.authenticationManager.authenticate(authenticationRequest); -// // // ... -// // } - -// public record LoginRequest(String username, String password) { -// } - -// public AuthenticationManager getAuthenticationManager() { -// return authenticationManager; -// } - -// } - diff --git a/src-ORIG/main/java/org/yann/demo/controller/UploadController.java b/src-ORIG/main/java/org/yann/demo/controller/UploadController.java deleted file mode 100644 index 03f416f..0000000 --- a/src-ORIG/main/java/org/yann/demo/controller/UploadController.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.yann.demo.controller; - -import org.springframework.web.bind.annotation.GetMapping; -import org.yann.demo.service.ImageService; - -import jakarta.servlet.http.HttpServletResponse; - -import java.io.IOException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.springframework.stereotype.Controller; - -@Controller -public class UploadController { - - Logger logger = LoggerFactory.getLogger(UploadController.class); - - // @Autowired - ImageService gallery; - - @GetMapping("/upload") - public String uploadImage() { - - logger.info("test"); - - // fetch values from tag field - - // inject in the DB - - // model.addAttribute("images", gallery.get() ); - // model.addAttribute("mypath", "file:///Users/yannc/Downloads/images/" ); - return "uploadform"; - } - - @GetMapping("/dummy") - void manual(HttpServletResponse response) throws IOException { - // jfrog-ignore - response.setHeader("Custom-Header", "foo"); - response.setStatus(200); - response.getWriter().println("Hello World!"); - } -} diff --git a/src-ORIG/main/java/org/yann/demo/controller/UserController.java b/src-ORIG/main/java/org/yann/demo/controller/UserController.java deleted file mode 100644 index 8e7f25f..0000000 --- a/src-ORIG/main/java/org/yann/demo/controller/UserController.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.yann.demo.controller; - -import org.springframework.ui.Model; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.yann.demo.service.FileStorageServiceImpl; -import org.yann.demo.service.ImageService; -import org.yann.demo.service.UserService; -import org.apache.commons.text.StringSubstitutor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; - -import org.springframework.stereotype.Controller; - -@Controller -public class UserController { - - Logger logger = LoggerFactory.getLogger(UserController.class); - - // @Autowired - ImageService gallery; - - @GetMapping("/user") - public void loadGallery(@RequestParam(name="name", required=false, defaultValue="World") String name, Model model) { - - try { - gallery = new FileStorageServiceImpl("/Users/yannc/Downloads/images/"); - gallery.load(); - logger.info(StringSubstitutor.replaceSystemProperties("You are running with java.version = ${java.version} and os.name = ${os.name}.")); - logger.info(gallery.get().toString()); - model.addAttribute("images", gallery.get() ); - model.addAttribute("mypath", "file:///Users/yannc/Downloads/images/" ); - - UserService users = new UserService(); - users.getUser(name); - - } catch (IOException e) { - e.printStackTrace(); - } - - } -} diff --git a/src-ORIG/main/java/org/yann/demo/error/ApiError.java b/src-ORIG/main/java/org/yann/demo/error/ApiError.java deleted file mode 100644 index 293a0df..0000000 --- a/src-ORIG/main/java/org/yann/demo/error/ApiError.java +++ /dev/null @@ -1,52 +0,0 @@ -package org.yann.demo.error; - -import java.util.Arrays; -import java.util.List; - -import org.springframework.http.HttpStatus; - -public class ApiError { - - private HttpStatus status; - private String message; - private List errors; - - public ApiError(HttpStatus status, String message, List errors) { - super(); - this.status = status; - this.message = message; - this.errors = errors; - } - - public ApiError(HttpStatus status, String message, String error) { - super(); - this.status = status; - this.message = message; - errors = Arrays.asList(error); - } - - public HttpStatus getStatus() { - return status; - } - - public String getMessage() { - return message; - } - - public List getErrors() { - return errors; - } - - public void setStatus(HttpStatus status) { - this.status = status; - } - - public void setMessage(String message) { - this.message = message; - } - - public void setErrors(List errors) { - this.errors = errors; - } - -} diff --git a/src-ORIG/main/java/org/yann/demo/error/RestExceptionHandler.java b/src-ORIG/main/java/org/yann/demo/error/RestExceptionHandler.java deleted file mode 100644 index bb9e4e0..0000000 --- a/src-ORIG/main/java/org/yann/demo/error/RestExceptionHandler.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.yann.demo.error; - -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpStatus; -import org.springframework.http.HttpStatusCode; -import org.springframework.http.ResponseEntity; -import org.springframework.web.HttpRequestMethodNotSupportedException; -import org.springframework.web.bind.annotation.RestControllerAdvice; -import org.springframework.web.context.request.WebRequest; -import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; - -@RestControllerAdvice -public class RestExceptionHandler extends ResponseEntityExceptionHandler { - - @Override - protected ResponseEntity handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex, - HttpHeaders headers, HttpStatusCode status, WebRequest request) { - - // return super.handleHttpRequestMethodNotSupported(ex, headers, status,request); - StringBuilder builder = new StringBuilder(); - - builder.append(ex.getMethod()); - builder.append( - " method is not supported for this request. Supported methods are "); - ex.getSupportedHttpMethods().forEach(t -> builder.append(t + " ")); - ApiError apiError = new ApiError(HttpStatus.METHOD_NOT_ALLOWED, - ex.getLocalizedMessage(), builder.toString()); - return new ResponseEntity( - apiError, new HttpHeaders(), apiError.getStatus()); - } -} \ No newline at end of file diff --git a/src-ORIG/main/java/org/yann/demo/model/Gallery.java b/src-ORIG/main/java/org/yann/demo/model/Gallery.java deleted file mode 100644 index 2ebcf0e..0000000 --- a/src-ORIG/main/java/org/yann/demo/model/Gallery.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.yann.demo.model; - -import java.util.ArrayList; -import java.util.List; - -public class Gallery { - List images = new ArrayList(); -} diff --git a/src-ORIG/main/java/org/yann/demo/model/Image.java b/src-ORIG/main/java/org/yann/demo/model/Image.java deleted file mode 100644 index bd37426..0000000 --- a/src-ORIG/main/java/org/yann/demo/model/Image.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.yann.demo.model; - -public class Image { - private String name; - private String comment; - - public Image(String name, String comment) { - this.name = name; - this.comment = comment; - } - - public String GetName() { - return this.name; - } - - public String GetComment() { - return this.comment; - } -} - diff --git a/src-ORIG/main/java/org/yann/demo/model/User.java b/src-ORIG/main/java/org/yann/demo/model/User.java deleted file mode 100644 index 5e18eb3..0000000 --- a/src-ORIG/main/java/org/yann/demo/model/User.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.yann.demo.model; - -// import jakarta.persistence.EmbeddedId; -// import jakarta.persistence.Entity; -// import jakarta.persistence.GeneratedValue; -// import jakarta.persistence.GenerationType; -// import jakarta.persistence.Table; - -// @Entity -// @Table(name = "TBL_USERS") -public class User { - public User(Long id, String username, String password, boolean enabled) { - this.id = id; - this.username = username; - this.password = password; - this.enabled = enabled; - } - - public User(String username, String email) { - this.username = username; - this.email = email; - } - - // @EmbeddedId - // @GeneratedValue(strategy = GenerationType.IDENTITY) - private Long id; - private String username; - private String password; - private String email; - private boolean enabled; - - - // getters - public Long getId() { - return id; - } - - public String getUsername() { - return username; - } - - public String getPassword() { - return password; - } - - public boolean isEnabled() { - return enabled; - } - - public String getEmail() { - return email; - } - - // setters - public void setId(Long id) { - this.id = id; - } - - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setEnabled(boolean enabled) { - this.enabled = enabled; - } - - public void setEmail(String email) { - this.email = email; - } - -} diff --git a/src-ORIG/main/java/org/yann/demo/repository/UserRepository.java b/src-ORIG/main/java/org/yann/demo/repository/UserRepository.java deleted file mode 100644 index 514b7ee..0000000 --- a/src-ORIG/main/java/org/yann/demo/repository/UserRepository.java +++ /dev/null @@ -1,11 +0,0 @@ -// package org.yann.demo.repository; - -// import org.springframework.data.jpa.repository.JpaRepository; -// import org.springframework.data.jpa.repository.Query; -// import org.yann.demo.model.User; - -// public interface UserRepository extends JpaRepository { - -// @Query("SELECT login FROM TBL_USERS u WHERE login = ?1") -// User findByUsername(String username); -// } \ No newline at end of file diff --git a/src-ORIG/main/java/org/yann/demo/security/MyDaoAuthenticationProvider.java b/src-ORIG/main/java/org/yann/demo/security/MyDaoAuthenticationProvider.java deleted file mode 100644 index 0599174..0000000 --- a/src-ORIG/main/java/org/yann/demo/security/MyDaoAuthenticationProvider.java +++ /dev/null @@ -1,15 +0,0 @@ -// package org.yann.demo.security; - -// import org.springframework.security.authentication.dao.DaoAuthenticationProvider; -// import org.springframework.security.core.Authentication; -// import org.springframework.security.core.AuthenticationException; - - -// public class MyDaoAuthenticationProvider extends DaoAuthenticationProvider { - -// @Override -// public Authentication authenticate(Authentication authentication) throws AuthenticationException { -// return super.authenticate(authentication); -// } - -// } \ No newline at end of file diff --git a/src-ORIG/main/java/org/yann/demo/security/MyUserDetails.java b/src-ORIG/main/java/org/yann/demo/security/MyUserDetails.java deleted file mode 100644 index 6cdf92d..0000000 --- a/src-ORIG/main/java/org/yann/demo/security/MyUserDetails.java +++ /dev/null @@ -1,57 +0,0 @@ -// package org.yann.demo.security; - -// import java.util.Collection; - -// import org.springframework.security.core.GrantedAuthority; -// import org.springframework.security.core.userdetails.UserDetails; - -// public class MyUserDetails implements UserDetails { - -// private final String username; -// private final String password; -// private final Collection authorities; -// private final boolean enabled; - -// public MyUserDetails(String username, String password, Collection authorities, boolean enabled) { -// this.username = username; -// this.password = password; -// this.authorities = authorities; -// this.enabled = enabled; -// } - -// @Override -// public Collection getAuthorities() { -// return authorities; -// } - -// @Override -// public String getPassword() { -// return password; -// } - -// @Override -// public String getUsername() { -// return username; -// } - -// @Override -// public boolean isAccountNonExpired() { -// return false; -// } - -// @Override -// public boolean isAccountNonLocked() { -// return false; -// } - -// @Override -// public boolean isCredentialsNonExpired() { -// return false; -// } - -// @Override -// public boolean isEnabled() { -// return enabled; -// } - -// } diff --git a/src-ORIG/main/java/org/yann/demo/security/MyUserDetailsService.java b/src-ORIG/main/java/org/yann/demo/security/MyUserDetailsService.java deleted file mode 100644 index 968e6bb..0000000 --- a/src-ORIG/main/java/org/yann/demo/security/MyUserDetailsService.java +++ /dev/null @@ -1,34 +0,0 @@ -// package org.yann.demo.security; - -// import org.springframework.beans.factory.annotation.Autowired; -// import org.springframework.security.core.userdetails.UserDetails; -// import org.springframework.security.core.userdetails.UserDetailsService; -// import org.springframework.security.core.userdetails.UsernameNotFoundException; -// import org.yann.demo.repository.UserRepository; -// import org.yann.demo.model.User; - - -// public class MyUserDetailsService implements UserDetailsService { - -// @Autowired -// private UserRepository userRepository; - -// @Override -// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { - -// User user = userRepository.findByUsername(username); - -// if (username == null) { -// throw new UsernameNotFoundException("User not found with username: " + username); -// } - -// // Map user data to UserDetails object -// return new MyUserDetails( -// user.getUsername(), -// user.getPassword(), // Assuming password is stored securely -// null, user.isEnabled() // Assuming an "enabled" flag exists in the User entity -// ); - -// } - -// } \ No newline at end of file diff --git a/src-ORIG/main/java/org/yann/demo/service/FileStorageServiceImpl.java b/src-ORIG/main/java/org/yann/demo/service/FileStorageServiceImpl.java deleted file mode 100644 index da723eb..0000000 --- a/src-ORIG/main/java/org/yann/demo/service/FileStorageServiceImpl.java +++ /dev/null @@ -1,54 +0,0 @@ -package org.yann.demo.service; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.HashSet; -import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -public class FileStorageServiceImpl implements ImageService { - - // ResourceLoader resourceLoader; - String folder; - Set gallery; - - public FileStorageServiceImpl(String path) { - folder = path; - this.init(); - } - - @Override - public void init() { - gallery = new HashSet(); - } - - public void setImagesPath(String path) { - folder = path; - } - - @Override - public void load() throws IOException { - try (Stream stream = Files.list(Paths.get(folder))) { - gallery = stream - .filter(file -> !Files.isDirectory(file)) - .map(Path::getFileName) - .map(Path::toString) - .collect(Collectors.toSet()); - } - // return resourceLoader.getResource("file:/Users/yannc/Downloads/" + filename); - } - - public Set get() { - return gallery; - } - - @Override - public void list() { - gallery.stream().forEach(System.out::println); - - } - -} diff --git a/src-ORIG/main/java/org/yann/demo/service/ImageService.java b/src-ORIG/main/java/org/yann/demo/service/ImageService.java deleted file mode 100644 index 94dd09a..0000000 --- a/src-ORIG/main/java/org/yann/demo/service/ImageService.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.yann.demo.service; - -import java.io.IOException; -import java.util.Set; - -import org.springframework.stereotype.Service; - -// import java.nio.file.Path; -// import org.springframework.web.multipart.MultipartFile; - -@Service -public interface ImageService { - public void init(); - -// public void save(MultipartFile file); - public void load() throws IOException; - - public Set get(); - - public void list(); - -// public void deleteAll(); - -// public Stream loadAll(); -} \ No newline at end of file diff --git a/src-ORIG/main/java/org/yann/demo/service/UserService.java b/src-ORIG/main/java/org/yann/demo/service/UserService.java deleted file mode 100644 index 5b3ab75..0000000 --- a/src-ORIG/main/java/org/yann/demo/service/UserService.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.yann.demo.service; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DataAccessException; -import org.springframework.jdbc.core.JdbcTemplate; -import org.springframework.stereotype.Service; -import org.yann.demo.controller.UploadController; -import org.yann.demo.model.User; - -@Service -public class UserService{ - - Logger logger = LoggerFactory.getLogger(UploadController.class); - - - @Autowired - JdbcTemplate jdbcTemplate; - - public UserService() { - } - - public void getUser(String username) { - try { -// jfrog-ignore - jdbcTemplate.query( - "SELECT login, email FROM TBL_USERS WHERE login = " + username, - (rs, rowNum) -> new User(rs.getString("login"), rs.getString("email")), - "") - .forEach(u -> System.out.println(u.toString())); - } catch (DataAccessException ex) { - logger.error("Couldn't connect to the DB"); - } - - } -} \ No newline at end of file diff --git a/src-ORIG/main/resources/application.properties b/src-ORIG/main/resources/application.properties deleted file mode 100644 index 27c7f26..0000000 --- a/src-ORIG/main/resources/application.properties +++ /dev/null @@ -1,16 +0,0 @@ -spring.thymeleaf.check-template-location=true -spring.thymeleaf.prefix=classpath:/templates/ -spring.web.resources.static-locations=file:/Users/yannc/Downloads/images/ - -spring.datasource.url=jdbc:h2:mem:testdb -spring.datasource.driverClassName=org.h2.Driver -spring.datasource.username=sa -spring.datasource.password=password -spring.h2.console.enabled=true -spring.h2.console.path=/h2-console - -spring.sql.init.schema-locations=classpath:sql/schema.sql -spring.sql.init.data-locations=classpath:sql/data.sql - -backend.username=serviceApp -backend.password=fdsfdsfsdfsqfsdfdfqs1237 \ No newline at end of file diff --git a/src-ORIG/main/resources/credentials.txt b/src-ORIG/main/resources/credentials.txt deleted file mode 100644 index 727b810..0000000 --- a/src-ORIG/main/resources/credentials.txt +++ /dev/null @@ -1,3 +0,0 @@ -db.url= -db.user=admin -db.password=fdsfdsfsfsdfdf \ No newline at end of file diff --git a/src-ORIG/main/resources/sql/data.sql b/src-ORIG/main/resources/sql/data.sql deleted file mode 100644 index 16cfcb7..0000000 --- a/src-ORIG/main/resources/sql/data.sql +++ /dev/null @@ -1,5 +0,0 @@ -INSERT INTO TBL_USERS (login, pass, email) VALUES - ('Alex', 'Kole', 'alex@email.com'), - ('Brian', 'Smith', 'brian@email.com'), - ('Johnny', 'Wu', 'johnny@email.com'), - ('Bruce', 'Wayne', 'bruce@wayne.corp'); \ No newline at end of file diff --git a/src-ORIG/main/resources/sql/schema.sql b/src-ORIG/main/resources/sql/schema.sql deleted file mode 100644 index 256c526..0000000 --- a/src-ORIG/main/resources/sql/schema.sql +++ /dev/null @@ -1,8 +0,0 @@ -DROP TABLE IF EXISTS TBL_USERS; - -CREATE TABLE TBL_USERS ( - id INT AUTO_INCREMENT PRIMARY KEY, - login VARCHAR(250) NOT NULL, - pass VARCHAR(250) NOT NULL, - email VARCHAR(250) DEFAULT NULL -); \ No newline at end of file diff --git a/src-ORIG/main/resources/templates/fragments/footer.html b/src-ORIG/main/resources/templates/fragments/footer.html deleted file mode 100644 index f1032d7..0000000 --- a/src-ORIG/main/resources/templates/fragments/footer.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - ... - - -
- © 2024 Footer -
- - \ No newline at end of file diff --git a/src-ORIG/main/resources/templates/fragments/header.html b/src-ORIG/main/resources/templates/fragments/header.html deleted file mode 100644 index d1e89ad..0000000 --- a/src-ORIG/main/resources/templates/fragments/header.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - ... - - - - - \ No newline at end of file diff --git a/src-ORIG/main/resources/templates/homepage.html b/src-ORIG/main/resources/templates/homepage.html deleted file mode 100644 index ca2a7e9..0000000 --- a/src-ORIG/main/resources/templates/homepage.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - -
-
-
-

Test

-

- Welcome to the Spring MVC Quickstart application! - Get started quickly by signing up. -

-

- Sign up -

-
-
- -
- - \ No newline at end of file diff --git a/src-ORIG/main/resources/templates/img.html b/src-ORIG/main/resources/templates/img.html deleted file mode 100644 index eb7a5d7..0000000 --- a/src-ORIG/main/resources/templates/img.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
-
- -

My Team

-
-
-
\ No newline at end of file diff --git a/src-ORIG/main/resources/templates/uploadform.html b/src-ORIG/main/resources/templates/uploadform.html deleted file mode 100644 index 768e419..0000000 --- a/src-ORIG/main/resources/templates/uploadform.html +++ /dev/null @@ -1,20 +0,0 @@ - - - - Getting Started: Serving Web Content - - - - - - -
- -
-

-

- -
- - - \ No newline at end of file diff --git a/src-ORIG/main/resources/templates/user.html b/src-ORIG/main/resources/templates/user.html deleted file mode 100644 index 7b3abf1..0000000 --- a/src-ORIG/main/resources/templates/user.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - Getting Started: Serving Web Content - - - - - - -
- -
-

Image Gallery

-
-
- -
-
-
- -
- - - - \ No newline at end of file diff --git a/src-ORIG/test/java/org/yann/demo/DemoApplicationTests.java b/src-ORIG/test/java/org/yann/demo/DemoApplicationTests.java deleted file mode 100644 index 780dc56..0000000 --- a/src-ORIG/test/java/org/yann/demo/DemoApplicationTests.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.yann.demo; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class DemoApplicationTests { - - @Test - void contextLoads() { - } - -}