Skip to content

Commit 82f1890

Browse files
authored
Merge pull request #76 from coderPaddyS/Adriano/finish
Finish javadocs
2 parents b63f3d6 + 6ba1283 commit 82f1890

File tree

11 files changed

+131
-35
lines changed

11 files changed

+131
-35
lines changed

backend/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,4 @@
168168
</plugins>
169169
</build>
170170

171-
</project>
171+
</project>

backend/src/main/java/de/itermori/pse/kitroomfinder/backend/BackendApplication.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,22 @@
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
66
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
77

8+
/**
9+
* The main class.
10+
*
11+
* @author Lukas Zetto
12+
* @author Adriano Castro
13+
* @version 1.0
14+
*/
815
@EnableEncryptableProperties
916
@EnableJpaRepositories(basePackages = "de.itermori.pse.kitroomfinder.backend.repositories")
1017
@SpringBootApplication()
1118
public class BackendApplication {
1219

20+
/**
21+
* The main method.
22+
* @param args The arguments.
23+
*/
1324
public static void main(String[] args) {
1425
SpringApplication.run(BackendApplication.class, args);
1526
}

backend/src/main/java/de/itermori/pse/kitroomfinder/backend/ErrorHandling.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,21 @@
99
import java.util.List;
1010
import java.util.stream.Collectors;
1111

12+
/**
13+
* Handles GraphQL errors.
14+
*
15+
* @author Lukas Zetto
16+
* @version 1.0
17+
*/
1218
@Component
1319
public class ErrorHandling implements GraphQLErrorHandler {
20+
21+
/**
22+
* Processes GraphQL errors.
23+
*
24+
* @param errors The GraphQL errors.
25+
* @return The processed errors.
26+
*/
1427
@Override
1528
public List<GraphQLError> processErrors(List<GraphQLError> errors) {
1629
if (errors == null || errors.isEmpty()) {
@@ -28,4 +41,5 @@ private GraphQLError unwrapError(GraphQLError error) {
2841
} else
2942
return error;
3043
}
44+
3145
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
package de.itermori.pse.kitroomfinder.backend.exceptions;
22

3+
/**
4+
* Exception class for handling bad tokens.
5+
*
6+
* @author Lukas Zetto
7+
* @version 1.0
8+
*/
39
public class BadTokenException extends RuntimeException {
410

11+
/**
12+
* {@inheritDoc}
13+
*/
514
@Override
615
public String getMessage() {
716
return "invalid Token";
817
}
18+
919
}

backend/src/main/java/de/itermori/pse/kitroomfinder/backend/exceptions/NoSuchAliasSuggestionException.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
package de.itermori.pse.kitroomfinder.backend.exceptions;
22

3+
/**
4+
* Exception class for handling case when no alias suggestion with provided name exists.
5+
*
6+
* @author Adriano Castro
7+
* @version 1.0
8+
*/
39
public class NoSuchAliasSuggestionException extends RuntimeException {
410

11+
/**
12+
* {@inheritDoc}
13+
*/
514
@Override
615
public String getMessage() {
716
return "No such alias suggestion exists in the database";

backend/src/main/java/de/itermori/pse/kitroomfinder/backend/exceptions/UserNotFoundException.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
package de.itermori.pse.kitroomfinder.backend.exceptions;
22

3+
/**
4+
* Exception class for handling case when provided user is not registered yet.
5+
*
6+
* @author Lukas Zetto
7+
* @version 1.0
8+
*/
39
public class UserNotFoundException extends RuntimeException{
410

11+
/**
12+
* {@inheritDoc}
13+
*/
514
@Override
615
public String getMessage() {
716
return "User not registered yet";

backend/src/main/java/de/itermori/pse/kitroomfinder/backend/security/JWTFilter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818

1919
import static java.util.function.Predicate.not;
2020

21+
/**
22+
* Filter that manages the authentication and authorization.
23+
*
24+
* @author Lukas Zetto
25+
* @version 1.0
26+
*/
2127
@Component
2228
public class JWTFilter extends OncePerRequestFilter {
2329
private static final String AUTHORIZATION_HEADER = "Authorization";
@@ -51,5 +57,5 @@ private Optional<String> getToken(HttpServletRequest request) {
5157
.filter(Matcher::find)
5258
.map(matcher -> matcher.group(1));
5359
}
54-
}
5560

61+
}
Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,56 @@
11
package de.itermori.pse.kitroomfinder.backend.security;
22

33
import de.itermori.pse.kitroomfinder.backend.models.User;
4-
import javassist.Loader;
4+
import java.util.Set;
5+
import java.util.stream.Collectors;
6+
import java.util.stream.Stream;
57
import lombok.Builder;
68
import lombok.Getter;
79
import org.springframework.security.core.GrantedAuthority;
810
import org.springframework.security.core.authority.SimpleGrantedAuthority;
911
import org.springframework.security.web.authentication.WebAuthenticationDetails;
1012
import org.springframework.security.web.authentication.preauth.PreAuthenticatedAuthenticationToken;
1113

12-
import java.util.Set;
13-
import java.util.stream.Collectors;
14-
import java.util.stream.Stream;
15-
14+
/**
15+
* Token that carries the authorities of the authenticated user.
16+
*
17+
* @author Lukas Zetto
18+
* @version 1.0
19+
*/
1620
@Getter
1721
public class JWTPreAuthenticationToken extends PreAuthenticatedAuthenticationToken {
22+
1823
private static final long serialVersionUID = 34737835684569L;
1924

25+
/**
26+
* Constructor: Demands for the initialization a {@link User} and a {@link WebAuthenticationDetails}.
27+
*
28+
* @param principal The user.
29+
* @param details The web authentication details.
30+
*/
2031
@Builder
2132
public JWTPreAuthenticationToken(User principal, WebAuthenticationDetails details) {
2233
super(principal, null, parseAuthorities(principal.getAuthorities()));
2334
super.setDetails(details);
2435
}
2536

37+
/**
38+
*
39+
* {@inheritDoc}
40+
*/
2641
@Override
2742
public Object getCredentials() {
2843
return null;
2944
}
3045

3146
private static Set<GrantedAuthority> parseAuthorities(String authorities) {
3247
return Stream.of(authorities.split(","))
33-
.map(authority -> buildSimpleGrantedAuthority(authority))
48+
.map(JWTPreAuthenticationToken::buildSimpleGrantedAuthority)
3449
.collect(Collectors.toSet());
3550
}
3651

3752
private static SimpleGrantedAuthority buildSimpleGrantedAuthority(String authority) {
3853
return new SimpleGrantedAuthority(authority);
3954
}
55+
4056
}

backend/src/main/java/de/itermori/pse/kitroomfinder/backend/security/WebSecurityConfig.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package de.itermori.pse.kitroomfinder.backend.security;
22

3-
import java.util.Arrays;
43
import java.util.List;
54
import lombok.RequiredArgsConstructor;
65
import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -13,21 +12,28 @@
1312
import org.springframework.security.config.http.SessionCreationPolicy;
1413
import org.springframework.security.web.authentication.preauth.RequestHeaderAuthenticationFilter;
1514
import org.springframework.web.cors.CorsConfiguration;
16-
import org.springframework.web.cors.CorsConfigurationSource;
1715
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
1816
import org.springframework.web.filter.CorsFilter;
1917

20-
import static org.springframework.security.config.Customizer.withDefaults;
21-
18+
/**
19+
* Configuration class which defines the standard rights
20+
* for the methods in the resolver package and for the filter.
21+
*
22+
* @author Lukas Zetto
23+
* @version 1.0
24+
*/
2225
@Configuration
2326
@EnableWebSecurity
2427
@EnableGlobalMethodSecurity(prePostEnabled = true)
2528
@RequiredArgsConstructor
2629
@EnableConfigurationProperties()
2730
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
28-
private final JWTFilter jwtFilter;
2931

32+
private final JWTFilter jwtFilter;
3033

34+
/**
35+
* {@inheritDoc}
36+
*/
3137
@Override
3238
protected void configure(HttpSecurity http) throws Exception {
3339
http
@@ -39,6 +45,10 @@ protected void configure(HttpSecurity http) throws Exception {
3945
.addFilterBefore(jwtFilter, RequestHeaderAuthenticationFilter.class);
4046
}
4147

48+
/**
49+
* Configures CORS.
50+
* @return The CORS filter.
51+
*/
4252
@Bean
4353
public CorsFilter corsConfigurationSource() {
4454
CorsConfiguration configuration = new CorsConfiguration();
@@ -49,4 +59,5 @@ public CorsFilter corsConfigurationSource() {
4959
source.registerCorsConfiguration("/**", configuration);
5060
return new CorsFilter(source);
5161
}
62+
5263
}

backend/src/test/java/de/itermori/pse/kitroomfinder/backend/BackendApplicationTests.java

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)