Wednesday, May 6, 2009

difference between keyentry and trustedcertentry

You can tell if a certificate includes a private key by the way keytool lists it. Signing certificates with private keys will be marked keyEntry. Authority certificates without private keys will be marked trustedCertEntry.

Monday, March 30, 2009

The Logging Saga

Took me a whole day, so was worth blogging it.
This is jboss-4.2.2 specific.
WAR files in JBoss are scoped by default.
EAR files are not.

Lets look into the two case:
1. WAR
In case of WAR file, you can have the log4j.xml in the conf folder and things would work out. But, you cannot control the logging levels at runtime using Log4jService. The reason being, Log4JService controls the Logger in the jboss lib folder. To achieve this, I guess you might need a EAR or sthg.
What we can do is write a JSP/Servlet and have it as part of your application logger. This gives you the reference of your logger and hence runtime control to configure logging level


protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException,
IOException {
String loggerName = (String) request.getParameter("loggerName");
String level = (String) request.getParameter("level");
String actionType = (String) request.getParameter("submit");
System.out.println("loggerName=" + loggerName + "/level=" + level);
if (loggerName != null && loggerName.trim().length() > 0) {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
Level origLevelObj = Logger.getLogger(loggerName).getLevel();
String origLevel = "UNKNOWN";
if (origLevelObj == null) {
System.out.println(Logger.getRootLogger().getLevel());
origLevel = Logger.getRootLogger().getLevel().toString();
}

if (actionType.equalsIgnoreCase("getloggerlevel")) {
out.println("Log level for " + loggerName + " is <b>" + origLevel + "</b>");
} else if (actionType.equalsIgnoreCase("setloggerlevel")) {
setLogLevel(loggerName, level);
out.println("Log level for " + loggerName + " is changed from <b>" + origLevel + "</b> to <b>" + level
+ "</b>");
}

out.flush();
out.close();
}

}

private void setLogLevel(String loggerName, String level) {
if ("debug".equalsIgnoreCase(level)) {
Logger.getLogger(loggerName).setLevel(Level.DEBUG);
} else if ("info".equalsIgnoreCase(level)) {
Logger.getLogger(loggerName).setLevel(Level.INFO);
} else if ("error".equalsIgnoreCase(level)) {
Logger.getLogger(loggerName).setLevel(Level.ERROR);
} else if ("fatal".equalsIgnoreCase(level)) {
Logger.getLogger(loggerName).setLevel(Level.FATAL);
} else if ("warn".equalsIgnoreCase(level)) {
Logger.getLogger(loggerName).setLevel(Level.WARN);
}
}


<span style="font-weight:bold;">And this could be your JSP:</span>

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<h2> Log Level Controller </h2>
<br>
<FORM METHOD=POST ACTION="logy">
<table border=1>
<th colspan=2 bgcolor="YELLOW">Get Logger level</th>
<tr><td> LoggerName </td><td><INPUT TYPE=TEXT NAME="loggerName" SIZE=20></td></tr>
<tr><td colspan=2 align=right><INPUT TYPE=SUBMIT name=submit value=getloggerlevel></td></tr>
</table>
<br><br>
<table border=1>
<th colspan=2 bgcolor="YELLOW">Set Logger level</th>
<tr>
<td> LoggerName </td><td><INPUT TYPE=TEXT NAME="loggerName" SIZE=20></td></tr>
<tr><td> LogLevel </td>
<td>
<select name="level">
<option value=DEBUG>DEBUG</option>
<option value=INFO>INFO</option>
<option value=WARN>WARN</option>
<option value=ERROR>ERROR</option>
<option value=FATAL>FATAL</option>
</select>
</td></tr>
<tr><td colspan=2 align=right><INPUT TYPE=SUBMIT name=submit value=setloggerlevel></td></tr>
</table>
</FORM>


2. EAR

Make changes in jboss-log4j.xml.

To have application specific logging:
1. Write an appender - You can give your application specific filename.
2. Write a logger and refer to that appender. You do -> Logger.getLogger(x.class); This takes the complete package name into the logger hierarchy. So you can name you logger in log4j as "com.apple". This will route all your requests to your selected appender's file. and then specify the additivity to false. When you specify the additivity to false, then you dont log into the root appenders. And also, dont add your appender into the root logger.

<appender name="InfoAppender" class="org.apache.log4j.RollingFileAppender">
<errorHandler
class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
<param name="File" value="${jboss.server.log.dir}/pos-server.log" />
<param name="Append" value="true" />
<param name="ImmediateFlush" value="true" />
<param name="MaxFileSize" value="200MB" />
<param name="MaxBackupIndex" value="10" />
<param name="Threshold" value="DEBUG"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %X{SERVER_NAME} [%t] %-5p (%c{1}) - %m%n" />
</layout>
</appender>

And then do this: Very important
<logger name="com.boo" additivity="false">
<level value="DEBUG" />
<appender-ref ref="InfoAppender"/>
</logger>

Check out the root:
<root>

<priority value ="debug" />
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>

Monday, February 23, 2009

Yosemite









Mac is Mac is Mac. These are the pics from my camera ...modified

