Skip to content

Commit 11da7b6

Browse files
Merge pull request #158 from phasenraum2010/milestone-1.0.17
Milestone 1.0.17
2 parents dcc793f + e319fbc commit 11da7b6

File tree

171 files changed

+4149
-2648
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+4149
-2648
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
- export TWITTERWALL_INFO_IMPRINT_SCREEN_NAME=port80guru
4545
- export TWITTERWALL_GOOGLE_ANALYTICS_ID=TWITTERWALL_GOOGLE_ANALYTICS_ID
4646
- export TWITTERWALL_SCHEDULER_USER_LIST_NAME=test-typo3-hibernate-java
47+
- export TWITTERWALL_LOGIN_USERNAME=admin
48+
- export TWITTERWALL_LOGIN_PASSWORD=password
4749

4850
- run with: mvn clean spring-boot:run
4951

pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,10 @@
8080
<groupId>org.springframework.boot</groupId>
8181
<artifactId>spring-boot-starter-integration</artifactId>
8282
</dependency>
83-
<!--
8483
<dependency>
8584
<groupId>org.springframework.boot</groupId>
8685
<artifactId>spring-boot-starter-security</artifactId>
8786
</dependency>
88-
-->
8987
<dependency>
9088
<groupId>org.springframework.boot</groupId>
9189
<artifactId>spring-boot-starter-mobile</artifactId>
@@ -113,6 +111,10 @@
113111
<artifactId>spring-boot-configuration-processor</artifactId>
114112
<optional>true</optional>
115113
</dependency>
114+
<dependency>
115+
<groupId>org.thymeleaf.extras</groupId>
116+
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
117+
</dependency>
116118
<dependency>
117119
<groupId>org.yaml</groupId>
118120
<artifactId>snakeyaml</artifactId>

src/main/java/org/woehlke/twitterwall/Application.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import org.springframework.context.annotation.ImportResource;
88
import org.springframework.data.web.config.EnableSpringDataWebSupport;
99
import org.springframework.scheduling.annotation.EnableScheduling;
10-
import org.woehlke.twitterwall.conf.TwitterProperties;
11-
import org.woehlke.twitterwall.conf.TwitterwallBackendProperties;
12-
import org.woehlke.twitterwall.conf.TwitterwallFrontendProperties;
13-
import org.woehlke.twitterwall.conf.TwitterwallSchedulerProperties;
10+
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
11+
import org.woehlke.twitterwall.conf.properties.BackendProperties;
12+
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
13+
import org.woehlke.twitterwall.conf.properties.SchedulerProperties;
1414

1515

