Posts

PDF generation with Apache FOP

Image
What is Apache FOP?
Apache FOP is a print formatter driven by XSL formatting objects(XSL-FO). It is a library to read XSL FO objects and generate documents with specified output format. Here I have used pdf as the output format.

What is XSL?

XSL is a language for expressing stylesheets. It describes how to display data in an XML file.

What is XSL FO?

XSL FO is a part of XSL which is a markup language for XML document formatting.

How Apache FOP generate PDFs.


I have generated javaFX form to enter the data and when I click the print button after filling data, PDF will be created in a folder called PDFs. source code for this available in https://github.com/laki88/PatientDischargeForm.




JDBC drivers and connection strings

Recently I was fixing a bug in gadget creation in WSO2 DAS 3.1.0 in which gadget creation throws errors on some database types. So I have to check for major database types for gadget creation and I came up with following database drivers and connection strings and little more information their JDBC drivers.

MySQL
Driver class : com.mysql.jdbc.Driver
Connection string : jdbc:mysql://localhost:3306/databaseName

You can download JDBC driver from their official site.

MSSQL
Driver class : com.microsoft.sqlserver.jdbc.SQLServerDriver
Connection string :jdbc:sqlserver://hostName:1433;database=databaseName

You can download MSSQL driver from microsoft site. According to the JRE it comes from several flavours as below.

• Sqljdbc41.jar requires a JRE of 7 and supports the JDBC 4.1 API
• Sqljdbc42.jar requires a JRE of 8 and supports the JDBC 4.2 API

Apart from official MSSQL driver there are other supported drivers like jtds as well. You can find more information about them by referring this s…

Simple wait and notify example in Java

This example demonstrate wait and notify example. Main thread(ThreadA) will create threadB and will start threadB. After threadB started, it just print that it is started and will go to WAITING state by calling wait(). Meanwhile threadA goes to sleep for 3 seconds and will print that it is awaked and will notify threadB by calling notify(). This will cause to threadB goes to RUNNABLE state. Then it will resume the threadB's execution and will print that it is notified.

public class ThreadA { public static void main(String[] args) throws InterruptedException { ThreadB threadB = new ThreadB(); Thread thread = new Thread(threadB); thread.start(); Thread.sleep(3000); System.out.println("threadA is awaked......."); synchronized (threadB) { threadB.notify(); } } }public class ThreadB implements Runnable { public void run() { System.out.println("threadB is started................"…

Customize the place where tomcat instance creating for wso2 4.4.x servers

WSO2 4.4.x servers run on an OSGIfied tomcat. It creates the tomcat instance on <CARBON_HOME>/lib/tomcat directory. You can customize this path to your own one by changing the property "catalina.base" in wso2server.sh.

Policy add using Rest API in WSO2 EMM

You can add a policy using REST API given in EMM. For the use the dynamic registration client given.
below sample curl command will return client id and secret


curl -k -H "Content-Type: application/json" -X POST -d '{"owner":"admin","clientName":"admin_emm","grantType":"refresh_token password client_credentials","tokenScope":"prod"}' https://localhost:9443/dynamic-client-web/register
This will return a response like below
{"client_secret":"YCnfi_jp9Tso0qyRcbGxaQnYctga","callback_url":null,"client_id":"xJvKvUHNYqfK1MeQ_VybtBfF5MAa","client_name":"admin_admin_emm"}
Use the client id and secret by encoding using base64 to generate access token using below command
curl -k -d "grant_type=password&username=admin&password=admin&scope=default " -H "Authorization: Basic eEp2S3ZVSE5ZcWZLMU1lUV9WeWJ0QmZGNU1BY…

Application Whitelist and Blacklist Feature in WSO2 EMM

Image
It can be white listed and black listed applications in WSO2 EMM 2.1.0 onwards.

What is Application White List?
White listed applications are the only applications that allowed run on device. Any other application which does not appear on the list will not be allowed to run on the device.
What is Application Black List?
Black listed applications are the applications that are not allowed to run on the device.

Application black lists and white lists can be deployed on devices as device policies. Follow the below steps to create black list.

1. Enroll a device on EMM.
2. Create an app restriction policy
  i) Go to the EMM main window by issuing below url to the browser address bar
      https://localhost:9443/emm/
  ii) Click policy add button as shown in below

iii) Choose the platform. ex : I choose android platform.


iv) Click Applications Restrictions profile and click Off toggle button to On the profile



v) Choose black list from select box and add applications as below. Note that to ad…

WSO2 APP Manager(APPM) and WSO2 Enterprise Mobility Manager (EMM) integration

There are two separate cases for APPM and EMM integration

1. APPM and EMM on a single JVM. ex : EMM standalone pack.
2. APPM and EMM on separate JVMs. ex : clustered scenario

For the first case, EMM standalone vanilla pack should work without changing any configuration.

For the second case, There are some configurations which should be done. Follow the below steps to configure APPM and EMM on separate JVMs.

1. If you run APPM and EMM on same machine change the port offset of one pack. Let's change the port offset of APPM pack.

i) Change the port offset of carbon.xml to 10 which is in <APPM_HOME>/repository/conf directory.
ii) Since APPM default authentication mechanism is SAML SSO change the port of IdentityProviderUrl also in app-manager.xml

 ex : Change the port as shown in light green

<SSOConfiguration>

        <!-- URL of the IDP use for SSO -->
        <IdentityProviderUrl>https://localhost:9453/samlsso</IdentityProviderUrl>

        <Configura…