Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;

import org.apache.wicket.WicketRuntimeException;

/**
* A very simple {@link ISecureRandomSupplier} that holds a {@code SecureRandom} using
Expand All @@ -42,7 +41,7 @@ public DefaultSecureRandomSupplier()
}
catch (NoSuchAlgorithmException e)
{
throw new WicketRuntimeException(e);
random = new SecureRandom();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure that this is a good solution. This is the default random supplier impl that works "most of the time".

If one needs to use a custom RandomSupplier then (s)he needs to do getApplication().getSecuritySettings().setRandomSupplier(...)

public SecuritySettings setRandomSupplier(ISecureRandomSupplier randomSupplier)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of a FIPS system:
getApplication().getSecuritySettings() will throw an exception when it tries to create the SecuritySettings object because the SecuritySettings object initializes its randomSupplier member with a new DefaultSecureRandomSupplier instance. Based on the original code this will throw an exception that stops Wicket from initializing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please give more information why it will throw ?
Even better - paste the exception stacktrace.

FIPS is about the JDK security APIs, not about Wicket security related APIs (or any other library), no ?

Copy link
Member

@martin-g martin-g Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make my initial suggestion more clear:
You need to call getSecuritySettings().setRandomSupplier(new MyCustomSupplier()) in YourApplication#init() method.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've attempted in setting the random supplier in our application init, but the exception occurs before this. Exception:

SEVERE: Exception starting filter [SwAppApplication] javax.servlet.ServletException: org.apache.wicket.WicketRuntimeException: java.security.NoSuchAlgorithmException: SHA1PRNG SecureRandom not available at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:467) at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:365) at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:239) at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:221) at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:97) at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:3908) at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:4527) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:76) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749) at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:721) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1203) at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1193) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317) at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:76) at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:145) at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:749) at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:211) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.core.StandardService.startInternal(StandardService.java:412) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:874) at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:164) at org.apache.catalina.startup.Tomcat.start(Tomcat.java:439) at com.systemware.ccisvc.embedded.EmbeddedTomcat.startTomcat(Unknown Source) at com.systemware.client.base.BaseAppInitControl.initTomcat(Unknown Source) at com.systemware.client.base.BaseAppInitControlForCM.init(Unknown Source) at com.systemware.client.base.BaseApp.main(Unknown Source) Caused by: org.apache.wicket.WicketRuntimeException: java.security.NoSuchAlgorithmException: SHA1PRNG SecureRandom not available at org.apache.wicket.core.random.DefaultSecureRandomSupplier.<init>(DefaultSecureRandomSupplier.java:45) at org.apache.wicket.settings.SecuritySettings.<init>(SecuritySettings.java:69) at org.apache.wicket.Application.getSecuritySettings(Application.java:1271) at com.systemware.swapp.SwAppApplication.init(Unknown Source) at org.apache.wicket.Application.initApplication(Application.java:768) at org.apache.wicket.protocol.http.WicketFilter.init(WicketFilter.java:441) ... 32 more Caused by: java.security.NoSuchAlgorithmException: SHA1PRNG SecureRandom not available at java.base/sun.security.jca.GetInstance.getInstance(GetInstance.java:159) at java.base/java.security.SecureRandom.getInstance(SecureRandom.java:389) at org.apache.wicket.core.random.DefaultSecureRandomSupplier.<init>(DefaultSecureRandomSupplier.java:41)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see! We get the SecureRandom in the constructor ...
We should rework this to be lazy.

}
}

Expand Down