Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0581928
Update README.md
kollier-martin Oct 29, 2021
e8ba3b4
Update README.md
kollier-martin Oct 29, 2021
3742589
Update README.md
kollier-martin Oct 29, 2021
8d862ef
Utils and Servlets push for early setup
kollier-martin Oct 29, 2021
c971130
Merge branch 'kollier-feature' of https://github.com/210913-java-full…
kollier-martin Oct 29, 2021
a658d28
Hiccup
kollier-martin Oct 29, 2021
0f5992f
Delete src/main/resources directory
kollier-martin Oct 29, 2021
977725f
Merge branch 'kollier-feature' of https://github.com/210913-java-full…
kollier-martin Oct 29, 2021
7ea238f
CredentialValidator: Regex for account creation. Can be used on both …
kollier-martin Oct 29, 2021
a6f3ff1
Update README.md
kollier-martin Nov 1, 2021
01da59f
Updated .gitignore
kollier-martin Nov 1, 2021
9f72838
Delete beans.xml
kollier-martin Nov 1, 2021
633368e
Update README.md
kollier-martin Nov 1, 2021
7bcb8a1
A Few Changes
kollier-martin Nov 2, 2021
d3ce87f
Merge remote-tracking branch 'origin/kollier-feature' into kollier-fe…
kollier-martin Nov 2, 2021
93f29ac
A few changes
kollier-martin Nov 3, 2021
2c20ff5
A working commit that creates tables
kollier-martin Nov 4, 2021
b4b04dd
Group Agreement
kollier-martin Nov 4, 2021
2be99da
Sprint Push
kollier-martin Nov 5, 2021
9f3ec62
Team Update
kollier-martin Nov 5, 2021
13e4bef
Feature Update
kollier-martin Nov 9, 2021
abd22c4
Feature Update Patch
kollier-martin Nov 9, 2021
1aed1a1
Location Stuff
kollier-martin Nov 9, 2021
c8eb457
Logger Implementation
kollier-martin Nov 10, 2021
fcf4fe6
Update HELP.md
kollier-martin Nov 10, 2021
45b2c95
Dummy Commit. Unfinished Methods
kollier-martin Nov 12, 2021
e02aa7d
Backend Registration Changes
kollier-martin Nov 12, 2021
2b57620
AuthenticationController
kollier-martin Nov 13, 2021
cffe20c
Updates
kollier-martin Nov 15, 2021
aee3155
Optimization Pass #1
kollier-martin Nov 15, 2021
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: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@
*.tar.gz
*.rar

# Resources
# src/main/resources

# IntelliJ
\.idea

Expand All @@ -30,3 +27,4 @@ hs_err_pid*

# ignore any .properties files
*.properties
/.jpb/
37 changes: 24 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,41 @@ Team Vanquish Project 2 Implementation
- [ ] Users are interfacing with an advanced UI built with Angular running in a browser
- [ ] CRUD operations are supported for one or more domain objects via the web application's API endpoints
- [ ] Client/Server communication is done with JSON in HTTP request and response bodies.
- [ ] Client/Server communication is done with JSON in HTTP request and response bodies.
- [ ] All low-level persistence logic is abstracted away with Hibernate/Spring Data
- [ ] Documentation (all classes and methods have adequate Javadoc comments)
- [ ] All Exceptions are caught and logged to a file
- [ ] All VanquishP2.Exceptions are caught and logged to a file/database
- [ ] Data useful to the application is retrieved from a third party API
- [ ] Adequate test coverage for the service-layer
- [ ] DevOps CI/CD pipeline is used to build and deploy project to a publicly available remote location


## -- App Name Here --
You will need to write a small paragraph describing your application. It should be 4-6 sentences and briefly cover the important points and features.
## -- 4TheMusic --

### Minimum Viable Product
Your team will need to work with the trainer to come up with a satisfactory list of user stories for MVP as well as bonus stories. They should begin with "As a [stakeholder] I can... and describe what the user should be able to do. Aim for at least 2 different roles, user and administrator. Try to come up with 8 or so user stories for MVP. Carefully consider what your team can accomplish in 3 weeks and try not to set yourselves too great a task.
"4TheMusic" is a social web service that brings music fans and concert-goers together with their favorite artists,
while allowing premium users to gain valuable insights from user trends and analytics.

Users can create and share playlists of their favorite songs and artists,
along with viewing songs by similar artists and genres, and connecting to the social media accounts of their
favorite artists.

* As a user, I can see...
* As a user, I can purchase...
* As a user, I can check...
* As an administrator, I can schedule...
* As an administrator, I can cancel...
* As an administrator, I can view...
Premium users (concert organizers, artists, tour managers, etc.) can browse artists and see high-level, real-time analytics on
the users that like particular artists.


### Minimum Viable Product
* As a user, I can create a playlist.
* As a user, I can add or remove songs from a playlist.
* As a user, I can rate a song with a like or dislike.
* As a user, I can look up an album and see what songs are on it.
* As a user, I can look up an artist and see a [limited] list of their songs.
* As a premium user, I can schedule a concert.
* As a premium user, I can cancel a concert.
* As a premium user, I can see a list of liked songs for a user.
* As a premium user, I can see a like/dislike ratio for a particular song.

