mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
apply formatter
This commit is contained in:
@@ -49,15 +49,12 @@ import com.commafeed.frontend.utils.exception.DisplayExceptionPage;
|
||||
|
||||
public class CommaFeedApplication extends AuthenticatedWebApplication {
|
||||
|
||||
private static Logger log = LoggerFactory
|
||||
.getLogger(CommaFeedApplication.class);
|
||||
private static Logger log = LoggerFactory.getLogger(CommaFeedApplication.class);
|
||||
|
||||
public CommaFeedApplication() {
|
||||
super();
|
||||
String prod = ResourceBundle.getBundle("application").getString(
|
||||
"production");
|
||||
setConfigurationType(Boolean.valueOf(prod) ? RuntimeConfigurationType.DEPLOYMENT
|
||||
: RuntimeConfigurationType.DEVELOPMENT);
|
||||
String prod = ResourceBundle.getBundle("application").getString("production");
|
||||
setConfigurationType(Boolean.valueOf(prod) ? RuntimeConfigurationType.DEPLOYMENT : RuntimeConfigurationType.DEVELOPMENT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,16 +63,16 @@ public class CommaFeedApplication extends AuthenticatedWebApplication {
|
||||
|
||||
mountPage("welcome", WelcomePage.class);
|
||||
mountPage("demo", DemoLoginPage.class);
|
||||
|
||||
|
||||
mountPage("recover", PasswordRecoveryPage.class);
|
||||
mountPage("recover2", PasswordRecoveryCallbackPage.class);
|
||||
|
||||
|
||||
mountPage("logout", LogoutPage.class);
|
||||
mountPage("error", DisplayExceptionPage.class);
|
||||
|
||||
// mountPage("google/import/redirect", GoogleImportRedirectPage.class);
|
||||
// mountPage(GoogleImportCallbackPage.PAGE_PATH,
|
||||
// GoogleImportCallbackPage.class);
|
||||
|
||||
// mountPage("google/import/redirect", GoogleImportRedirectPage.class);
|
||||
// mountPage(GoogleImportCallbackPage.PAGE_PATH,
|
||||
// GoogleImportCallbackPage.class);
|
||||
|
||||
mountPage("next", NextUnreadRedirectPage.class);
|
||||
|
||||
@@ -89,8 +86,7 @@ public class CommaFeedApplication extends AuthenticatedWebApplication {
|
||||
setHeaderResponseDecorator(new IHeaderResponseDecorator() {
|
||||
@Override
|
||||
public IHeaderResponse decorate(IHeaderResponse response) {
|
||||
return new JavaScriptFilteredIntoFooterHeaderResponse(response,
|
||||
"footer-container");
|
||||
return new JavaScriptFilteredIntoFooterHeaderResponse(response, "footer-container");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -100,61 +96,52 @@ public class CommaFeedApplication extends AuthenticatedWebApplication {
|
||||
AjaxRequestTarget target = cycle.find(AjaxRequestTarget.class);
|
||||
// redirect to the error page if ajax request, render error on
|
||||
// current page otherwise
|
||||
RedirectPolicy policy = target == null ? RedirectPolicy.NEVER_REDIRECT
|
||||
: RedirectPolicy.AUTO_REDIRECT;
|
||||
return new RenderPageRequestHandler(new PageProvider(
|
||||
new DisplayExceptionPage(ex)), policy);
|
||||
RedirectPolicy policy = target == null ? RedirectPolicy.NEVER_REDIRECT : RedirectPolicy.AUTO_REDIRECT;
|
||||
return new RenderPageRequestHandler(new PageProvider(new DisplayExceptionPage(ex)), policy);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setupSecurity() {
|
||||
getSecuritySettings().setAuthenticationStrategy(
|
||||
new DefaultAuthenticationStrategy("LoggedIn") {
|
||||
getSecuritySettings().setAuthenticationStrategy(new DefaultAuthenticationStrategy("LoggedIn") {
|
||||
|
||||
private CookieUtils cookieUtils = null;
|
||||
private CookieUtils cookieUtils = null;
|
||||
|
||||
@Override
|
||||
protected CookieUtils getCookieUtils() {
|
||||
@Override
|
||||
protected CookieUtils getCookieUtils() {
|
||||
|
||||
if (cookieUtils == null) {
|
||||
cookieUtils = new CookieUtils() {
|
||||
@Override
|
||||
protected void initializeCookie(Cookie cookie) {
|
||||
super.initializeCookie(cookie);
|
||||
cookie.setHttpOnly(true);
|
||||
}
|
||||
};
|
||||
if (cookieUtils == null) {
|
||||
cookieUtils = new CookieUtils() {
|
||||
@Override
|
||||
protected void initializeCookie(Cookie cookie) {
|
||||
super.initializeCookie(cookie);
|
||||
cookie.setHttpOnly(true);
|
||||
}
|
||||
return cookieUtils;
|
||||
}
|
||||
});
|
||||
getSecuritySettings().setAuthorizationStrategy(
|
||||
new IAuthorizationStrategy() {
|
||||
};
|
||||
}
|
||||
return cookieUtils;
|
||||
}
|
||||
});
|
||||
getSecuritySettings().setAuthorizationStrategy(new IAuthorizationStrategy() {
|
||||
|
||||
@Override
|
||||
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(
|
||||
Class<T> componentClass) {
|
||||
boolean authorized = true;
|
||||
@Override
|
||||
public <T extends IRequestableComponent> boolean isInstantiationAuthorized(Class<T> componentClass) {
|
||||
boolean authorized = true;
|
||||
|
||||
boolean restricted = componentClass
|
||||
.isAnnotationPresent(SecurityCheck.class);
|
||||
if (restricted) {
|
||||
SecurityCheck annotation = componentClass
|
||||
.getAnnotation(SecurityCheck.class);
|
||||
Roles roles = CommaFeedSession.get().getRoles();
|
||||
authorized = roles.hasAnyRole(new Roles(annotation
|
||||
.value().name()));
|
||||
}
|
||||
return authorized;
|
||||
}
|
||||
boolean restricted = componentClass.isAnnotationPresent(SecurityCheck.class);
|
||||
if (restricted) {
|
||||
SecurityCheck annotation = componentClass.getAnnotation(SecurityCheck.class);
|
||||
Roles roles = CommaFeedSession.get().getRoles();
|
||||
authorized = roles.hasAnyRole(new Roles(annotation.value().name()));
|
||||
}
|
||||
return authorized;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActionAuthorized(Component component,
|
||||
Action action) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public boolean isActionAuthorized(Component component, Action action) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -164,10 +151,8 @@ public class CommaFeedApplication extends AuthenticatedWebApplication {
|
||||
|
||||
protected void setupInjection() {
|
||||
try {
|
||||
BeanManager beanManager = (BeanManager) new InitialContext()
|
||||
.lookup("java:comp/BeanManager");
|
||||
new CdiConfiguration(beanManager).setPropagation(
|
||||
ConversationPropagation.NONE).configure(this);
|
||||
BeanManager beanManager = (BeanManager) new InitialContext().lookup("java:comp/BeanManager");
|
||||
new CdiConfiguration(beanManager).setPropagation(ConversationPropagation.NONE).configure(this);
|
||||
} catch (NamingException e) {
|
||||
log.warn("Could not locate bean manager. CDI is disabled.");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user