CCM NG: Today's result of getting Bebop running in a full Java EE environement

git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@3842 8810af33-2d31-482b-a856-94f89814c4df
pull/2/head
jensp 2016-02-04 14:47:05 +00:00
parent 4527595438
commit c21ab1e5d7
5 changed files with 167 additions and 56 deletions

View File

@ -0,0 +1,65 @@
# -*- text -*-
# This file locates stylesheets, if you are using the
# "PatternStylesheetResolver". Please read the Javadoc for that file for
# the full story.
# Currently the "resource" part is actually "short-circuited", see
# Templating#transformURL(url). As long as we store and synchronize all theme
# files in each server's local file system, we use the direct file apprach to
# avoid unnecessary http request and traffic between client (user) and server!
# Additionally all modules are installed into one webapp context, so the
# webapp tag is redundant, but sort of required by some part of the code.
# Theme with single entry point (e.g Mandalay) managed by themedirector
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/start.xsl
http://::host::/::webapp::/themes/::themedir::/::theme::/start.xsl
# Theme with single entry point (e.g Mandalay) unmanaged default
#http://::host::/resource/::webapp::/themes/mandalay/start.xsl
#http://::host::/::webapp::/themes/mandalay/start.xsl
# Theme with single entry point (e.g Mandalay) unmanaged default
#http://::host::/resource/::webapp::/themes/mandalay/start.xsl
http://::host::/::webapp::/themes/foundry-base/start.xsl
# ==============================================================================
# The following is for multi-entry themes, not used in ScientificCMS
# ==============================================================================
# Output type is for things such as text/javascript
# NOT used by ScientificCMS, uses Mandalay only!
#http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::-::outputtype::-::locale::.xsl
#http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::-::outputtype::.xsl
# Grabs custom item xsl for CMS
# NOT used by ScientificCMS, uses Mandalay only!
#http://::host::/themes/servlet/content-item/index.xsl?oid=::item_template_oid::&delegated=::item_delegated_url::
# Theme, with optional locale & prefix
# NOT used by ScientificCMS, uses Mandalay only!
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/::application::-::url::-::prefix::-::locale::.xsl
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/::application::-::url::-::prefix::.xsl
# Theme, with optional locale
# NOT used by ScientificCMS, uses Mandalay only!
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/::application::-::url::-::locale::.xsl
#http://::host::/resource/::webapp::/themes/::themedir::/::theme::/::application::-::url::.xsl
# APLAWS generic default, with locale and prefix
# XXX change ROOT -> ccm-ldn-aplaws
# http://::host::/resource/ROOT/themes/static/aplaws-generic/::application::-::url::-::prefix::-::locale::.xsl
# http://::host::/resource/ROOT/themes/static/aplaws-generic/::application::-::url::-::prefix::.xsl
# APLAWS generic default, with locale
# XXX change ROOT -> ccm-ldn-aplaws
# http://::host::/resource/ROOT/themes/static/aplaws-generic/::application::-::url::-::locale::.xsl
# http://::host::/resource/ROOT/themes/static/aplaws-generic/::application::-::url::.xsl
# Global default, from application's own web app
# NOT used by ScientificCMS
#http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::-::locale::.xsl
#http://::host::/resource/::webapp::/themes/heirloom/apps/::application::/xsl/::url::.xsl

View File

