Contribute to this guideReport an issue

guideOverview

CKFinder is an Ajax application with a frontend written entirely in JavaScript. It communicates with the server through JSON messages. On the server side, there is a “connector” written in a specific server language, which handles the frontend requests. The following diagram illustrates it:

Diagram of CKFinder architecture overview.

# Connector architecture

The CKFinder 3 for Java connector is a regular servlet built on top of the Spring features:

  • spring-context – Used for dependency injection, events and resource management.
  • spring-web – Used for web-related tasks.

# Path scan

CKFinder’s servlet initializes its own internal application context and performs a path scan of the com.cksource.ckfinder package to discover and register all the components. If you need to add a custom path to be scanned for components, you can use the scan-path servlet initialization parameter.

To register your custom components (e.g. Authenticator), you need to either place the code in the com.cksource.ckfinder package, or in the package you registered for path scan using the scan-path servlet initialization parameter.

Servlet initialization parameters can be set in many ways. Below, you can see an example of setting the scan-path parameter using the Standard Deployment Descriptor (web.xml file). Thanks to this, CKFinder’s Authenticator or any other custom code can be placed in a package of your choice. In the example presented below it is in the package named com.example.ckfinder.

<!-- web.xml -->
<servlet>
    <init-param>
        <param-name>scan-path</param-name>
        <param-value>com.example.ckfinder</param-value>
    </init-param>
    <servlet-name>CKFinder</servlet-name>
    <servlet-class>com.cksource.ckfinder.servlet.CKFinderServlet</servlet-class>
    <multipart-config>
        <location>/tmp</location>
        <max-file-size>5242880</max-file-size><!--5MB-->
        <max-request-size>20971520</max-request-size><!--20MB-->
        <file-size-threshold>0</file-size-threshold>
    </multipart-config>
</servlet>