basic structure
This commit is contained in:
		
							
								
								
									
										25
									
								
								src/main/java/de/jottyfan/camporganizer/Main.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/main/java/de/jottyfan/camporganizer/Main.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| package de.jottyfan.camporganizer; | ||||
|  | ||||
| import org.springframework.boot.SpringApplication; | ||||
| import org.springframework.boot.autoconfigure.SpringBootApplication; | ||||
| import org.springframework.boot.builder.SpringApplicationBuilder; | ||||
| import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author jotty | ||||
|  * | ||||
|  */ | ||||
| @SpringBootApplication | ||||
| @RestController | ||||
| public class Main extends SpringBootServletInitializer { | ||||
| 	@Override | ||||
| 	protected SpringApplicationBuilder configure(SpringApplicationBuilder appication) { | ||||
| 		return appication.sources(Main.class); | ||||
| 	} | ||||
|  | ||||
| 	public static void main(String[] args) { | ||||
| 		SpringApplication.run(Main.class, args); | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,40 @@ | ||||
| package de.jottyfan.camporganizer.config; | ||||
|  | ||||
| import javax.sql.DataSource; | ||||
|  | ||||
| import org.jooq.SQLDialect; | ||||
| import org.jooq.impl.DataSourceConnectionProvider; | ||||
| import org.jooq.impl.DefaultConfiguration; | ||||
| import org.jooq.impl.DefaultDSLContext; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.Configuration; | ||||
| import org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author jotty | ||||
|  * | ||||
|  */ | ||||
| @Configuration | ||||
| public class InitialConfiguration { | ||||
| 	@Autowired | ||||
| 	private DataSource dataSource; | ||||
|  | ||||
| 	@Bean | ||||
| 	public DataSourceConnectionProvider connectionProvider() { | ||||
| 		return new DataSourceConnectionProvider(new TransactionAwareDataSourceProxy(dataSource)); | ||||
| 	} | ||||
|  | ||||
| 	@Bean | ||||
| 	public DefaultDSLContext dsl() { | ||||
| 		return new DefaultDSLContext(configuration()); | ||||
| 	} | ||||
|  | ||||
| 	public DefaultConfiguration configuration() { | ||||
| 		DefaultConfiguration jooqConfiguration = new DefaultConfiguration(); | ||||
| 		jooqConfiguration.set(connectionProvider()); | ||||
| 		jooqConfiguration.set(SQLDialect.POSTGRES); | ||||
| 		return jooqConfiguration; | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,62 @@ | ||||
| package de.jottyfan.camporganizer.config; | ||||
|  | ||||
| import org.keycloak.adapters.springboot.KeycloakSpringBootConfigResolver; | ||||
| import org.keycloak.adapters.springsecurity.KeycloakConfiguration; | ||||
| import org.keycloak.adapters.springsecurity.authentication.KeycloakAuthenticationProvider; | ||||
| import org.keycloak.adapters.springsecurity.config.KeycloakWebSecurityConfigurerAdapter; | ||||
| import org.keycloak.adapters.springsecurity.management.HttpSessionManager; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||||
| import org.springframework.context.annotation.Bean; | ||||
| import org.springframework.context.annotation.ComponentScan; | ||||
| import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; | ||||
| import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; | ||||
| import org.springframework.security.config.annotation.web.builders.HttpSecurity; | ||||
| import org.springframework.security.core.authority.mapping.SimpleAuthorityMapper; | ||||
| import org.springframework.security.core.session.SessionRegistryImpl; | ||||
| import org.springframework.security.web.authentication.session.RegisterSessionAuthenticationStrategy; | ||||
| import org.springframework.security.web.authentication.session.SessionAuthenticationStrategy; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author jotty | ||||
|  * | ||||
|  */ | ||||
| @KeycloakConfiguration | ||||
| @ComponentScan(basePackageClasses = KeycloakSpringBootConfigResolver.class) | ||||
| @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, jsr250Enabled = true) | ||||
| public class SecurityConfig extends KeycloakWebSecurityConfigurerAdapter { | ||||
|  | ||||
| 	@Autowired | ||||
| 	public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception { | ||||
| 		KeycloakAuthenticationProvider keycloakAuthenticationProvider = keycloakAuthenticationProvider(); | ||||
| 		keycloakAuthenticationProvider.setGrantedAuthoritiesMapper(new SimpleAuthorityMapper()); | ||||
| 		auth.authenticationProvider(keycloakAuthenticationProvider); | ||||
| 	} | ||||
|  | ||||
| 	@Bean | ||||
| 	public KeycloakSpringBootConfigResolver KeycloakConfigResolver() { | ||||
| 		return new KeycloakSpringBootConfigResolver(); | ||||
| 	} | ||||
|  | ||||
| 	@Bean | ||||
| 	@Override | ||||
| 	@ConditionalOnMissingBean(HttpSessionManager.class) | ||||
| 	protected HttpSessionManager httpSessionManager() { | ||||
| 		return new HttpSessionManager(); | ||||
| 	} | ||||
|  | ||||
| 	@Bean | ||||
| 	@Override | ||||
| 	protected SessionAuthenticationStrategy sessionAuthenticationStrategy() { | ||||
| 		return new RegisterSessionAuthenticationStrategy(new SessionRegistryImpl()); | ||||
| 	} | ||||
|  | ||||
| 	@Override | ||||
| 	protected void configure(HttpSecurity http) throws Exception { | ||||
| 		super.configure(http); | ||||
| 		http.authorizeRequests().antMatchers("/**").permitAll(); | ||||
| 		http.anonymous().disable(); | ||||
| 		http.csrf().disable(); | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,37 @@ | ||||
| package de.jottyfan.camporganizer.module.common; | ||||
|  | ||||
| import javax.servlet.ServletException; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
|  | ||||
| import org.apache.logging.log4j.LogManager; | ||||
| import org.apache.logging.log4j.Logger; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Controller; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author jotty | ||||
|  * | ||||
|  */ | ||||
| @Controller | ||||
| public class IndexController { | ||||
| 	private static final Logger LOGGER = LogManager.getLogger(IndexController.class); | ||||
|  | ||||
| 	@Autowired | ||||
| 	private HttpServletRequest request; | ||||
|  | ||||
| 	@GetMapping("/") | ||||
| 	public String index() { | ||||
| 		if (request == null) { | ||||
| 			LOGGER.error("request is null"); | ||||
| 		} | ||||
| 		return "/"; | ||||
| 	} | ||||
|  | ||||
| 	@GetMapping("/logout") | ||||
| 	public String getLogout(HttpServletRequest request) throws ServletException { | ||||
| 		request.logout(); | ||||
| 		return "redirect:/"; | ||||
| 	} | ||||
| } | ||||
| @@ -0,0 +1,35 @@ | ||||
| package de.jottyfan.camporganizer.module.common; | ||||
|  | ||||
| import static de.jottyfan.camporganizer.db.jooq.Tables.V_CAMP; | ||||
|  | ||||
| import java.util.stream.Stream; | ||||
|  | ||||
| import org.apache.logging.log4j.LogManager; | ||||
| import org.apache.logging.log4j.Logger; | ||||
| import org.jooq.DSLContext; | ||||
| import org.jooq.SelectWhereStep; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Repository; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
|  | ||||
| import de.jottyfan.camporganizer.db.jooq.tables.records.VCampRecord; | ||||
|  | ||||
| /** | ||||
|  * | ||||
|  * @author jotty | ||||
|  * | ||||
|  */ | ||||
| @Repository | ||||
| @Transactional(transactionManager = "transactionManager") | ||||
| public class IndexGateway { | ||||
| 	private static final Logger LOGGER = LogManager.getLogger(IndexGateway.class); | ||||
|  | ||||
| 	@Autowired | ||||
| 	private DSLContext jooq; | ||||
|  | ||||
| 	public Stream<VCampRecord> getAllCamps() { | ||||
| 		SelectWhereStep<VCampRecord> sql = jooq.selectFrom(V_CAMP); | ||||
| 		LOGGER.debug(sql.toString()); | ||||
| 		return sql.fetchStream(); | ||||
| 	} | ||||
| } | ||||
							
								
								
									
										21
									
								
								src/main/resources/application.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								src/main/resources/application.properties
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| # jooq | ||||
| spring.datasource.driver-class-name=org.postgresql.Driver | ||||
| spring.datasource.url=jdbc:postgresql://localhost:5432/camporganizer | ||||
| spring.datasource.username=jooq | ||||
| spring.datasource.password=jooq | ||||
|  | ||||
| # application | ||||
| server.port = 8081 | ||||
|  | ||||
| server.servlet.context-path=/COBusiness | ||||
|  | ||||
| # keycloak | ||||
| keycloak.auth-server-url = http://localhost:8080/ | ||||
| keycloak.realm = ow | ||||
| keycloak.resource = biblecamp | ||||
| keycloak.public-client = true | ||||
| keycloak.security-constraints[0].authRoles[0] = business | ||||
| keycloak.security-constraints[0].securityCollections[0].patterns[0] = /* | ||||
| #keycloak.credentia | ||||
| keycloak.use-resource-role-mappings=true | ||||
| #keycloak.bearer-only=true | ||||
							
								
								
									
										23
									
								
								src/main/resources/static/js/dataTables.de.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								src/main/resources/static/js/dataTables.de.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,23 @@ | ||||
| var locale_de = { | ||||
| 	"sEmptyTable": "Keine Daten in der Tabelle vorhanden", | ||||
| 	"sInfo": "_START_ bis _END_ von _TOTAL_ Einträgen", | ||||
| 	"sInfoEmpty": "0 bis 0 von 0 Einträgen", | ||||
| 	"sInfoFiltered": "(gefiltert von _MAX_ Einträgen)", | ||||
| 	"sInfoPostFix": "", | ||||
| 	"sInfoThousands": ".", | ||||
| 	"sLengthMenu": "_MENU_ Einträge anzeigen", | ||||
| 	"sLoadingRecords": "Wird geladen...", | ||||
| 	"sProcessing": "Bitte warten...", | ||||
| 	"sSearch": "Suchen", | ||||
| 	"sZeroRecords": "Keine Einträge vorhanden.", | ||||
| 	"oPaginate": { | ||||
| 		"sFirst": "Erste", | ||||
| 		"sPrevious": "Zurück", | ||||
| 		"sNext": "Nächste", | ||||
| 		"sLast": "Letzte" | ||||
| 	}, | ||||
| 	"oAria": { | ||||
| 		"sSortAscending": ": aktivieren, um Spalte aufsteigend zu sortieren", | ||||
| 		"sSortDescending": ": aktivieren, um Spalte absteigend zu sortieren" | ||||
| 	} | ||||
| }; | ||||
		Reference in New Issue
	
	Block a user