Tuesday, June 14, 2016

How to connect OpenAM and Spring Security to do Single Sign On (SSO)?

There is a list of previous steps for doing SSO between a Web app and OpenAm and the most important things are:
  1.  Start OpenAM and well configurated server.
  2.  Create users and specificate the rol names.
  3.  Install agentapp inside webserver
  4.  Execute agentadmin to create a policy between webapp and openam.
All those steps require some time, in the application context we need to do some configuration in context for conclude AAA, Authentication is taking for OpenAM, Authorization is given by Spring Security and OpenAM interconnection and Accounting is doing for WebApp when it asign the corresponding roles and access to the client (by now we are going to do some federation), so here the short list of configuration for doing with Spring security:

1. First required artifact in the app:

2. Start spring context with spring security:

3. The most import part filters and connection to retry OpenAM config:

4. Create the shared cookie:

5. The amconfig properties to taking url, user and password

For the application is kind of simple for just federate permissions between components.

Important link:

Saturday, June 11, 2016

How to solve 'ISAM error: the file is locked' on Informix after using jdbc?

I have a Teacher/Sensei who teach me a lot the theory and principles of database engine really works his name is ++++++ a consultant and expert on Oracle, we worked together some months ago, my experience at that time was with Oracle Database 11g and Oracle Enterprise Manager, using some past knowledge I have to encourage a relative problem with Informix called "Dirty Reads" he explained to me that is a bad practice of consulting, updating or inserting data.

Informix is more sensible and treats data carefully based on ISAM which are algorithms in database in response a petition of users, so database principles are the same in other database engine, but on the other hand, at Oracle the engine resolves this problem internally and produce a problem or cost when it represents a problem causing interruptions in database, one of those is the best post I have introduced:

http://codefixes.blogspot.mx/2016/05/possible-solution-for-isam-error-key.html

When your process is concurrent and you have multiple users in the background pieces of data have to move on in the engine, if you do not measure and take the cost of queries that you are sending to database eventually you degrade the performance of your application, a problem could be at the next one:

 ISAM error: the file is locked (http://www.oninit.com/errorcode/index.php?pageid=-113)

For solving this kind of problems are two paths, one is correct the application (the better one) or give more time of waiting for the database (mitigating), so please check your query if you are doing an update of a bunch of elements you should go through the primary key o indexed fields, or in it is the case in a select check your where statement and modified to go to indexing field:

update table set column = :column1 where idprimarykey in (:idprimarykey);
select column1, column2, column3 from table where  idprimarykey in (:idprimarykey);

The other method is gained more time in transaction is not an effective way but informix provided:
...
> echo "set isolation to dirty read; select count(*) from customer;" | dbaccess stores_demo
... 
> echo "set lock mode to wait; select count(*) from customer;" | dbaccess stores_demo
...
http://www-01.ibm.com/support/docview.wss?uid=swg21508233

Dirty data are not welcomed to the database and you must carry the access to objects where are you doing transactions and service who are using it. 

Another important configuration when are using Informix is take care of Transaction Isolation and propagations after reading the documentation, Informix does not support readonly=true, and propagation must be in Serializable for betters ways, something like this if you are using spring framework:

@Transactional(value = "XXXXTransaccionManager", readOnly = false, propagation = Propagation.REQUIRED, timeout = 6000,isolation = Isolation.READ_COMMITTED)

And take care of using a version superior of 3 in the driver because it have some problems in the writing.


Best Regards, 

Important links:

How to web service client built in Perl for testing purpose?

Sometimes we are in a server terminal and we need to test webservice behavior, so based in what we have running scripts in perl. 

Option 1: One file of test


1. The client program: 


2. Execution line: 

$ perl soap_action_ws_test.pl > soap_action_ws_test.log

Option 2: With external file:

1. Request XML


2. The client program:


3. Execution line: 

$ perl soap_action_ws_test_2.pl > soap_action_ws_test_2.log

Option 3: Load external file by command line

1. The client program:


 
2. Execution line: 

$ perl soap_action_ws_test.pl  /home/user/code/perl/consultarSalariesPorRangoRequest.xml > soap_action_ws_test.log

Important sources:
Tested on:

  • Centos
  • HP-UX
  • Ubuntu 
Best regards,