### Bonus Stories
* As an administrator, I can...
* As a user, I can view a list of users who like the same songs.
* As a premium user, I can see a like/dislike ratio for an entire artist.

## Tech Stack
You should be employing the following technologies in your project.
Expand Down
96 changes: 90 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>
<groupId>com.revature.vanquish</groupId>
<artifactId>P2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>0.0.1</version>
<packaging>war</packaging>
<name>P2</name>
<description>Project 2 with Spring Boot Implementation</description>
Expand All @@ -22,30 +22,114 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
<version>2.5.5</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<version>2.5.5</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.vaadin.external.google</groupId>
<artifactId>android-json</artifactId>
<version>0.0.20131108.vaadin1</version>
<scope>compile</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.13.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.13.0</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>2.7.3</version>
<scope>runtime</scope>
</dependency>

<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20210307</version>
</dependency>

<!-- JSON Web Token -->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-api</artifactId>
<version>0.11.2</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-impl</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt-jackson</artifactId>
<version>0.11.2</version>
<scope>runtime</scope>
</dependency>

<!-- Mockito -->
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.0.0</version>
</dependency>

<!-- H2 Testing Database -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.200</version>
</dependency>

<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
13 changes: 0 additions & 13 deletions src/main/java/Application/P2Application.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package VanquishP2.Application.Beans.Aspects;

import VanquishP2.Application.Beans.ModelServices.LoggerService;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

/**
* LoggerAspect
* Logs all method calls and exceptions for all classes except filters.
*
* @author Kollier Martin
*/


@Aspect
@Component
public class LoggerAspect {
private final LoggerService loggerService;

public LoggerAspect(LoggerService loggerService) {
this.loggerService = loggerService;
}

@Pointcut("within(VanquishP2.*.*.*.*)")
public void logAll() {

}

@Around("within(VanquishP2.*.*.*.*)")
public void logAroundAll(ProceedingJoinPoint joinPoint) throws Throwable {
try {
joinPoint.proceed();
} catch (Exception ignored){

}
}

@AfterThrowing(pointcut = "logAll()", throwing = "e")
public void logMethodException(JoinPoint jp, Throwable e) {
String methodSig = extractMethodSignature(jp);
loggerService.writeLog(String.format("%s was thrown in method %s with message: %s", e.getClass().getSimpleName(), methodSig, e.getMessage()), 3);
}

private String extractMethodSignature(JoinPoint jp) {
return jp.getTarget().getClass().toString() + "." + jp.getSignature().getName();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package VanquishP2.Application.Beans.Filters;

import VanquishP2.Application.Beans.Service.JWTUtil;
import VanquishP2.DTOs.PrincipalDTO;
import VanquishP2.Exceptions.AuthenticationException;
import io.jsonwebtoken.Claims;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
* Authentication Filter
* Chains with other filters on every endpoint call to make sure the current request is from a valid source
* @author Kollier Martin
* @date 11/8/2021
*/

@Component
public class AuthenticationFilter implements Filter {
private JWTUtil jwtUtil;

@Override
public void init(FilterConfig config) {
ApplicationContext container = WebApplicationContextUtils.getRequiredWebApplicationContext(config.getServletContext());
this.jwtUtil = container.getBean(JWTUtil.class);
}

@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws ServletException, IOException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) resp;

if (!request.getRequestURI().equals("/4TheMusic/login")
&& !request.getRequestURI().equals("/4TheMusic/register/basic")
&& !request.getRequestURI().equals("/4TheMusic/register/premium")
&& !request.getRequestURI().equals("/4TheMusic/user/all")) {
parseToken(request);
}

chain.doFilter(request, response);
}

private void parseToken(HttpServletRequest request) throws AuthenticationException {
String errMessage = "Unauthorized user tried to barge their way in here! Don't worry, I caught this transgression. Error: %s";

String header = request.getHeader(jwtUtil.getHeader());

if (header == null || !header.startsWith(jwtUtil.getPrefix())) {
throw new AuthenticationException(errMessage);
} else {
String token = header.replaceAll(jwtUtil.getPrefix(), "");

Claims jwtClaims = jwtUtil.parseJWT(token);
PrincipalDTO principalDTO = new PrincipalDTO(jwtClaims);
request.setAttribute("principal", principalDTO);
}
}
}
22 changes: 22 additions & 0 deletions src/main/java/VanquishP2/Application/Beans/Filters/CORSFilter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package VanquishP2.Application.Beans.Filters;

import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component
public class CORSFilter extends OncePerRequestFilter {

@Override
protected void doFilterInternal(HttpServletRequest req, HttpServletResponse resp, FilterChain chain) throws ServletException, IOException {
resp.setHeader("Access-Control-Allow-Origin", "*");
resp.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, PUT, PATCH");
resp.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, Authentication");
chain.doFilter(req, resp);
}
}
Loading