Fix json props.

This commit is contained in:
Paulo Gustavo Veiga 2024-02-09 00:02:56 -08:00
parent 05c2e545ae
commit 34318c1e3f
4 changed files with 33 additions and 36 deletions

View File

@ -25,6 +25,7 @@ import java.util.Optional;
@Component @Component
public class JwtAuthenticationFilter extends OncePerRequestFilter { public class JwtAuthenticationFilter extends OncePerRequestFilter {
private static final String BEARER_TOKEN_PREFIX = "Bearer "; private static final String BEARER_TOKEN_PREFIX = "Bearer ";
private static final String AUTHORIZATION_HEADER = "Authorization";
@Autowired @Autowired
private UserDetailsService userDetailsService; private UserDetailsService userDetailsService;
@ -38,7 +39,6 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
throws ServletException, IOException { throws ServletException, IOException {
final Optional<String> token = getJwtTokenFromRequest(request); final Optional<String> token = getJwtTokenFromRequest(request);
if (token.isPresent() && SecurityContextHolder.getContext().getAuthentication() == null) { if (token.isPresent() && SecurityContextHolder.getContext().getAuthentication() == null) {
// Extract email from token ... // Extract email from token ...
final Optional<String> email = extractEmailFromToken(token.get()); final Optional<String> email = extractEmailFromToken(token.get());
@ -74,7 +74,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
private static Optional<String> getJwtTokenFromRequest(@NotNull HttpServletRequest request) { private static Optional<String> getJwtTokenFromRequest(@NotNull HttpServletRequest request) {
Optional<String> result = Optional.empty(); Optional<String> result = Optional.empty();
final String authorizationHeader = request.getHeader("Authorization"); final String authorizationHeader = request.getHeader(AUTHORIZATION_HEADER);
if (authorizationHeader != null) { if (authorizationHeader != null) {
if (authorizationHeader.startsWith(BEARER_TOKEN_PREFIX)) { if (authorizationHeader.startsWith(BEARER_TOKEN_PREFIX)) {
logger.trace("JWT Bearer token found."); logger.trace("JWT Bearer token found.");

View File

@ -21,12 +21,13 @@ package com.wisemapping.model;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import jakarta.persistence.*; import jakarta.persistence.*;
import java.io.Serializable; import java.io.Serializable;
@Entity @Entity
@Table(name = "COLLABORATION_PROPERTIES") @Table(name = "COLLABORATION_PROPERTIES")
public class CollaborationProperties implements Serializable { public class CollaborationProperties implements Serializable {
public static final String DEFAULT_JSON_PROPERTIES = "{zoom:0.8}"; public static final String DEFAULT_JSON_PROPERTIES = "{\"zoom\":0.8}";
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private int id; private int id;

View File

@ -33,7 +33,6 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
@ -206,7 +205,6 @@ public class MindmapController extends BaseController {
return mindmapHistory.getUnzipXml(); return mindmapHistory.getUnzipXml();
} }
/** /**
* The intention of this method is the update of several properties at once ... * The intention of this method is the update of several properties at once ...
*/ */

View File

@ -35,6 +35,14 @@ public class RestMindmapMetadata {
private String jsonProps; private String jsonProps;
private boolean locked; private boolean locked;
private String title; private String title;
private String isLockedBy;
public RestMindmapMetadata(@NotNull String title, @NotNull String jsonProps, boolean locked, @Nullable String isLockedBy) {
this.jsonProps = jsonProps;
this.title = title;
this.locked = locked;
this.isLockedBy = isLockedBy;
}
public String getJsonProps() { public String getJsonProps() {
return jsonProps; return jsonProps;
@ -60,21 +68,11 @@ public class RestMindmapMetadata {
this.title = title; this.title = title;
} }
public String getLockFullName() { public String getIsLockedBy() {
return lockFullName; return isLockedBy;
} }
public void setLockFullName(String lockFullName) { public void setIsLockedBy(String isLockedBy) {
this.lockFullName = lockFullName; this.isLockedBy = isLockedBy;
} }
private String lockFullName;
public RestMindmapMetadata(@NotNull String title, @NotNull String jsonProps, boolean locked, @Nullable String lockFullName) {
this.jsonProps = jsonProps;
this.title = title;
this.locked = locked;
this.lockFullName = lockFullName;
}
} }