@ -399,8 +399,8 @@ public class PatternStylesheetResolver implements StylesheetResolver {
try { try {
// Read the source file. // Read the source file.
ClassLoader cload = Thread.currentThread().getContextClassLoader(); ClassLoader cload = Thread.currentThread().getContextClassLoader();
InputStream stream = cload.getResourceAsStream(path.substring(1)); InputStream stream = cload.getResourceAsStream(path.substring(0));
s_log.debug("got stream using path " + path.substring(1)); s_log.debug("got stream using path " + path.substring(0));
s_log.debug("stream.available is " + stream.available()); s_log.debug("stream.available is " + stream.available());
m_paths = new ArrayList(); m_paths = new ArrayList();

View File

@ -31,20 +31,21 @@ import com.arsdigita.web.LoginSignal;
import com.arsdigita.xml.Document; import com.arsdigita.xml.Document;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.libreccm.cdi.utils.CdiUtil;
import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.security.PermissionChecker; import org.libreccm.security.PermissionChecker;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
import java.io.IOException; import java.io.IOException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.enterprise.inject.spi.CDI;
import javax.inject.Inject;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet; import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import
javax.servlet.http.HttpServletResponse;
import org.libreccm.cdi.utils.CdiUtil;
import static com.arsdigita.ui.admin.AdminConstants.*; import static com.arsdigita.ui.admin.AdminConstants.*;
@ -111,7 +112,8 @@ public class AdminServlet
// /////// Some preparational steps /////////////// // /////// Some preparational steps ///////////////
/* Determine access privilege: only logged in users may access */ /* Determine access privilege: only logged in users may access */
final CdiUtil cdiUtil = new CdiUtil(); final CdiUtil cdiUtil = new CdiUtil();
final Subject subject = cdiUtil.findBean(Subject.class); // final Subject subject = cdiUtil.findBean(Subject.class);
final Subject subject = CDI.current().select(Subject.class).get();
final PermissionChecker permissionChecker = cdiUtil.findBean( final PermissionChecker permissionChecker = cdiUtil.findBean(
PermissionChecker.class); PermissionChecker.class);

View File

@ -45,6 +45,7 @@ import com.arsdigita.bebop.parameters.URLParameter;
import com.arsdigita.kernel.KernelConfig; import com.arsdigita.kernel.KernelConfig;
import com.arsdigita.kernel.security.SecurityConfig; import com.arsdigita.kernel.security.SecurityConfig;
import com.arsdigita.ui.UI; import com.arsdigita.ui.UI;
import com.arsdigita.util.UncheckedWrapperException;
import static com.arsdigita.ui.login.LoginConstants.*; import static com.arsdigita.ui.login.LoginConstants.*;
@ -52,6 +53,12 @@ import com.arsdigita.web.ParameterMap;
import com.arsdigita.web.RedirectSignal; import com.arsdigita.web.RedirectSignal;
import com.arsdigita.web.ReturnSignal; import com.arsdigita.web.ReturnSignal;
import com.arsdigita.web.URL; import com.arsdigita.web.URL;
import java.util.Iterator;
import java.util.Set;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.CDI;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -61,6 +68,7 @@ import org.apache.shiro.authc.UsernamePasswordToken;
import org.libreccm.cdi.utils.CdiUtil; import org.libreccm.cdi.utils.CdiUtil;
import org.apache.shiro.subject.Subject; import org.apache.shiro.subject.Subject;
import org.libreccm.configuration.ConfigurationManager;
/** /**
* A Bebop form that accepts login and password from the user and attempts to * A Bebop form that accepts login and password from the user and attempts to
@ -128,14 +136,34 @@ public class UserLoginForm extends Form implements LoginConstants,
final boolean autoRegistrationOn) { final boolean autoRegistrationOn) {
super(FORM_NAME, panel); super(FORM_NAME, panel);
securityConfig = SecurityConfig.getConfig(); // final ConfigurationManager confManager = CDI.current().select(
// ConfigurationManager.class).get();
final BeanManager beanManager = CDI.current().getBeanManager();
final Set<Bean<?>> beans = beanManager.getBeans(
ConfigurationManager.class);
final Iterator<Bean<?>> iterator = beans.iterator();
final ConfigurationManager confManager;
if (iterator.hasNext()) {
final Bean<ConfigurationManager> bean = (Bean<ConfigurationManager>) iterator.
next();
final CreationalContext<ConfigurationManager> ctx = beanManager.
createCreationalContext(bean);
confManager = (ConfigurationManager) beanManager.getReference(
bean, ConfigurationManager.class, ctx);
} else {
throw new UncheckedWrapperException(
"Failed to lookup ConfigurationManager");
}
securityConfig = confManager.findConfiguration(SecurityConfig.class);
setMethod(Form.POST); setMethod(Form.POST);
addInitListener(this); addInitListener(this);
addValidationListener(this); addValidationListener(this);
addProcessListener(this); addProcessListener(this);
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = confManager.findConfiguration(
KernelConfig.class);
m_autoRegistrationOn = autoRegistrationOn; m_autoRegistrationOn = autoRegistrationOn;
@ -143,14 +171,14 @@ public class UserLoginForm extends Form implements LoginConstants,
add(m_timestamp); add(m_timestamp);
m_returnURL = new Hidden(new URLParameter( m_returnURL = new Hidden(new URLParameter(
LoginHelper.RETURN_URL_PARAM_NAME)); LoginHelper.RETURN_URL_PARAM_NAME));
m_returnURL.setPassIn(true); m_returnURL.setPassIn(true);
add(m_returnURL); add(m_returnURL);
setupLogin(); setupLogin();
add(new Label(LoginHelper.getMessage( add(new Label(LoginHelper.getMessage(
"login.userRegistrationForm.password"))); "login.userRegistrationForm.password")));
m_password = new Password(new StringParameter(FORM_PASSWORD)); m_password = new Password(new StringParameter(FORM_PASSWORD));
// Since new users should not enter a password, allow null. // Since new users should not enter a password, allow null.
//m_password.addValidationListener(new NotNullValidationListener()); //m_password.addValidationListener(new NotNullValidationListener());
@ -159,7 +187,7 @@ public class UserLoginForm extends Form implements LoginConstants,
SimpleContainer cookiePanel = new BoxPanel(BoxPanel.HORIZONTAL); SimpleContainer cookiePanel = new BoxPanel(BoxPanel.HORIZONTAL);
m_isPersistent = new CheckboxGroup(FORM_PERSISTENT_LOGIN_P); m_isPersistent = new CheckboxGroup(FORM_PERSISTENT_LOGIN_P);
Label optLabel = new Label(LoginHelper.getMessage( Label optLabel = new Label(LoginHelper.getMessage(
"login.userRegistrationForm.cookieOption")); "login.userRegistrationForm.cookieOption"));
Option opt = new Option(FORM_PERSISTENT_LOGIN_P_DEFAULT, optLabel); Option opt = new Option(FORM_PERSISTENT_LOGIN_P_DEFAULT, optLabel);
m_isPersistent.addOption(opt); m_isPersistent.addOption(opt);
if (kernelConfig.isRememberLoginEnabled()) { if (kernelConfig.isRememberLoginEnabled()) {
@ -168,8 +196,8 @@ public class UserLoginForm extends Form implements LoginConstants,
cookiePanel.add(m_isPersistent); cookiePanel.add(m_isPersistent);
cookiePanel.add(new DynamicLink( cookiePanel.add(new DynamicLink(
"login.userRegistrationForm.explainCookieLink", "login.userRegistrationForm.explainCookieLink",
LoginServlet.getCookiesExplainPageURL())); LoginServlet.getCookiesExplainPageURL()));
add(cookiePanel); add(cookiePanel);
add(new Submit(SUBMIT), ColumnPanel.CENTER | ColumnPanel.FULL_WIDTH); add(new Submit(SUBMIT), ColumnPanel.CENTER | ColumnPanel.FULL_WIDTH);
@ -193,8 +221,8 @@ public class UserLoginForm extends Form implements LoginConstants,
*/ */
private void setupLogin() { private void setupLogin() {
SimpleContainer loginMessage = new SimpleContainer( SimpleContainer loginMessage = new SimpleContainer(
"subsite:loginPromptMsg", "subsite:loginPromptMsg",
LoginServlet.SUBSITE_NS_URI); LoginServlet.SUBSITE_NS_URI);
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
@ -208,17 +236,17 @@ public class UserLoginForm extends Form implements LoginConstants,
if (kernelConfig.emailIsPrimaryIdentifier()) { if (kernelConfig.emailIsPrimaryIdentifier()) {
add(new Label(LoginHelper.getMessage( add(new Label(LoginHelper.getMessage(
"login.userRegistrationForm.email"))); "login.userRegistrationForm.email")));
m_loginName = new TextField(new EmailParameter(FORM_LOGIN)); m_loginName = new TextField(new EmailParameter(FORM_LOGIN));
addInitListener(new EmailInitListener((EmailParameter) m_loginName. addInitListener(new EmailInitListener((EmailParameter) m_loginName.
getParameterModel())); getParameterModel()));
} else { } else {
add(new Label(LoginHelper.getMessage( add(new Label(LoginHelper.getMessage(
"login.userRegistrationForm.screenName"))); "login.userRegistrationForm.screenName")));
m_loginName = new TextField(new StringParameter(FORM_LOGIN)); m_loginName = new TextField(new StringParameter(FORM_LOGIN));
addInitListener(new ScreenNameInitListener( addInitListener(new ScreenNameInitListener(
(StringParameter) m_loginName. (StringParameter) m_loginName.
getParameterModel())); getParameterModel()));
} }
m_loginName.addValidationListener(new NotNullValidationListener()); m_loginName.addValidationListener(new NotNullValidationListener());
add(m_loginName); add(m_loginName);
@ -232,7 +260,7 @@ public class UserLoginForm extends Form implements LoginConstants,
*/ */
@Override @Override
public void init(FormSectionEvent event) public void init(FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
s_log.info("In init"); s_log.info("In init");
final KernelConfig kernelConfig = KernelConfig.getConfig(); final KernelConfig kernelConfig = KernelConfig.getConfig();
@ -242,7 +270,7 @@ public class UserLoginForm extends Form implements LoginConstants,
s_log.info("trying SSO"); s_log.info("trying SSO");
// try { // try {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
"SSO currently not supported"); "SSO currently not supported");
// Web.getUserContext().loginSSO(); // Web.getUserContext().loginSSO();
// s_log.info("loginSSO ok, now processing redirect_url"); // s_log.info("loginSSO ok, now processing redirect_url");
// process(event); // process(event);
@ -273,7 +301,7 @@ public class UserLoginForm extends Form implements LoginConstants,
*/ */
@Override @Override
public void validate(FormSectionEvent event) public void validate(FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
s_log.debug("In validate"); s_log.debug("In validate");
@ -312,7 +340,7 @@ public class UserLoginForm extends Form implements LoginConstants,
*/ */
@Override @Override
public void process(final FormSectionEvent event) public void process(final FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
s_log.debug("In process"); s_log.debug("In process");
final PageState state = event.getPageState(); final PageState state = event.getPageState();
@ -338,15 +366,15 @@ public class UserLoginForm extends Form implements LoginConstants,
* *
*/ */
protected void loginUser(final FormSectionEvent event) protected void loginUser(final FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
PageState state = event.getPageState(); PageState state = event.getPageState();
final CdiUtil cdiUtil = new CdiUtil(); final CdiUtil cdiUtil = new CdiUtil();
final Subject subject = cdiUtil.findBean(Subject.class); final Subject subject = cdiUtil.findBean(Subject.class);
final UsernamePasswordToken token = new UsernamePasswordToken( final UsernamePasswordToken token = new UsernamePasswordToken(
(String) m_loginName.getValue(state), (String) m_loginName.getValue(state),
(String) m_password.getValue(state) (String) m_password.getValue(state)
); );
token.setRememberMe(getPersistentLoginValue(state, false)); token.setRememberMe(getPersistentLoginValue(state, false));
try { try {
@ -365,7 +393,7 @@ public class UserLoginForm extends Form implements LoginConstants,
* *
*/ */
protected void onLoginSuccess(final FormSectionEvent event) protected void onLoginSuccess(final FormSectionEvent event)
throws FormProcessException { throws FormProcessException {
// do nothing // do nothing
} }
@ -394,7 +422,7 @@ public class UserLoginForm extends Form implements LoginConstants,
*/ */
protected void onLoginFail(final FormSectionEvent event, protected void onLoginFail(final FormSectionEvent event,
final AuthenticationException ex) final AuthenticationException ex)
throws FormProcessException { throws FormProcessException {
s_log.debug("Login fail"); s_log.debug("Login fail");
event.getFormData().addError(ERROR_LOGIN_FAIL); event.getFormData().addError(ERROR_LOGIN_FAIL);
} }

View File

@ -19,30 +19,34 @@
package com.arsdigita.util; package com.arsdigita.util;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
/** /**
* Provides the system name of the CCM Spin off (eg aplaws or ScientificCMS) and the version number. * Provides the system name of the CCM Spin off (eg aplaws or ScientificCMS) and
* It's primary use is to provide the theme engine with that information for display. The data * the version number. It's primary use is to provide the theme engine with that
* displayed is stored in the /WEB-INF/systeminformation.properties, which is usually provided by * information for display. The data displayed is stored in the
* the bundle. The ccm-sci-bundle for example provides this file, which can be found in * /WEB-INF/systeminformation.properties, which is usually provided by the
* {@code ccm-sci-bundle/web/WEB-INF} directory. At the moment it is necessary to update this * bundle. The ccm-sci-bundle for example provides this file, which can be found
* (these) file(s) manually. * in {@code ccm-sci-bundle/web/WEB-INF} directory. At the moment it is
* necessary to update this (these) file(s) manually.
* *
* A {@code systeminformations.properties} should contain at least these three properties: * A {@code systeminformations.properties} should contain at least these three
* properties:
* <dl> * <dl>
* <dt>version</dt> * <dt>version</dt>
* <dd>The version of the specific CCM distribution.</dd> * <dd>The version of the specific CCM distribution.</dd>
* <dt>appname</dt> * <dt>appname</dt>
* <dd>The name of the CCM distribution, for example <strong>ScientificCMS</strong> * <dd>The name of the CCM distribution, for example
* <dt>apphomepage</dt> * <strong>ScientificCMS</strong>
* <dd> * <dt>apphomepage</dt>
The URL of the website of the CCM distribution, for example * <dd>
* {@code http://www.scientificcms.org} * The URL of the website of the CCM distribution, for example
* </dd> * {@code http://www.scientificcms.org}
* </dd>
* </dl> * </dl>
* *
* *
@ -52,7 +56,8 @@ import java.util.Properties;
public class SystemInformation { public class SystemInformation {
/** /**
* Map containing all informations provided by the {@code systeminformation.properties} file. * Map containing all informations provided by the
* {@code systeminformation.properties} file.
*/ */
private final Map<String, String> sysInfo = new HashMap<String, String>(); private final Map<String, String> sysInfo = new HashMap<String, String>();
/** /**
@ -61,18 +66,28 @@ public class SystemInformation {
private final static SystemInformation INSTANCE = new SystemInformation(); private final static SystemInformation INSTANCE = new SystemInformation();
/** /**
* The constructor takes care of loading the data from the properties file and placing them into * The constructor takes care of loading the data from the properties file
* {@code HashMap}. * and placing them into {@code HashMap}.
*/ */
public SystemInformation() { public SystemInformation() {
final Properties properties = new Properties(); final Properties properties = new Properties();
try { try {
properties.load(getClass().getResourceAsStream( final InputStream stream = getClass().getResourceAsStream(
"/WEB-INF/systeminformation.properties")); "WEB-INF/systeminformation.properties");
if (stream == null) {
properties.put("version", "");
properties.put("appname", "LibreCCM");
properties.put("apphomepage", "http://www.libreccm.org");
} else {
properties.load(stream);
}
// properties.load(getClass().getResourceAsStream(
// "WEB-INF/systeminformation.properties"));
} catch (IOException ex) { } catch (IOException ex) {
throw new UncheckedWrapperException(ex); throw new UncheckedWrapperException(ex);
} }
for (String key : properties.stringPropertyNames()) { for (String key : properties.stringPropertyNames()) {
sysInfo.put(key, properties.getProperty(key)); sysInfo.put(key, properties.getProperty(key));
} }
@ -97,7 +112,8 @@ public class SystemInformation {
*/ */
final public String get(final String key) throws IllegalArgumentException { final public String get(final String key) throws IllegalArgumentException {
if (key == null || key.isEmpty()) { if (key == null || key.isEmpty()) {
throw new IllegalArgumentException("Parameter key must not be null or empty."); throw new IllegalArgumentException(
"Parameter key must not be null or empty.");
} }
return sysInfo.get(key); return sysInfo.get(key);
} }