1616
/**
@@ -19,9 +19,9 @@
1919
@EnableScheduling
2020
@SpringBootApplication
2121
@EnableConfigurationProperties({
22-
TwitterwallBackendProperties.class,
23-
TwitterwallFrontendProperties.class,
24-
TwitterwallSchedulerProperties.class,
22+
BackendProperties.class,
23+
FrontendProperties.class,
24+
SchedulerProperties.class,
2525
TwitterProperties.class
2626
})
2727
@EnableSpringDataWebSupport

src/main/java/org/woehlke/twitterwall/ScheduledTasks.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import org.springframework.stereotype.Service;
88
import org.springframework.transaction.annotation.Propagation;
99
import org.springframework.transaction.annotation.Transactional;
10-
import org.woehlke.twitterwall.conf.TwitterwallSchedulerProperties;
10+
import org.woehlke.twitterwall.conf.properties.SchedulerProperties;
1111
import org.woehlke.twitterwall.scheduled.mq.endoint.StartTask;
1212

1313
/**
@@ -20,46 +20,46 @@ public class ScheduledTasks {
2020
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_TWEETS)
2121
public void fetchTweetsFromTwitterSearch() {
2222
String msg = "fetch Tweets From TwitterSearch ";
23-
if(twitterwallSchedulerProperties.getAllowUpdateTweets() && !twitterwallSchedulerProperties.getSkipFortesting()) {
23+
if(schedulerProperties.getAllowUpdateTweets() && !schedulerProperties.getSkipFortesting()) {
2424
startTask.fetchTweetsFromTwitterSearch();
2525
}
2626
}
2727

2828
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_TWEETS)
2929
public void updateTweets() {
3030
String msg = "update Tweets ";
31-
if(twitterwallSchedulerProperties.getAllowUpdateTweets() && !twitterwallSchedulerProperties.getSkipFortesting()){
31+
if(schedulerProperties.getAllowUpdateTweets() && !schedulerProperties.getSkipFortesting()){
3232
startTask.updateTweets();
3333
}
3434
}
3535

3636
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER)
3737
public void updateUserProfiles() {
3838
String msg = "update User Profiles ";
39-
if(twitterwallSchedulerProperties.getAllowUpdateUserProfiles() && !twitterwallSchedulerProperties.getSkipFortesting()) {
39+
if(schedulerProperties.getAllowUpdateUserProfiles() && !schedulerProperties.getSkipFortesting()) {
4040
startTask.updateUserProfiles();
4141
}
4242
}
4343

4444
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_UPDATE_USER_BY_MENTION)
4545
public void updateUserProfilesFromMentions(){
4646
String msg = "update User Profiles From Mentions";
47-
if(twitterwallSchedulerProperties.getAllowUpdateUserProfilesFromMention() && !twitterwallSchedulerProperties.getSkipFortesting()) {
47+
if(schedulerProperties.getAllowUpdateUserProfilesFromMention() && !schedulerProperties.getSkipFortesting()) {
4848
startTask.updateUserProfilesFromMentions();
4949
}
5050
}
5151

5252
@Scheduled(fixedRate = FIXED_RATE_FOR_SCHEDULAR_FETCH_USER_LIST)
5353
public void fetchUsersFromDefinedUserList(){
5454
String msg = "fetch Users from Defined User List ";
55-
if(twitterwallSchedulerProperties.getFetchUserList().getAllow() && !twitterwallSchedulerProperties.getSkipFortesting()) {
55+
if(schedulerProperties.getFetchUserList().getAllow() && !schedulerProperties.getSkipFortesting()) {
5656
startTask.fetchUsersFromDefinedUserList();
5757
}
5858
}
5959

6060
@Autowired
61-
public ScheduledTasks(TwitterwallSchedulerProperties twitterwallSchedulerProperties, StartTask startTask) {
62-
this.twitterwallSchedulerProperties = twitterwallSchedulerProperties;
61+
public ScheduledTasks(SchedulerProperties schedulerProperties, StartTask startTask) {
62+
this.schedulerProperties = schedulerProperties;
6363
this.startTask = startTask;
6464
}
6565

@@ -83,7 +83,7 @@ public ScheduledTasks(TwitterwallSchedulerProperties twitterwallSchedulerPropert
8383

8484
private static final Logger log = LoggerFactory.getLogger(ScheduledTasks.class);
8585

86-
private final TwitterwallSchedulerProperties twitterwallSchedulerProperties;
86+
private final SchedulerProperties schedulerProperties;
8787

8888
private final StartTask startTask;
8989
}

src/main/java/org/woehlke/twitterwall/conf/DataSourceConf.java renamed to src/main/java/org/woehlke/twitterwall/conf/DataSourceConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*/
1515
@Configuration
1616
@EnableJpaRepositories("org.woehlke.twitterwall.oodm.repositories")
17-
public class DataSourceConf {
17+
public class DataSourceConfig {
1818

1919
@Bean
2020
@Primary
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package org.woehlke.twitterwall.conf;
2+
3+
4+
import org.springframework.context.annotation.Configuration;
5+
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
6+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
7+
8+
@Configuration
9+
public class WebMvcConfig extends WebMvcConfigurerAdapter {
10+
11+
@Override
12+
public void addViewControllers(ViewControllerRegistry registry) {
13+
registry.addViewController("/adm").setViewName("redirect:/application/management");
14+
registry.addViewController("/").setViewName("redirect:/tweet/all");
15+
}
16+
17+
}
18+
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package org.woehlke.twitterwall.conf;
2+
3+
4+
import org.springframework.beans.factory.annotation.Autowired;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
7+
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
8+
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
9+
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
10+
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
11+
12+
@Configuration
13+
@EnableWebSecurity
14+
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
15+
16+
@Override
17+
protected void configure(HttpSecurity http) throws Exception {
18+
http
19+
.authorizeRequests()
20+
.antMatchers(
21+
"/",
22+
"/tweet/all",
23+
"/user/*",
24+
"/user/screenName/*",
25+
"/user/list/tweets",
26+
"/hashtag/overview",
27+
"/hashtag/*",
28+
"/hashtag/text/*",
29+
"/imprint",
30+
"/css/*","/css/**",
31+
"/favicon/*","/favicon/**",
32+
"/js/*","/js/**",
33+
"/map-icons/*","/map-icons/**",
34+
"/webjars/*","/webjars/**"
35+
).permitAll()
36+
.anyRequest().authenticated()
37+
.and()
38+
.formLogin()
39+
.loginPage("/login")
40+
.permitAll()
41+
.and()
42+
.logout()
43+
.logoutSuccessUrl("/")
44+
.permitAll();
45+
}
46+
47+
@Autowired
48+
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
49+
String user = frontendProperties.getLoginUsername();
50+
String pwd = frontendProperties.getLoginPassword();
51+
String role = "USER";
52+
auth
53+
.inMemoryAuthentication()
54+
.withUser(user).password(pwd).roles(role);
55+
}
56+
57+
@Autowired
58+
public WebSecurityConfig(FrontendProperties frontendProperties) {
59+
this.frontendProperties = frontendProperties;
60+
}
61+
62+
private final FrontendProperties frontendProperties;
63+
}

