Commit a3fb00ef authored by Noel Alonso's avatar Noel Alonso
Browse files

Añade configuración de seguridad y mapping

parent 5d6f9026
Loading
Loading
Loading
Loading
+39 −0
Original line number Diff line number Diff line
package es.redmic.timeseriesview.config;

import org.joda.time.DateTime;
import org.springframework.stereotype.Component;

import es.redmic.viewlib.config.MapperScanBeanBase;
import es.redmic.viewlib.config.MapperScanBeanItfc;
import ma.glasnost.orika.converter.builtin.PassThroughConverter;
import ma.glasnost.orika.impl.DefaultMapperFactory;

@Component
public class MapperScanBean extends MapperScanBeanBase implements MapperScanBeanItfc {

	public MapperScanBean() {
		super();
	}

	@Override
	protected void addDefaultActions() {

		addConverter(new PassThroughConverter(DateTime.class));
	}

	@Override
	protected void addObjectFactory() {

	}

	public MapperScanBean build() {

		if (factory == null) {

			factory = new DefaultMapperFactory.Builder().build();
			addObjectFactory();
			addDefaultActions();
		}
		return this;
	}
}
 No newline at end of file
+39 −0
Original line number Diff line number Diff line
package es.redmic.timeseriesview.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;

import es.redmic.restlib.config.ResourceServerConfigurationBase;

@Configuration
public class Oauth2SecurityConfiguration {

	@Configuration
	@EnableResourceServer
	protected static class ResourceServerConfiguration extends ResourceServerConfigurationBase {

		@Override
		public void configure(HttpSecurity http) throws Exception {
			// @formatter:off
			
			http.authorizeRequests().antMatchers(HttpMethod.GET, "/actuator/**").permitAll();
			
			http.authorizeRequests().antMatchers(HttpMethod.GET, "/**").permitAll();
			
			http.authorizeRequests().antMatchers(HttpMethod.POST, "/**/_search").permitAll();
			
			http.authorizeRequests().antMatchers(HttpMethod.POST, "/**/_mget").permitAll();
			
			http.authorizeRequests().antMatchers(HttpMethod.POST, "/**/_suggest").permitAll();
			
			http.authorizeRequests().antMatchers("/**/_selection/**").permitAll();
			
			http.authorizeRequests().antMatchers(HttpMethod.GET, "/**/_search/_schema").permitAll();
			
			http.authorizeRequests().antMatchers("/**").access(
					"#oauth2.hasScope('read') and hasAnyRole('ROLE_ADMINISTRATOR', 'ROLE_OAG', 'ROLE_COLLABORATOR')");
		}
	}
}
 No newline at end of file
+20 −0
Original line number Diff line number Diff line
package es.redmic.timeseriesview.config;

import org.springframework.stereotype.Service;
import org.springframework.web.context.annotation.SessionScope;

import es.redmic.restlib.common.service.UserUtilsServiceItfc;
import es.redmic.restlib.config.UserBaseService;

@SessionScope
@Service
public class UserService extends UserBaseService implements UserUtilsServiceItfc {

	/*
	 * Implementa la interfaz para obtener información de usuarios
	 */

	public UserService() {
		super();
	}
}