Thursday, April 22, 2010

Accessing OpenSSO Identity Services

Step 1: Access WSDL from URL

http://host:port/opensso/identityservices?WSDL

Step 2: Generate Proxy classes from WSDL using Eclipse

Step 3: Access OpenSSO Identity Services


 //Create Operation                 
 IdentityServicesImplProxy identityServicesImplProxy = new IdentityServicesImplProxy();
 identityServicesImplProxy.setEndpoint("http://host:port/opensso/identityservices/IdentityServices");

 IdentityDetails identityDetails = new IdentityDetails();
 String username = "sunmoon3112";
 String emailaddr = "sunmoon3112@mycorp.com";
 String pwd = "Start@12";
           
 //set admin token
 Token result = identityServicesImplProxy.authenticate("amadmin", "P@ssw0rd", "realm=/");
 String admintoken = result.getId();
 Token admin = new Token();
 admin.setId(admintoken);
          
  //set some user attributes           
 Attribute attrs[] = {pwdattr1,emailattr2};
 identityDetails.setName(username);//create user id
 identityDetails.setAttributes(attrs);//set attrs for identity
 identityServicesImplProxy.create(identityDetails, admin);

Step 4: Similarly try accessing all other identity services via generated Proxy

Wednesday, April 21, 2010

Executing Sun IdM XPress Rules from Java

Example Rule

As a simple example, let’s say we have a rule getUserAttribute that gets and returns a specified attribute – for example fullname – of a user identified by her accountId:

<Rule name="getUserAttribute">

    <RuleArgument name="context" />

    <RuleArgument name="accountId" />

    <RuleArgument name="attrName" />

    <defvar name="wsUser">

        <invoke name="getObjectIfExists">

            <ref>context</ref>

            <s>User</s>

            <ref>accountId</ref>

        </invoke>

    </defvar>

    <invoke name="getAttribute">

        <ref>wsUser</ref>

        <ref>attrName</ref>

    </invoke>

</Rule>

Executing Rules from Java

Let’s say this rule is stored in a configuration object of wsType EndUserLibrary whose name is MyCorp-UserRuleLibrary.
That is, the full name to our rule is MyCorp-UserRuleLibrary:getUserAttribute.
It takes only a few lines to execute this rule from Java. Let’s first create a Util class holding our method:


package com.mycorp.util.XpressUtil;


import java.util.Map;

import com.waveset.expression.ExState;

import com.waveset.object.LighthouseContext;

import com.waveset.object.Rule;

import com.waveset.util.WavesetException;


public class XpressUtil {


    public static Object executeRule(LighthouseContext context,

            String ruleName, Map args) throws WavesetException {


        Rule rule = Rule.findRule(context.getCache(), ruleName);

        ExState state = new ExState();

        return rule.eval(state, args);


    }


}

Now we can execute our XPress rule from Java:


import java.util.Map;

import java.util.HashMap;

import com.waveset.session.Session;

import com.waveset.session.SessionFactory;

import com.waveset.util.EncryptedData;


import com.mycorp.util.XpressUtil;


// somewhere in our java code...


EncryptedData encryptedPassword = new EncryptedData("configurator");

Session wsSess = SessionFactory.getSession("Configurator", encryptedPassword);


String ruleName = "MyCorp-UserRuleLibrary:getUserAttribute";


Map args = new HashMap();

args.put("context", wsSess);

args.put("accountId", "Configurator");

args.put("attrName", "fullname");


Object result = XpressUtil.executeRule( wsSess, ruleName, args );     

Monday, April 19, 2010

“Don't judge a book by its cover”

A 25 year old son was sitting beside his old father in a train one day. When the train was about to leave, all the passengers started settling down in their seats. The son was filled with joy and anxiety. He was seated by the window. He put his hand out and felt the breeze and screamed, “ Papa look at all the trees, they are moving behind”. The old father smiled and admired his son’s feelings. Beside the old man, a couple was also traveling and observed this strange behavior. They found something awkward and childish in the behavior of this 25 year old man.

All of a sudden, the son shouted again “Papa see! The clouds are moving about; there is a pond down and many cows are drinking it’s water”. It soon started drizzling. Once again, the young man felt exited and said “papa, I can see and feel the rain drops touching my hand”. The couple seeing this and feeling concerned, asked the old man “why don’t you consult a good doctor and treat your son; don’t you find something abnormally different in him ?”

The old man replied, “Yes, I have provided the best treatment for my only boy. We are just returning from the hospital. I am happy for today is the day he has received his sense of sight. It’s for the first time my son is seeing and relishing these little wonders which we have been watching and ignoring in our routine life!”

The couple had no words to reply and felt sorry for their remarks.

