



Well.. maybe not..
Anyway, I’ve read a topic here about webservices in java, and it seems that custom objects are not supported.. *sigh*
I needed to think of another way to sent data from the server to client and parse that to the frontend..
What i did was creating a method that returned a String and passed that string to the client. After recieving the string from the server to the client I needed to “decompose / split” the string into smaller pieces uses regex and fill the data into a two dimensional array to iterate it trough the JSP using taglibs.
It took me some time to figure out how to do this but i managed it although I can’t shake this feeling off my head that this way of sending data to the client is not the way is supposed to. I’ll look further into this as the project progresses and see if I can find a “cleaner” way to do this.

The code does what its supposed to do but I wished that my code was as clean as this kitchen above.
Below are some code examples i wrote so that you can see how i did this to sent data from the server to client.
This is the code that i wrote to get the data from the HSQL:
@WebMethod
@PermitAll
public String getAllUsers(){
Query q = entityManager.createQuery(”select id,naam,role from AddUsersEjb”);
List result1 = q.getResultList();
String endResult = “”;
Iterator it = result1.iterator();
int i = 0;
Object[] o = null ;
while ( it.hasNext() ) {
o = (Object[]) it.next();
endResult = endResult + “\n [,]” + o[0].toString() + “[,]” + o[1].toString() + “[,]” + o[2].toString();
}
return endResult;
}
This code shows how to split the String array and fill the data into a 2d string array:
System.out.println(”port.getAllUsers()”);
String tmp = port.getAllUsers();
String [] temp = tmp.split(”\\[,]“);
int arrayLength = temp.length/3;
System.out.println(”arrayLength”+ arrayLength);
String[][] arraytjeTwee = new String[arrayLength][3];
try{
int m = 1;
int n = 2;
int o = 3;
for (int i = 0; i< arrayLength; i++){
int j = 0;
int k = 1;
int l = 2;
for (j = 0; j < 3; j++) {
arraytjeTwee[i][j] = temp[m];
arraytjeTwee[i][k] = temp[n];
arraytjeTwee[i][l] = temp[o];
}
m = m+3;
n = n+3;
o = o+3;
System.out.println(”array2d: 1 ” + arraytjeTwee[i][0]);
System.out.println(”array2d: 2 ” + arraytjeTwee[i][1]);
System.out.println(”array2d: 3 ” + arraytjeTwee[i][2]);
}
}catch(Exception e){
}
And finally in the JSP to show the results:
<ejb:for var=”row” begin=”0″ end=”${ejb:length(userOverviewBean.list)}”> <tr><td>${userOverviewBean.list[row][0]}</td><td>${userOverviewBean.list[row][1]}</td><td>${userOverviewBean.list[row][2]}</td></tr>
</ejb:for>

Regards,
Happyface
www.engineeringserver.com




Today I managed to fix the Jaas problem I had earlier by changing the login-config.xml and jboss-service.xml like this:
jboss-service.xml
<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE server
PUBLIC “-//JBoss//DTD MBean Service 4.0//EN”
“http://www.jboss.org/j2ee/dtd/jboss-service_4_0.dtd“
>
<server>
<mbean code=”org.jboss.security.auth.login.DynamicLoginConfig”
name=”JAASExample:service=DynamicLoginConfig”>
<attribute name=”AuthConfig”>META-INF/login-config.xml</attribute>
<depends optional-attribute-name=”LoginConfigService”>
jboss.security:service=XMLLoginConfig
</depends>
<depends optional-attribute-name=”SecurityManagerService”>
jboss.security:service=JaasSecurityManager
</depends>
</mbean>
</server>
login-config.xml
<?xml version=’1.0′?>
<!DOCTYPE policy
PUBLIC “-//JBoss//DTD JBOSS Security Config 3.0//EN”
“http://www.jboss.org/j2ee/dtd/security_config.dtd“>
<policy>
<application-policy name=”TestDomain”>
<authentication>
<login-module code=”org.jboss.security.auth.spi.DatabaseServerLoginModule”
flag=”required”>
<module-option name=”dsJndiName”>java:/DefaultDS</module-option>
<module-option name=”principalsQuery”>
select passwd from Users username where username=?</module-option>
<module-option name=”rolesQuery”>
select userRoles, ‘Roles’ from UserRoles where username=?</module-option>
</login-module>
</authentication>
</application-policy>
</policy>
Instead of having hardcoded users in the MyLoginModule we are now checking if the users are known in the database. Currently the passwords are stored as plain text but i’ll fix this later using MD5 (base64) salt. I’ll probably use this one: http://java.sun.com/j2se/1.4.2/docs/api/java/security/MessageDigest.html

Bomba, the drink that makes you feel like a soldier.