Tuesday, November 11, 2008

WSDL styles

Firstly, let me talk about RPC/literal and Document/Literal(Wrapped)

RPC/literal -- uses methodName in soap:body, and the input parameters.
For eg. if you had a method like

private void simpleMethod(int x, int y)

RPC/literal SOAP request would be like...
<simplemethod>(Method name)
<x>2</x>
<y>3</y>
</simplemethod>

A Document/Literal(Wrapped) would be -
<name_of_input_request_element_in_wsdl>
<x>2</x>
<y>3</y>
</name_of_input_request_element_in_wsdl>

RPC/encoded would be like
<simplemethod>(Method name)
<x type="int">2</x>
<y type="">3</y>
<simplemethod>

Document/Encoded would be like
<soap:body>
<x>2</x>
<y>3</y>
</soap:body>

Check that there is no method names or sthg. Just the input params.

Document/Literal (bare)
<input_element1>2</input_element1>
<input_element2>3</input_element2>

Good like to read
<a href="http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/">http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/</a></simplemethod></simplemethod>

Wednesday, November 5, 2008

Hard time

This has been a very very tough week. I have never had it so hard. I cant concentrate. I just wish there werent so many rules. I just wish we could do stuff what we want. Sometimes, something amazing can be missed just because there are rules. 

I hate rules. 

Tuesday, October 21, 2008

Class.getResource and ClassLoader.getResource

I better blog this down before I forget and do another couple of hours of research.
Class.getResource(): 
1. Resolves name you pass to it. If the name has a starting "/", then it takes it relative from the classpath. means.. "/config/x.txt" == in classpath, config/x.txt should be there
2. If you dont pass a starting "/" then it appends the package name to the file...so, if the name is "config/x.txt" and the class is com.xxx.MyClass, it will look for com/xxx/config/x.txt.
ClassLoader.getResource():
Doesnt do any name resolving. Delegates to parent classloader, if not found, looks in current classloader. 

This is my execution:
C:\workspace\CL\bin>java -cp .;CL-1.0.jar a.B
              
I have a config file called POS.properties in ./config folder.

I tried to read POS.properties in 3 ways.
(i) From main method, 
this.class.getResource(/config/POS.properties);
Will find it. From current path, it exists in config/
this.class.getResource(config/POS.properties);
Cant find it. From current path, Looks for in a/config/POS.properties. 
this.class.getClassLoader().getResource(/config/POS.properties);
Cant find it
this.class.getClassLoader().getResource(config/POS.properties);
Will find it.

Monday, September 15, 2008

el corte de madera creek, woodside , ca




Yup...hiking day. Somehow...Didnt have lot to blog these days..things went too fast or I wasnt in a mood.
It was totally amazing! For the first half, we were going down the hill...thru the mountains and just before entering the mountains ...we saw the sign that it was infested with rattle snakes and mountain lions...we were bloody shocked and looked at each other.. We were shit scared... Well, we went anyway...then almost one mile down the hill...we see no one...we were alone....we wud stop at every creaking sound. We wud be scared with rats making sound etc... we thought maybe we r at a wrong place and we shud go back.. then we were at a point when we were totally freaked out. and then we turned back and started to go....but then at the same nick of time...we see more hikers... phew..from then on we saw lot of bikers and people..so it was cool. Then while going back...GPS was taking us down the hill....only car can drive and there were edges of the mountain.... ..I was ultra cool....and then the unthinkable happened... another car came in the opposite direction!!!!!!! ...heheheheh...someone had to move back...and it was all edgey....I moved back..and the other car somehow managed to move.....phew phew phew...I still cant get over the excitment...hopefully we go to more hiking!!

Check more pictures here...

Tuesday, June 24, 2008

Its Stupid, stupid!

We are going into doing stuff with OSGi. OSGi does dynamic linking up and stuff. Osgi manages lifecycle also.

So I think, whats the difference between OSGi and JMX. Research tells me, JMXing OSGi bundles :o

I forgot abt that...Then I figured, whats the difference between OSGi and Webservices. hehehehe
Research tells me, how to mae OSGi bundles as webservices.

More comments when I becomes smarter.

Monday, June 9, 2008

Natasha Bedingfield

Decent song.

sarkar raj

If I had fast forward option, I would have seen the movie in 30mins. I dont remember seeing a more irritating movie. The music is so irritating, every stupid scene has music. You cant say the actors did a bad job. There was no substance in the story, what can they do. But, then you would say great actors rise above bad scripts. Well, you can say amitabh bachchan is one. He is the sole saving grace of the movie. Sheer class, unbelivable acting.

Absihek bachchan is a directors actor. It defnetly looks he does what the director says. The funniest part is he has a pissed off face in the movie. why? His pissed off expression doesnt evoke any seriousness. His characters seriousness is not visible. God knows why aishwarya rai is there in the movie.


Rao saab, and amitabh take the credit. And also one of the villans...who is with aishwarya rai.

Tuesday, May 27, 2008

TCS and Apple