Moral of the story: “Do not draw conclusions, until you know the actual facts”. There is a proverb in English which goes, “don’t judge a book by its cover”. People, situations and places cannot be predicted or judged from a skewed angle. Life is beyond the ordinary and the truth is much more harder than the way it’s simply presented. What may be simple to you, may be the world for someone else.

Sunday, April 11, 2010

“Unique flaws and Appreciation”

A water bearer in China had two large pots, each hung on the ends of a pole which he carried across his neck. One of the pots had a crack in it, while the other pot was perfect and always delivered a full portion of water. At the end of the long walk from the stream to the House, the cracked pot arrived only half full. For a full two years this went on daily, with the bearer delivering only one and a half pots full of water to his house.

Of course, the perfect pot was proud of its accomplishments, perfect for which it was made. But the poor cracked pot was ashamed of it's own imperfection and miserable that it was able to accomplish only half of what it had been made to do.

After two years of what it perceived to be a bitter failure, it spoke to the water bearer one day by the stream. "I am ashamed of myself, and I want to apologize to you. I have been able to deliver only half my load because this crack in my side causes water to leak out all the way back to your house. Because of my flaws, you have to do all of this work, and you don't get full value from your efforts," the pot said.

The bearer said to the pot, "Did you notice that there were flowers only on your side of the path, but not on the other pot's side? That's because I have always known about your flaw. So I planted flower seeds on your side of the path, and every day while we walk back, you've watered them. For two years I have been able to pick these beautiful flowers to decorate the table.
Without you being just the way you are, there would not be this beauty to grace the house?

Lessons to Learn from This Story:

Each of us has our own unique flaws. We're all cracked pots. But it's the cracks and flaws we each have that make our lives together so very interesting and rewarding. You've just got to take each person for what they are, and look for the good in them. Blessed are the flexible, for they shall not be bent out of shape.

Remember to appreciate all the different people in your life.

Monday, April 5, 2010

“Focus on the destination”

Two Spanish friends set out on a mini-truck and headed off to a jungle to indulge in a deer hunt. Parking at a distance they set off into the bushes to a vantage point down in the valley, waiting for their prey.

After a few hours of many failed attempts, they finally managed to shoot down a deer. And then began the long journey back to their truck.

The two friends clasped the deer’s tail and began to drag it towards their truck. A farmer saw them struggling and shouted out some advice: “ That’s not the way to do it! God made handles for you to drag the deer. You see the antlers on the deer? Those horn like things? Hold that – and pull the deer!”

The two friends looked at each other and decided to heed the advice. They went to the other side, grabbed the deer’s antlers and continued to drag it.

Ten minutes later, one of them said, “The farmer was right. It’s much easier this way!”.

“That’s right” said his partner, “only problem is we are moving farther and farther away from our truck”.

Lessons to Learn from This Story:

In our pursuit to make things easier now, we often lose sight of what we are initially set-out to do, diverting us from our destination.

“Be true to yourself and never cheat God”

There was a student who was very weak in academics. His struggle was particularly with Mathematics. He struggled to reach class tenth but failed to clear the final board examination, Mathematics being the bottleneck.
He was totally shattered for his poor show and decided to give it a best shot in the upcoming supplementary examinations to be held four months from then.
Being extremely god fearing in nature he prayed to god and promised god that he would donate food to twenty five people if he passed the exam.
The next few months he was extremely focused and invested his best efforts in cracking the examination.
The big day had arrived. He had prepared extremely well for the exam. The examination started, credit to his hard work, he was able to answer all the questions at lightning fast time and was left with two hours before he could submit his answer scripts. He was confident of a perfect 100.
With a decent two hours on hand, the student started calculating the cost of the committed donation that he promised to god when he would pass the examination.
His calculations started he calculated the expenses for donation to 25 people. At the end of it he thought that it was quite a significant amount that he should be spending from already a meager pocket money. He convinced himself that it was his hard work that helped him get through the trouble, divine element was very limited.
He kept on borrowing additional sheets for calculations, the number came down from 25..20..18..15..10..5… and then finally to just one, that too he decided that he would donate a very simple and a plain vegetarian meal with no sweets and starters.
By then he had exhausted almost equal number of answer sheets for calculating, meanwhile the time was up and the invigilator started snatching away papers in hurry with force, this student was the last one to have submitted his papers. With a great feel of achievement and content he tucked the bunch of papers in his bag and jumped out with a feel of achievement.
Results were declared and to his astonishment he had failed the exam yet again, he broke into tears and started cursing god for his yet another failure. Back home disgusted he wanted to tear all his calculation sheets to protest against god’s mercilessness and tore open his bag furiously, when he opened his bag he was shocked and just stood speechless. He submitted his calculation papers and brought home his answer sheets.
Lessons to Learn from This Story:
Be true to yourself and never try to cheat God!