Ok so I got a job as this worldwide companys Information Technology/Information Service department. It takes cares of the whole country. Its a logistics company. So everything needs to work or planes, trucks, ships etc might get delayed. Or the cargo/shipment etc might miss it. Then someone has to pay the delays. Or sometimes some system is’nt working and packages go missing for hours…
Anyway Arkie asked me to write what have I done there so far. Luckily I have written a short “diary” for myself about what I have done there
I’ve been there for 3 weeks now. Was at the biggest office for the first 2 weeks. Then got transferred to this airport office instead since they got another new employee as well and chose me to go to this 2nd place.
The bigger place, I’ll call it BP(business park) from now on. Had quite a hectic atmosphere. Everything felt like it was messed up from the day I started there. And everything had a huge hurry. Then at the 2nd, smaller place at the airport area. Things over there seems really organized and calm. Seemed the opposite from BP. Going from ~3000 people building to ~500 people building. Guess it was inevitable. But I dont mind, anything has’nt been bad so far at least.
One thing that got me surprized was. That I got admin acces really fast and easily. Also a “all areas acces key” on the airport area building when I got transferred there. I did’nt expect it to be that easy to get those. Made me wonder if I was an enemy of the company how “easily” I could harm them. But I wont since I’ve been liking working there so far
But guess they have to, if they expect me to do my job. I need those accesses.

Week 1: The first day I got there. My accounts and passwords we’rnt ready. Someone had forgotten to fill an application for me to get those. I did’nt have a desk either. So they were really prepared for me comming there. I sat next to the service desk team leader the first day pretty much. She explained what she was doing most of the time so I learnt quite alot that day just by watching.
Watching how the service desk was working. How the calls/service requests my email were answered to and prioritized.
Then I had 2hours Active Directory course over there with 3 other people. They taught us the basic structure of their AD and how are we allowed to administrate it.
I got to organize the “electronic” warehouse… I moved maybe 1km of different type of cables into boxes. Piled the boxes up, got quite alot more room there.
Was testing old computers from a quite small room for old computer stuff. 90% of the computers I tested did’nt work. So we took out the RAM from those. And those which did work. We added ram so they had at least 512mb of RAM. Organized this small room for old computers as well. Was quite a simple job. New computers on spesific location. Old in another. And not working ones to their own spot. Then the “misc” stuff to own spot as well.
Also had to edit this excel file with all my countrys emplyees in it. Had over 5000 lines, cant remember exactly how many though. Had to edit almost every line. And compare the persons information in the excel file with AD’s information and some other databases information. Then update it accordingly to the newer one. This took me almost 2 days. Was a pain as well.
Rest of that week I was dropping images (complete windows xp installations with needed corporate programs etc in it) to new computers they had recieved a while ago. Was quite a easy and nice job. Could spend alot of time surfing the interned while waiting for the images to be copied to the harddrives.
Week 2:
I continue dropping images to the remaining new computers, there was’nt that many of those left. After that I got this brand new and super small laptop. I was supposed to find drivers for it. Took me 5 minutes to find the power on-button from it :P. Was hidden quite well. But after that every driver and update was quite easy to find, thanks to Dells awesome website.
Learnt a bit more about doing new service tickets, how to do those the correct way. To make the persons life easier who needs to process it. Also learnt alot about outlook, which I have never used until that week :P. Was quite simple stuff. How to add an account, how to do/add archive files to outlook.
Had quite a “funny” problem at the accounting side. One person could not acces his outlook since her account was migrated from one domain to another (theres this migration going on, has been for some months, from the country wide ad to the global ad). So they first sent me, to check that she had all the settings in outlook correct. She did have. I had no clue what was the problem. Then they sent me to install a new outlook for her if it got fixed that way. But I could’nt install it
not sure why.
Well after that this “wise” guy who has (I think so at least) lots of experience from before. Came. Checked stuff. He found out the accountings firewall did’nt let outlook through. (account has a really tough firewall, since they take care of the money there). So this guy made a few calls. And soon we got a ping through to the email server. Which we did’nt a while before. The problem did’nt solve…
Then they started to investigate more. This person had 2 email accounts with the exact same name on the new and old domain for some reason… And the emails kept going to the wrong email account. And since she was with the accounting they did’nt want to delete the old mailbox. Who knows what important stuff was there (for any even close to a ordinary person the another mailbox woulda gotten deleted instantly). So they had to contact the global helpdesk for that company. Who did something and got rid of the 2nd mail account. With the messages there to the new one.
Kind of funny since they sent a newbie like me to solve it on the first place
I got to do more service tickets.
Then on friday. Death came. There was some outlook update that did’nt automaticly add peoples archives to outlook. So many help calls and emails asking about that. That was the last day probably that I had something to learn about outlook. Everything about outlook came crystal clear
They even let me answer the phone on that day for the first time. Since there was so many calls and requests. I solved quite many requests that day. And even made one call to a person regarding the ticket she had made. Asking for more information. Rather than email.
Someone asked me to “fix” a computer from the “training room” (room with a projector and many computers meant for training/teaching/some course). So I logged on with my admin account. Could’nt find anything that needed fixing. Logged off, went back and sent back an email. I had checked the computer. Then someone went checking if it was working properly and it was. They thanked for “fixing” it.
Week 3:
This 3rd week I got transferred to the smaller place, in an airport area. On the first day me being there. Some backup server got installed there. Was quite nice to watch it getting installed. Anything did’nt really seem that hard.
After that I installed 7 images to 7 laptops. Most problems in this smaller place were about printer not working. And it usually was solved by restarting the printer. There was one problem where the printer had disappeared wholely from the reception ladys so they could’nt print anything to the printer behind them. I tried and tried to add, but nothing worked. Then I got another admin account with more rights than before, installed a new driver for printers. And it started working.
Had a problem with VPN connections certificate missing. I had no clue how to get a new one. I tested stuff. But did’nt get it working. Then a bit later this another guy there at IT showed how. And I was quite close to get it right but still not close enough.
Then a bad thing happened. One persons harddrive from his laptop got trashed. I’m not sure why, but guess he had been throwing his laptop around the walls or something (was like 5 years old computer though). He needed the files back fast. And a new computer. Luckily I had been installing the images there earlier. He got a working laptop in an hour. But his harddrive was not working for us. Had to send it to Norway to some special data recovery place. It cost a bit over 7k euros to get the data back. After that I realized how much information is really worth. I knew it could be alot. But actually being next when this guy says 3k euros and you get it in maybe a 5 working days. Or 7k euros and in 3 days max. They chose the 3days one.
I got my own “key” to the building. Its electroinc key though. Small plastic card that you show to these scanners and then doors open if you have the right to open the door in the card. Was a bit funny though. When I was getting the card, the guy was wondering what kind of acces do I need since I’m from IT/IS. He was’nt sure and I was’nt sure since I was new there. Then he was like “Oh well I’ll give it all”. And now I get everywhere there I think.
Lastly that week. People wanted to get email working on their Nokia Communicators. And they had no clue how to. So I took one of their phones and tested around a while trying different IPs etc what I could choose from the options. And finally got working. After getting one to work I could help 2 other persons with that problem as well. I think I’m doing fine a the new place.
At least its alot more easier enviroment for me to work and relaxing. Than that Business Park, where everything was always hectic.




