Showing posts with label alui. Show all posts
Showing posts with label alui. Show all posts

Wednesday, October 20, 2010

Encrypting and decrypting portlet properties in Oracle WCI Portal

A useful feature from Oracle WCI portal is the possibility to save crypted portlet properties. Using an private key by the portlet administrator, enables him to save the encrypted settings and then by using an public key to read the information into the portlet view page. 
To do this first we have to generate private and public key. You can generate public key using some of the tools in internet or just use java by doing the following:
1 // RSA by default 1024bit 2 KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA"); 3 4 KeyPair generatedKeyPair = keyGen.genKeyPair(); 5 6 // save the keys 7 PrivateKey privateKey = keyPair.getPrivate(); 8 PublicKey publicKey = keyPair.getPublic(); 9 10 X509EncodedKeySpec x509EncodedKeySpec = new X509EncodedKeySpec(publicKey.getEncoded()); 11 12 // save the public key 13 FileOutputStream fos = new FileOutputStream("public.key"); 14 fos.write(x509EncodedKeySpec.getEncoded()); 15 fos.close(); 16 17 // save the private key 18 PKCS8EncodedKeySpec pkcs8EncodedKeySpec = new PKCS8EncodedKeySpec( 19 privateKey.getEncoded()); 20 fos = new FileOutputStream("private.key"); 21 fos.write(pkcs8EncodedKeySpec.getEncoded()); 22 fos.close(); 23 24 25 26




We do have now our RSA public and private keys which we will use to decrypt and encrypt the portlet setting. In our portlet application we have to read those keys and generate KeyPair which then we use inside the Chiper to decrypt or encrypt the properties. The code bellow shows you how to read the keys and generate the key pairs.




1 // get the cipher and load the private key 2 Cipher cipher = Cipher.getInstance("RSA"); 3 4 // Read Public Key. 5 File filePublicKey = new File("public.key"); 6 FileInputStream fis = new FileInputStream("public.key"); 7 byte[] encodedPublicKey = new byte[(int) filePublicKey.length()]; 8 fis.read(encodedPublicKey); 9 fis.close(); 10 11 // Read Private Key. 12 File filePrivateKey = new File("private.key"); 13 fis = new FileInputStream("private.key"); 14 byte[] encodedPrivateKey = new byte[(int) filePrivateKey.length()]; 15 fis.read(encodedPrivateKey); 16 fis.close(); 17 18 // Generate KeyPair. 19 KeyFactory keyFactory = KeyFactory.getInstance(algorithm); 20 X509EncodedKeySpec publicKeySpec = new X509EncodedKeySpec(encodedPublicKey); 21 22 PublicKey publicKey = keyFactory.generatePublic(publicKeySpec); 23 PKCS8EncodedKeySpec privateKeySpec = new PKCS8EncodedKeySpec(encodedPrivateKey); 24 PrivateKey privateKey = keyFactory.generatePrivate(privateKeySpec); 25 26 KeyPair keyPari = new KeyPair(publicKey, privateKey); 27




Having the KeyPair we can do the decrypting and encrypting process and then save this information inside the WCI portlet settings.


1 // code follows 2 3 // to encrypt property and then save 4 cipher.init(Cipher.ENCRYPT_MODE, keyPair.getPublic()); 5 6 portletContext.getResponse().setEncryptedSettingValue(SettingType.Portlet, "YourPropertyName", propertyValue, cipher); 7 8 9 // to read a encrypted property 10 cipher.init(Cipher.DECRYPT_MODE, keyPair.getPrivate()); 11 String prop = portletContext.getRequest().getEncryptedSettingValue(SettingType.Portlet, "YourPropertyName", cipher); 12 13 14 15 16 17

Monday, July 19, 2010

WCI Updates in Oracle Metalink

I’ve been asked several times, how to search and download patches and updates for the WCI portal. The support for WCI is very healthy and gives a lot of optimizations/updates you can install. Using the new Metalink interface is very easy to do, let’s start:

  • First thing you have to do, login into the Metalink (Oracle Support) portal using your customer account.
  • Inside the Metalink portal click on the Patches & Updates

image

  • On the right side you do have now a several options to search for :

image

  • Because we want to search for specific product, click on the link Product or Family (Advanced Search). The application will change the searchable options with the following screen:

image

  • In field Product type the name of the product, for example “Interactions”. You will get a list with suggestions, from which you can select the product you want. From the Release drop-down, select the version for which you look for updates. Next you can select the platform you run your portal application, like shown on the screen bellow:

image

  • Click now on search and you will get a screen with all available updates.  

Monday, April 27, 2009

Connect to the ALI LDAP Directory Service

Starting with version 6.5 from the ALUI Portal now WebCenter Interaction the development team released a new service calls ALI LDAP Directory. This is a completely LDAP service which allows you to connect external applications more easier. If you get for example Ldapbrowser tool which you can download for free on the the this link, you can test how it works. To connect to the ALI LDAP Service you need the following information:

Host: the machine on which ALI LDAP has been installed
Base: ou=users,dc=bea,dc=com - this is the base where all groups and users are stored
User DN: uid=administrator,ou=users,dc=bea,dc=com

For 'uid' I used administrator, but you can use another account from the portal. Knowing this you can for example implement authentication from external application against the portal, which are not working in portal context!

cheers