src/main/java/org/woehlke/twitterwall/conf/TwitterwallBackendProperties.java renamed to src/main/java/org/woehlke/twitterwall/conf/properties/BackendProperties.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.woehlke.twitterwall.conf;
1+
package org.woehlke.twitterwall.conf.properties;
22

33

44
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -12,7 +12,7 @@
1212
@Component
1313
@Validated
1414
@ConfigurationProperties(prefix="twitterwall.backend")
15-
public class TwitterwallBackendProperties {
15+
public class BackendProperties {
1616

1717
@Valid
1818
public Twitter twitter = new Twitter();

src/main/java/org/woehlke/twitterwall/conf/TwitterwallFrontendProperties.java renamed to src/main/java/org/woehlke/twitterwall/conf/properties/FrontendProperties.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.woehlke.twitterwall.conf;
1+
package org.woehlke.twitterwall.conf.properties;
22

33

44
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -11,7 +11,7 @@
1111
@Component
1212
@Validated
1313
@ConfigurationProperties(prefix="twitterwall.frontend")
14-
public class TwitterwallFrontendProperties {
14+
public class FrontendProperties {
1515

1616
@NotNull
1717
private String idGoogleAnalytics;
@@ -37,6 +37,12 @@ public class TwitterwallFrontendProperties {
3737
@NotNull
3838
private Integer pageSize;
3939

40+
@NotNull
41+
private String loginUsername;
42+
43+
@NotNull
44+
private String loginPassword;
45+
4046
@Valid
4147
private Controller controller = new Controller();
4248

@@ -125,4 +131,20 @@ public Integer getPageSize() {
125131
public void setPageSize(Integer pageSize) {
126132
this.pageSize = pageSize;
127133
}
134+
135+
public String getLoginUsername() {
136+
return loginUsername;
137+
}
138+
139+
public void setLoginUsername(String loginUsername) {
140+
this.loginUsername = loginUsername;
141+
}
142+
143+
public String getLoginPassword() {
144+
return loginPassword;
145+
}
146+
147+
public void setLoginPassword(String loginPassword) {
148+
this.loginPassword = loginPassword;
149+
}
128150
}

src/main/java/org/woehlke/twitterwall/conf/TwitterwallSchedulerProperties.java renamed to src/main/java/org/woehlke/twitterwall/conf/properties/SchedulerProperties.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.woehlke.twitterwall.conf;
1+
package org.woehlke.twitterwall.conf.properties;
22

33

44
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -13,7 +13,7 @@
1313
@Component
1414
@Validated
1515
@ConfigurationProperties(prefix="twitterwall.scheduler")
16-
public class TwitterwallSchedulerProperties {
16+
public class SchedulerProperties {
1717

1818
@NotNull
1919
private Boolean allowFetchTweetsFromTwitterSearch;

0 commit comments

Comments
 (0)