Todays progress:
- added 3 user roles (hardcoded..) , the user roles should be retrieved from the database but i’m unable to do this so far, see below for more info.
- added servlet permissions per user role (you can’t access certain servlets / JSP’s if you don’t have the permission, like “customer” can’t visit “admin” pages)
- created an util page in the admin area to test things out that im currently working on (taglibs etc)
- ..some minor changes in servlets & JSP’s
Jaas ( Java Authentication and Authorization Service) database login
I’m currently trying to get users from the hypersonic database trough the Jaas loginmodule, the problem is that im not sure how to get the user data from teh database . Ive read some tutorials about getting users from the database but that didn’t work for me. Oh well, i’ll keep trying and see what i can do.
I managed to retrieve the username, password & roles from the database by creating a method that performs a query after you hit the submit button from the login page but he problem is that the roles that are retrieved from the database are not known in the hardcoded JAAS loginmodule so that the JAAS loginmodule doesn’t recognize the roles from the database.. once i find a way to retrieve the roles I can get the users from the database so that the login is dynamic.
I haven’t defined a retard role, but damn i’m tempted.

.. guess what i’ll be doing this entire weekend? (nah, not playing ninja like that guy above me)
.. that and testing / writing a demo application that uses the Java SE Security technology. ( http://java.sun.com/javase/technologies/security/ , Cryptography API)
Regards,
HappyFace
www.engineeringserver.com




A small update on today’s progress:
Finished today:
- add user to database
- remove user from database
Currently in development:
- show all users using taglibs
I’m currently trying to add taglibs to iterate all the users from the database to the JSP but I keep getting:
org.apache.jasper.JasperException: /UserExplore.jsp(14,2) Unable to load tag handler class “tags.IfTag” for tag “ejb:if”
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:198)
org.apache.jasper.compiler.Parser.parseCustomTag(Parser.java:1224)
org.apache.jasper.compiler.Parser.parseElements(Parser.java:1449)
The tags *should* work but for some reason the class doesn’t compile and fails to load these imports:
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;
Although when I manually type: import javax.servlet.jsp….. the package(s) CAN be found. Weird.. oh well, i’ll look this up first thing tomorrow
Here’s a screenshot for those that are interested in the Manager admin menu that i’ve been working on today, nothing fancy but it works functionality wise. The pretty shiny layout can always be added later ![]()



More Options ...
Categories
Tag Cloud
Blog RSS
Comments RSS

Void « Default
Life
Earth
Wind
Water
Fire
Light 