Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
[fix] missing changes from examserver
Browse files Browse the repository at this point in the history
  • Loading branch information
smee committed Oct 22, 2010
1 parent f495bfb commit 0b82cf4
Show file tree
Hide file tree
Showing 6 changed files with 214 additions and 118 deletions.
Expand Up @@ -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<String> getRadiusMailSuffixes();

void setRadiusMailSuffixes(List<String> suffixes);

/**
* Settings for signing and timestamping PDF files.
*
Expand All @@ -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();

}
Expand Up @@ -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;
Expand Down Expand Up @@ -367,7 +367,7 @@ public List<String> getRadiusMailSuffixes() {

/*
* (non-Javadoc)
*
*
* @see de.thorstenberger.examServer.service.ConfigManager#setRadiusMailSuffixes(java.util.List)
*/
@Override
Expand All @@ -386,4 +386,48 @@ public synchronized void setRadiusMailSuffixes(List<String> 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();
}

}
Expand Up @@ -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
*/
*/
/**
*
*/
Expand All @@ -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");
}

}
Expand Up @@ -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
Expand Down

0 comments on commit 0b82cf4

Please sign in to comment.