This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Controller | |
public class MyController { | |
@Secured(admin = true) | |
@RequestMapping(value="/show_users.html", method = RequestMethod.GET) | |
public String showAllUsers(Model model) { | |
... | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Target({ ElementType.METHOD }) | |
@Retention(RetentionPolicy.RUNTIME) | |
@Inherited | |
@Documented | |
public @interface Secured { | |
Boolean admin() default false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Aspect | |
@Component | |
public class SecuredAspect { | |
@Pointcut("@annotation(annotation)") | |
@SuppressWarnings("unused") | |
private void secured(Secured annotation) { | |
} | |
@Around("secured(annotation)") | |
public Object aroundCachedMethods(ProceedingJoinPoint thisJoinPoint, Secured annotation) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans> | |
... | |
<bean class="security.SecurityAspect" /> | |
<aop:aspectj-autoproxy /> | |
</beans> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<beans> | |
... | |
<bean id="jangodConf" | |
class="org.springframework.web.servlet.view.jangod.JangodConfigurer"> | |
<property name="configurationFile" value="jangod.config.properties" /> | |
</bean> | |
<bean class="org.springframework.web.servlet.view.jangod.JangodViewResolver"> | |
<property name="jangodConfig" ref="jangodConf" /> | |
<property name="prefix" value="/WEB-INF/views" /> | |
<property name="suffix" value=".html" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "base.html" %} | |
{% block content %} | |
<div id="part-content"> | |
{% if posts %} | |
{% for post in posts %} | |
<div id="post-{{post.id}}" class="post-home"> | |
<div class="post-title"> | |
<h1><a href="{{post.link}}" rel="bookmark">{{post.title}}</a></h1> | |
</div> | |
<div class="post-content">{{post.preview}}</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<web-app> | |
... | |
<servlet> | |
<servlet-name>dispatcher</servlet-name> | |
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | |
<init-param> | |
<param-name>spring.profiles.active</param-name> | |
<param-value>production</param-value> | |
</init-param> | |
</servlet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo.bar; | |
import org.springframework.context.ApplicationContextInitializer; | |
import org.springframework.context.ConfigurableApplicationContext; | |
import org.springframework.core.env.ConfigurableEnvironment; | |
public class MyContextInitializer implements | |
ApplicationContextInitializer<ConfigurableApplicationContext> { | |
private static final String PROP = "com.google.appengine.runtime.environment"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<web-app> | |
.. | |
<servlet> | |
<servlet-name>dispatcher</servlet-name> | |
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> | |
<init-param> | |
<param-name>contextInitializerClasses</param-name> | |
<param-value>foo.bar.MyContextInitializer</param-value> | |
</init-param> | |
</servlet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package foo.bar; | |
import org.springframework.context.ApplicationContextInitializer; | |
import org.springframework.context.ConfigurableApplicationContext; | |
import org.springframework.core.env.ConfigurableEnvironment; | |
public class MyContextInitializer implements ApplicationContextInitializer<ConfigurableApplicationContext> { | |
public void initialize(ConfigurableApplicationContext applicationContext) { | |
ConfigurableEnvironment springEnvironment = applicationContext.getEnvironment(); |
OlderNewer