You would think working for Apple is cool. Not if you from TCS. TCS'ers are treated like shit, like cheap monkeys. Three - four people are stuffed in a cubicle. If you were apple employee, then you get a single cubicle. Well, I am not sure if Apple treats all consultants like this OR if TCS is its favorite baby.

Sunday, May 18, 2008

Ennio Morricone

Got to listen to his scores!

Its music that makes up a movie. Malena has a terrific sound track. I kinda read about this composer, but didnt really notice. That was until I saw "once upon a time in america". You should hear deborahs theme.

Thursday, May 15, 2008

java2wsdl p2n

Real headache -

sh /axis2-1.4/bin/java2wsdl.sh -o . -of junks.wsdl -sn ILoveJunkServiceImpl -st DOCUMENT -u LITERAL -p2n [all,http://junks.com] -cn com.junks.JunkInterface

When you give p2n.. make sure there is no space between ',' and 'http'. Else you would end up with this error -

An error occured while generating codeString index out of range: -1

Tuesday, May 13, 2008

Die you fool!

Cricket! After 6-7 yrs of playing cricket, without having any exercise... I decide to join my colleagues for a game of cricket on saturday. Well, what happened next shudnt surprise anyone. I wont bore you with my travails on the field. 

What happened after the play is interesting.. I pulled my muscle in the thigh during game 1. I continue playing, lets call it hamstring injury. I fall down..almost have dislocated shoulder. Stomach cramps. I couldt walk up the stairs. I couldnt take my laptop from hall to restroom. I forgot to buy food...so had to make some food...and then had the sleep of my life. 
Me going to play next week as well! :D if I wake up...

Friday, May 9, 2008

My top 10 scenes in movies

Lets see...here they are in no particular order, or maybe I will put the order later -

1. Goodfellas - Walk in the restaurant .. The song "then he kissed me is played".
2. Once upon a time in america - The background of the bridge when they are walking scene
3.
rest later...when I rememeber

Tuesday, May 6, 2008

Plagiarism by Homer?

I was watching hercules last night. It was a horrible horrible movie. Anyway, I was thinkin about Achilles and the trojan war. And bingo! Something hit me. There is a freaky similarity between mahabharata and the trojan war. Both wars were based around a woman. Trojan war had Achilles, who dies upon being hit on his heel. Mahabharata had Krishna, who doesnt die during the war, but is hit on the heel too!!

Should I get a life?

Monday, April 28, 2008

BoobBox??

Monday again. Start wasnt good. Roomie and me have a tiff. I got to be more tolerant. And my car repair costs 700$ :( 

Not even sure what the issue was. Need to check it out. Well, by now the "boobbox" heading would have caused enough impatience... 

I was talking to one of my friends. Lets call her cleopatra. So, cleopatra and me are talking about music systems. I mention that I had bought  my mom this sony mini-radio/taperecorder thing. Still cant remember the name. So she blurts out ...boobbox? (she wanted to say boombox). It was so spontaneous and so funny. If I were outside...I wud have laughed until tears came out. In office, I had to hold my laughter until my face became red. btw, she was sooooooo  embarrassed, in her terms.

Geez, that was quite a spelling mistake!!

Thursday, April 24, 2008

Marrisa mayer

She is absolutely amazing! Check this out - http://www.sanfranmag.com/story/adventures-marissa#story_top

Sunday, April 20, 2008

what happened on weekend

Phriday - Went to "forgetting sarah marshall". Real load of crap. Cheap dirty jokes. Male frontal nudity. Had to do lot of stuff on saturday, atleast planned to do a lot of stuff. Slept at 3:45pm :( and then woke up at 11:30 . There was a macys sale going on. Rushed to see if anything good was going on. Big disappointment. Missed the car registration. Need to go on munday. Then came back and dozed off until 900pm :( That was very disappointing.. :( Again 3:00 until sunday morning. Woke up @ 2:00 and went out with few frnds.
Went to see google office!! It was impressive!! I mean it was like home... the food was free and was all around. There was gym. fooze ball, table tennis. I mean for christs sake there was a fooze ball table outside a conference room. Totally totally informal. I like it that way. Played the fooze ball for sometime...was interesting! Then went to dinner to my roomies frnds place. I didnt want to go..I mean firstly I am socially inept and then I didnt know these ppl well enough. Well, I had to go anyway... But it didnt suck...had some good time!!
So sunday was "ok". Google was cool. You have to just work there... before the fuzz dies out.

Sunday, April 13, 2008

Cache creek

We went to atlantic city thinking we wont find any casino in CA. Guess what? This is a sin city. There are more casinos here than you can imagine. But they all suck. They dont have the money. It shows. Atlantic city was rich, classy. The games here was shitty too.

Roulette... I didnt see the numbers at first. I thought the wheel was spinning real fast. Then I thought this was way too advanced..that the numbers disappeared. Guess what!! The color where the ball falls.. a respective color card is picked up... Geez.

Ditto with craps. The higher dice, gets the respective color card picked up.

Well, they gave us 25$ bonus points since it was our first time. But you had to put 1$ to start with. I did and won 80$. It was on a 5cent machine. So didnt mind the winning!

And hey, apparently, its cheap to pay for your food. but not cheap to thrust your stuff on others throats.