Create Multiple XACML policies by changing policy ID


This example is very useful for the wso2is xacml testing. This is just java client for create the multiple policies from one sample policy. Here you can create any number of policies and directly upload it to the WSO2IS by changing the config.properties file under the java client.

Instructions : this is java maven project you can just build it and open it from any IDE

Change the config.properties file according to your settings
Then you can create the multiple policies by running the MultiplePolicyCreator
You can upload the created policies by running the PolicyUploader

Specially: You can replace the sample.xml policy file as you wish and generate the policies according to that

Read the whole file and return the content without newlines in Java


This is a simple method to read whole file and take as a string without newlines

    public static String readFile(String filename) throws IOException {
        BufferedReader br = new BufferedReader(new FileReader(filename));
        String nextLine = "";
        StringBuffer sb = new StringBuffer();
        while ((nextLine = br.readLine()) != null) {
            sb.append(nextLine);
        }
        //remove newlines
        String newString = sb.toString().replace('\n', ' ');

        return newString;
    }

Java Themes with JTattoo


First download the JTattoo.jar and add into your project classpath then you have to put the following code into your main method

public static void main(String []args){
    try {
            //here you can put the selected theme class name in JTattoo
            UIManager.setLookAndFeel("com.jtattoo.plaf.texture.TextureLookAndFeel");

        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(PC.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(PC.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(PC.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(PC.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
}

These are the JTattoo themes

1. TextureLookAndFeel – “com.jtattoo.plaf.texture.TextureLookAndFeel”

2. SmartLookAndFeel – “com.jtattoo.plaf.smart.SmartLookAndFeel”

3. NoireLookAndFeel – “com.jtattoo.plaf.noire.NoireLookAndFeel”

4. AcrylLookAndFeel – “com.jtattoo.plaf.acryl.AcrylLookAndFeel”

5. AeroLookAndFeel – “com.jtattoo.plaf.aero.AeroLookAndFeel”

6. AluminiumLookAndFeel – “com.jtattoo.plaf.aluminium.AluminiumLookAndFeel”

7. BernsteinLookAndFeel – “com.jtattoo.plaf.bernstein.BernsteinLookAndFeel”

8. FastLookAndFeel – “com.jtattoo.plaf.fast.FastLookAndFeel”

9. GraphiteLookAndFeel – “com.jtattoo.plaf.graphite.GraphiteLookAndFeel”

10. HiFiLookAndFeel – “com.jtattoo.plaf.hifi.HiFiLookAndFeel”

11. LunaLookAndFeel – “com.jtattoo.plaf.luna.LunaLookAndFeel”

12. McWinLookAndFeel – “com.jtattoo.plaf.mcwin.McWinLookAndFeel”

13. MintLookAndFeel – “com.jtattoo.plaf.mint.MintLookAndFeel”

Set Icon in Java Frames


Set the icon image in JFrame – you have to put the following code in to your constructor and change the image path most probably we are using 24 * 24 pixels .png image (here “/images/” is one of my packages)

public void Constuctor(){
    this.setIconImage(new ImageIcon(getClass().getResource("/images/payroll.png")).getImage());
}

Example of Jframe

Set the icon image in JInternalFrame

public void Constuctor(){
     this.setFrameIcon(new ImageIcon(getClass().getResource("/images/Profile-24.png")));
}

Example for JInternalFrame

Consuming a SOAP service using WSO2 API Manager with Consumer Key And Consumer Secret


First you have to follow the Charitha’s blog Consuming a SOAP service using WSO2 API Manager
and create the API for your service.

In the above example its using the given “Access Token” to invoke the API now here what I’m going to explain how to invoke the API using “Access Token” generated by using  “Consumer Key”,”Consumer Secret”

Take the “Consumer Key”,”Consumer Secret” and Encode to Base64 format. You can do this with the following  web site http://www.base64encode.org/ What you have to do is give the  “<Consumer Key>:<Consumer Secret>” as follows and take the encoded value

Download the Jmeter project created for invoke the login API in API manager In this project you have to replace the Authorization value as follows

“Basic<Space>Your Encode Base64 Value” and run the jmeter script then take the “access_token” as follows

This access token you can use to access the API

Create a free website or blog at WordPress.com.

Up ↑