From 0b82cf40d862ad038377a0c50f68e7ed56c3d5cb Mon Sep 17 00:00:00 2001 From: Steffen Dienst Date: Fri, 22 Oct 2010 15:31:38 +0200 Subject: [PATCH] [fix] missing changes from examserver --- .../examServer/service/ConfigManager.java | 28 +++- .../service/impl/ConfigManagerImpl.java | 50 +++++- .../webapp/action/SystemConfigAction.java | 47 +++--- .../action/SystemConfigSubmitAction.java | 51 +++--- .../webapp/form/SystemConfigForm.java | 155 ++++++++++-------- examServer/src/main/jaxb/config.xsd | 1 + 6 files changed, 214 insertions(+), 118 deletions(-) diff --git a/examServer/src/main/java/de/thorstenberger/examServer/service/ConfigManager.java b/examServer/src/main/java/de/thorstenberger/examServer/service/ConfigManager.java index 51d1f964..d0028832 100644 --- a/examServer/src/main/java/de/thorstenberger/examServer/service/ConfigManager.java +++ b/examServer/src/main/java/de/thorstenberger/examServer/service/ConfigManager.java @@ -78,13 +78,13 @@ public interface ConfigManager { /** * Get a list of mail suffixes that resemble all mails that can be used for the current radius authentication server. - * + * * @return */ List getRadiusMailSuffixes(); - + void setRadiusMailSuffixes(List suffixes); - + /** * Settings for signing and timestamping PDF files. * @@ -94,4 +94,26 @@ public interface ConfigManager { void setPDFSignatureInfos(SignatureInfos si); + /** + * Random seed to use for all random generation processes involving tasklet creation. + * + * @return + */ + long getRandomSeed(); + + /** + * Is the result of {@link #getRandomSeed()} fixed (i.e. previously set by {@link #setRandomSeed(long)}? + * @return true if there is a fixed value, false after calling {@link #clearRandomSeed()}. + */ + boolean isRandomSeedRandom(); + /** + * @param val + */ + void setRandomSeed(long val); + + /** + * Use random values for each call to {@link #getRandomSeed()}. + */ + void clearRandomSeed(); + } diff --git a/examServer/src/main/java/de/thorstenberger/examServer/service/impl/ConfigManagerImpl.java b/examServer/src/main/java/de/thorstenberger/examServer/service/impl/ConfigManagerImpl.java index 1099053e..92fcbb94 100644 --- a/examServer/src/main/java/de/thorstenberger/examServer/service/impl/ConfigManagerImpl.java +++ b/examServer/src/main/java/de/thorstenberger/examServer/service/impl/ConfigManagerImpl.java @@ -65,8 +65,8 @@ public class ConfigManagerImpl implements ConfigManager { private final Log log = LogFactory.getLog(ConfigManagerImpl.class); /** - * - */ + * + */ public ConfigManagerImpl(final ExamServerManager examServerManager) { this.examServerManager = examServerManager; @@ -367,7 +367,7 @@ public List getRadiusMailSuffixes() { /* * (non-Javadoc) - * + * * @see de.thorstenberger.examServer.service.ConfigManager#setRadiusMailSuffixes(java.util.List) */ @Override @@ -386,4 +386,48 @@ public synchronized void setRadiusMailSuffixes(List suffixes) { } } + /* + * (non-Javadoc) + * + * @see de.thorstenberger.examServer.service.ConfigManager#getRandomSeed() + */ + @Override + public long getRandomSeed() { + if (config.isSetRandomSeed()) + return config.getRandomSeed(); + else { + synchronized(this){ + // generate a unique random seed + return System.nanoTime(); + } + } + } + + /* + * (non-Javadoc) + * + * @see de.thorstenberger.examServer.service.ConfigManager#setRandomSeed(long) + */ + @Override + public void setRandomSeed(long val) { + config.setRandomSeed(val); + save(); + } + + /* + * (non-Javadoc) + * + * @see de.thorstenberger.examServer.service.ConfigManager#clearRandomSeed() + */ + @Override + public void clearRandomSeed() { + config.unsetRandomSeed(); + save(); + } + + @Override + public boolean isRandomSeedRandom() { + return config.isSetRandomSeed(); + } + } diff --git a/examServer/src/main/java/de/thorstenberger/examServer/webapp/action/SystemConfigAction.java b/examServer/src/main/java/de/thorstenberger/examServer/webapp/action/SystemConfigAction.java index af5a4ddb..c2637774 100644 --- a/examServer/src/main/java/de/thorstenberger/examServer/webapp/action/SystemConfigAction.java +++ b/examServer/src/main/java/de/thorstenberger/examServer/webapp/action/SystemConfigAction.java @@ -15,7 +15,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ + */ /** * */ @@ -37,28 +37,33 @@ */ public class SystemConfigAction extends BaseAction { - /* (non-Javadoc) - * @see de.thorstenberger.examServer.webapp.action.BaseAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - @Override - public ActionForward execute(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception { - - final SystemConfigForm scf = (SystemConfigForm)form; - final ConfigManager configManager = (ConfigManager)getBean( "configManager" ); - - scf.setLoadJVMOnStartup( configManager.isLoadJVMOnStartup() ); - scf.setRemoteUserManagerURL( configManager.getRemoteUserManagerURL() ); - scf.setTitle( configManager.getTitle() ); - scf.setHttpAuthURL( configManager.getHTTPAuthURL() ); - scf.setHttpAuthMail( configManager.getHTTPAuthMail() ); - scf.setRadiusHost(configManager.getRadiusHost()); - scf.setRadiusSharedSecret(configManager.getRadiusSharedSecret()); - scf.setSignatureSettings( configManager.getPDFSignatureInfos() ); - scf.setRadiusMailSuffixes(configManager.getRadiusMailSuffixes()); + /* + * (non-Javadoc) + * + * @see de.thorstenberger.examServer.webapp.action.BaseAction#execute(org.apache.struts.action.ActionMapping, + * org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, + * javax.servlet.http.HttpServletResponse) + */ + @Override + public ActionForward execute(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception { - return mapping.findForward( "systemConfig" ); - } + final SystemConfigForm scf = (SystemConfigForm) form; + final ConfigManager configManager = (ConfigManager) getBean("configManager"); + scf.setLoadJVMOnStartup(configManager.isLoadJVMOnStartup()); + scf.setRemoteUserManagerURL(configManager.getRemoteUserManagerURL()); + scf.setTitle(configManager.getTitle()); + scf.setHttpAuthURL(configManager.getHTTPAuthURL()); + scf.setHttpAuthMail(configManager.getHTTPAuthMail()); + scf.setRadiusHost(configManager.getRadiusHost()); + scf.setRadiusSharedSecret(configManager.getRadiusSharedSecret()); + scf.setSignatureSettings(configManager.getPDFSignatureInfos()); + scf.setRadiusMailSuffixes(configManager.getRadiusMailSuffixes()); + scf.setRandomSeed(configManager.getRandomSeed()); + scf.setRandomSeedRandom(configManager.isRandomSeedRandom()); + + return mapping.findForward("systemConfig"); + } } diff --git a/examServer/src/main/java/de/thorstenberger/examServer/webapp/action/SystemConfigSubmitAction.java b/examServer/src/main/java/de/thorstenberger/examServer/webapp/action/SystemConfigSubmitAction.java index 09d2959f..b4369f5c 100644 --- a/examServer/src/main/java/de/thorstenberger/examServer/webapp/action/SystemConfigSubmitAction.java +++ b/examServer/src/main/java/de/thorstenberger/examServer/webapp/action/SystemConfigSubmitAction.java @@ -53,35 +53,42 @@ */ public class SystemConfigSubmitAction extends BaseAction { - /* (non-Javadoc) - * @see de.thorstenberger.examServer.webapp.action.BaseAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) - */ - @Override - public ActionForward execute(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception { - - - final SystemConfigForm scf = (SystemConfigForm)form; - final ConfigManager configManager = (ConfigManager)getBean( "configManager" ); - - configManager.setTitle( scf.getTitle() ); - configManager.setRemoteUserManagerURL( scf.getRemoteUserManagerURL() ); - configManager.setLoadJVMOnStartup( scf.isLoadJVMOnStartup() ); - configManager.setHTTPAuthURL( scf.getHttpAuthURL() ); - configManager.setHTTPAuthMail( scf.getHttpAuthMail() ); - configManager.setRadiusHost( scf.getRadiusHost() ); - configManager.setRadiusSharedSecret( scf.getRadiusSharedSecret() ); - configManager.setPDFSignatureInfos( scf.getSignatureSettings() ); + /* (non-Javadoc) + * @see de.thorstenberger.examServer.webapp.action.BaseAction#execute(org.apache.struts.action.ActionMapping, org.apache.struts.action.ActionForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse) + */ + @Override + public ActionForward execute(final ActionMapping mapping, final ActionForm form, final HttpServletRequest request, final HttpServletResponse response) throws Exception { + + + final SystemConfigForm scf = (SystemConfigForm)form; + final ConfigManager configManager = (ConfigManager)getBean( "configManager" ); + + configManager.setTitle( scf.getTitle() ); + configManager.setRemoteUserManagerURL( scf.getRemoteUserManagerURL() ); + configManager.setLoadJVMOnStartup( scf.isLoadJVMOnStartup() ); + configManager.setHTTPAuthURL( scf.getHttpAuthURL() ); + configManager.setHTTPAuthMail( scf.getHttpAuthMail() ); + configManager.setRadiusHost( scf.getRadiusHost() ); + configManager.setRadiusSharedSecret( scf.getRadiusSharedSecret() ); + configManager.setPDFSignatureInfos( scf.getSignatureSettings() ); configManager.setRadiusMailSuffixes(scf.getRadiusMailSuffixes()); + + // manually set random seed? + if (scf.isRandomSeedRandom()) { + configManager.clearRandomSeed(); + } else { + configManager.setRandomSeed(scf.getRandomSeed()); + } if ("Signatur testen".equals(scf.getTodo())) return createSignedPDF(mapping, request, response, configManager); final ActionMessages messages = new ActionMessages(); - messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "systemConfig.saved" ) ); - saveMessages( request, messages ); + messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage( "systemConfig.saved" ) ); + saveMessages( request, messages ); - return mapping.findForward( "success" ); - } + return mapping.findForward( "success" ); + } /** * @param mapping diff --git a/examServer/src/main/java/de/thorstenberger/examServer/webapp/form/SystemConfigForm.java b/examServer/src/main/java/de/thorstenberger/examServer/webapp/form/SystemConfigForm.java index 9070e7c4..0dba9840 100644 --- a/examServer/src/main/java/de/thorstenberger/examServer/webapp/form/SystemConfigForm.java +++ b/examServer/src/main/java/de/thorstenberger/examServer/webapp/form/SystemConfigForm.java @@ -34,17 +34,20 @@ */ public class SystemConfigForm extends BaseForm { - private String title; - private String remoteUserManagerURL; - private boolean loadJVMOnStartup; - - private String httpAuthURL; - private String httpAuthMail; - private String radiusHost; - private String radiusSharedSecret; + private String title; + private String remoteUserManagerURL; + private boolean loadJVMOnStartup; + + private String httpAuthURL; + private String httpAuthMail; + private String radiusHost; + private String radiusSharedSecret; private SignatureInfos si = new SignatureInfos(); private List mailSuffixes; + private long randomSeed; + private boolean randomSeedRandom = true; + /** * @return the mailSuffixes */ @@ -54,7 +57,7 @@ public List getRadiusMailSuffixes() { /** * Same contents as {@link #getRadiusMailSuffixes()} but as a single space delimited string. - * + * * @return */ public String getRadiusMailSuffixesDelimited() { @@ -80,7 +83,7 @@ public void setRadiusMailSuffixes(List mailSuffixes) { private String todo; - /** + /** * @return name of the submit button pressed */ public String getTodo() { @@ -120,65 +123,65 @@ public void setRadiusSharedSecret(final String radiusSharedSecret) { this.radiusSharedSecret = radiusSharedSecret; } /** - * @return Returns the loadJVMOnStartup. - */ - public boolean isLoadJVMOnStartup() { - return loadJVMOnStartup; - } - /** - * @param loadJVMOnStartup The loadJVMOnStartup to set. - */ - public void setLoadJVMOnStartup(final boolean loadJVMOnStartup) { - this.loadJVMOnStartup = loadJVMOnStartup; - } - /** - * @return Returns the remoteUserManagerURL. - */ - public String getRemoteUserManagerURL() { - return remoteUserManagerURL; - } - /** - * @param remoteUserManagerURL The remoteUserManagerURL to set. - */ - public void setRemoteUserManagerURL(final String remoteUserManagerURL) { - this.remoteUserManagerURL = remoteUserManagerURL; - } - /** - * @return Returns the title. - */ - public String getTitle() { - return title; - } - /** - * @param title The title to set. - */ - public void setTitle(final String title) { - this.title = title; - } - /** - * @return the httpAuthURL - */ - public String getHttpAuthURL() { - return httpAuthURL; - } - /** - * @param httpAuthURL the httpAuthURL to set - */ - public void setHttpAuthURL(final String httpAuthURL) { - this.httpAuthURL = httpAuthURL; - } - /** - * @return the httpAuthMail - */ - public String getHttpAuthMail() { - return httpAuthMail; - } - /** - * @param httpAuthMail the httpAuthMail to set - */ - public void setHttpAuthMail(final String httpAuthMail) { - this.httpAuthMail = httpAuthMail; - } + * @return Returns the loadJVMOnStartup. + */ + public boolean isLoadJVMOnStartup() { + return loadJVMOnStartup; + } + /** + * @param loadJVMOnStartup The loadJVMOnStartup to set. + */ + public void setLoadJVMOnStartup(final boolean loadJVMOnStartup) { + this.loadJVMOnStartup = loadJVMOnStartup; + } + /** + * @return Returns the remoteUserManagerURL. + */ + public String getRemoteUserManagerURL() { + return remoteUserManagerURL; + } + /** + * @param remoteUserManagerURL The remoteUserManagerURL to set. + */ + public void setRemoteUserManagerURL(final String remoteUserManagerURL) { + this.remoteUserManagerURL = remoteUserManagerURL; + } + /** + * @return Returns the title. + */ + public String getTitle() { + return title; + } + /** + * @param title The title to set. + */ + public void setTitle(final String title) { + this.title = title; + } + /** + * @return the httpAuthURL + */ + public String getHttpAuthURL() { + return httpAuthURL; + } + /** + * @param httpAuthURL the httpAuthURL to set + */ + public void setHttpAuthURL(final String httpAuthURL) { + this.httpAuthURL = httpAuthURL; + } + /** + * @return the httpAuthMail + */ + public String getHttpAuthMail() { + return httpAuthMail; + } + /** + * @param httpAuthMail the httpAuthMail to set + */ + public void setHttpAuthMail(final String httpAuthMail) { + this.httpAuthMail = httpAuthMail; + } /** * @param si @@ -195,6 +198,20 @@ public SignatureInfos getSignatureSettings() { return si; } + public void setRandomSeed(long value) { + this.randomSeed = value; + } + + public void setRandomSeedRandom(boolean val) { + this.randomSeedRandom = val; + } + + public boolean isRandomSeedRandom() { + return randomSeedRandom; + } + public long getRandomSeed() { + return randomSeed; + } } diff --git a/examServer/src/main/jaxb/config.xsd b/examServer/src/main/jaxb/config.xsd index 8d33e70d..cbd77d9b 100644 --- a/examServer/src/main/jaxb/config.xsd +++ b/examServer/src/main/jaxb/config.xsd @@ -31,6 +31,7 @@ +