Skip to content

Commit

Permalink
1.0.2: Comment adjustments for JavaDoc
Browse files Browse the repository at this point in the history
  • Loading branch information
naturalprogrammer committed Jul 1, 2022
1 parent b58472b commit 2dd08cc
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ public LemonCommonsWebAutoConfiguration() {
/**
* Prefixes JSON responses for JSON vulnerability. Disabled by default.
* To enable, add this to your application properties:
* lemon.enabled.json-prefix: true
* lemon.enabled.json-prefix: true
*
* @param objectMapper Object Mapper (configured by Spring Boot)
* @return Message converted
*/
@Bean
@ConditionalOnProperty(name="lemon.enabled.json-prefix")
Expand All @@ -100,9 +103,12 @@ public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter(

return converter;
}

/**
* Configures DefaultExceptionHandlerControllerAdvice if missing
* @param <T> exception
* @param errorResponseComposer the configured errorResponseComposer
* @return configured defaultExceptionHandlerControllerAdvice
*/
@Bean
@ConditionalOnMissingBean(DefaultExceptionHandlerControllerAdvice.class)
Expand All @@ -114,9 +120,6 @@ DefaultExceptionHandlerControllerAdvice<T> defaultExceptionHandlerControllerAdvi
return new DefaultExceptionHandlerControllerAdvice<>(errorResponseComposer);
}

/**
* Configures an Error Attributes if missing
*/
@Bean
@ConditionalOnMissingBean(ErrorAttributes.class)
public <T extends Throwable>
Expand All @@ -126,9 +129,6 @@ ErrorAttributes errorAttributes(ErrorResponseComposer<T> errorResponseComposer)
return new LemonErrorAttributes<>(errorResponseComposer);
}

/**
* Configures an Error Controller if missing
*/
@Bean
@ConditionalOnMissingBean(ErrorController.class)
public ErrorController errorController(ErrorAttributes errorAttributes,
Expand All @@ -139,9 +139,6 @@ public ErrorController errorController(ErrorAttributes errorAttributes,
return new LemonErrorController(errorAttributes, serverProperties, errorViewResolvers);
}

/**
* Configures LemonCorsConfig if missing and lemon.cors.allowed-origins is provided
*/
@Bean
@ConditionalOnProperty(name="lemon.cors.allowed-origins")
@ConditionalOnMissingBean(CorsConfigurationSource.class)
Expand All @@ -151,9 +148,6 @@ public LemonCorsConfigurationSource corsConfigurationSource(LemonProperties prop
return new LemonCorsConfigurationSource(properties);
}

/**
* Configures LemonSecurityConfig if missing
*/
@Bean
@ConditionalOnBean(LemonWebSecurityConfig.class)
public SecurityFilterChain lemonSecurityFilterChain(HttpSecurity http, LemonWebSecurityConfig securityConfig) throws Exception {
Expand All @@ -162,9 +156,6 @@ public SecurityFilterChain lemonSecurityFilterChain(HttpSecurity http, LemonWebS
return securityConfig.configure(http).build();
}

/**
* Configures an Auditor Aware if missing
*/
@Bean
@ConditionalOnMissingBean(AuditorAware.class)
public <ID extends Serializable>
Expand All @@ -174,9 +165,6 @@ AuditorAware<ID> auditorAware() {
return new LemonWebAuditorAware<>();
}

/**
* Configures LemonUtils
*/
@Bean
public LecwUtils lecwUtils(ApplicationContext applicationContext,
ObjectMapper objectMapper) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ public DefaultExceptionHandlerControllerAdvice(ErrorResponseComposer<T> errorRes
}


/**
* Handles exceptions
*/
@RequestMapping(produces = "application/json")
@ExceptionHandler(Throwable.class)
public ResponseEntity<?> handleException(T ex) throws T {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@
import com.naturalprogrammer.spring.lemon.exceptions.ErrorResponseComposer;
import com.naturalprogrammer.spring.lemon.exceptions.util.LexUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.boot.web.error.ErrorAttributeOptions;
import org.springframework.boot.web.servlet.error.DefaultErrorAttributes;
import org.springframework.web.context.request.WebRequest;
Expand Down Expand Up @@ -59,9 +57,6 @@ public Map<String, Object> getErrorAttributes(WebRequest request,
return errorAttributes;
}

/**
* Handles exceptions
*/
@SuppressWarnings("unchecked")
protected void addLemonErrorDetails(
Map<String, Object> errorAttributes, WebRequest request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import com.nimbusds.jwt.JWTClaimsSet;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.http.HttpHeaders;
import org.springframework.security.authentication.AuthenticationCredentialsNotFoundException;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
Expand Down Expand Up @@ -97,7 +95,7 @@ protected Authentication createAuthToken(String token) {
return new UsernamePasswordAuthenticationToken(principal, token, principal.getAuthorities());
}

/**
/*
* Default behaviour is to throw error. To be overridden in auth service.
*/
protected UserDto fetchUserDto(JWTClaimsSet claims) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void createLemonWebSecurityConfig(BlueTokenService blueTokenService) {
log.info("Created");
}

/**
/*
* Security configuration, calling protected methods
*/
public HttpSecurity configure(HttpSecurity http) throws Exception {
Expand All @@ -61,45 +61,45 @@ public HttpSecurity configure(HttpSecurity http) throws Exception {
return http;
}

/**

/*
* Configuring session creation policy
*/
protected void sessionCreationPolicy(HttpSecurity http) throws Exception {

// No session
http.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
}

/**

/*
* Logout related configuration
*/
protected void logout(HttpSecurity http) throws Exception {

http
.logout().disable(); // we are stateless; so /logout endpoint not needed
.logout().disable(); // we are stateless; so /logout endpoint not needed
}

/**

/*
* Configures exception-handling
*/
protected void exceptionHandling(HttpSecurity http) throws Exception {

http
.exceptionHandling()
/***********************************************
* To prevent redirection to the login page
* when someone tries to access a restricted page
**********************************************/
.authenticationEntryPoint(new Http403ForbiddenEntryPoint());
.exceptionHandling()

/***********************************************
* To prevent redirection to the login page
* when someone tries to access a restricted page
**********************************************/
.authenticationEntryPoint(new Http403ForbiddenEntryPoint());
}


/**
/*
* Configuring token authentication filter
*/
protected void tokenAuthentication(HttpSecurity http) {
Expand All @@ -113,37 +113,34 @@ protected void tokenAuthentication(HttpSecurity http) {
* Disables CSRF. We are stateless.
*/
protected void csrf(HttpSecurity http) throws Exception {

http
.csrf().disable();
.csrf().disable();
}

/**

/*
* Configures CORS
*/
protected void cors(HttpSecurity http) throws Exception {

http
.cors();
.cors();
}

/**

/*
* URL based authorization configuration. Override this if needed.
*/
protected void authorizeRequests(HttpSecurity http) throws Exception {
http.authorizeRequests()
.mvcMatchers("/**").permitAll();
.mvcMatchers("/**").permitAll();
}


/**
/*
* Override this to add more http configurations,
* such as more authentication methods.
*
* @param http
* @throws Exception
*/
protected void otherConfigurations(HttpSecurity http) {
// Override this method to provide other configurations
Expand Down

0 comments on commit 2dd08cc

Please sign in to comment.