Showing posts with label Weblogic. Show all posts
Showing posts with label Weblogic. Show all posts

Thursday, September 8, 2011

How to Create JDBC Connection Pool In Weblogic

Open weblogic admin console (home page) and go to “Services” tab in the left panel.


Click on “JDBC” on the right panel. It will open the following screen.



Click on “Data Sources”. It will open the following screen. Then click on “New” to create a new Connection Pool.

Enter the required details as shown for the below screen


Name : Enter appropriate name for the connection pool.
JNDI Name : Enter appropriate JNDI name for the connection pool.
Database Type : Select appropriate database type. In case of CPS its “Oracle”.

Database Driver : Select appropriate database driver. In case of CPS its “Oracle’s Driver (Thin)

Versions :9.0.1, 9.2.0,10,11”.
Click on “Next” after entering the details.

 
Click on “Next” once the below screen appears.


Enter the required connection properties for the database connection as shown below :

Database Name : Enter the appropriate database name (i.e. Service Identifier of the database).

Host Name : Enter the appropriate host IP address of database.

Port : Enter the appropriate Port No to connect to database.

Database User Name : Enter the appropriate database User Name to connect to database.

Password : Enter the appropriate password to connect to database.

Confirm Password : Enter the password again for confirmation.



Click on “Next” after entering the connection properties.



 
On clicking “Next” two more text area appears. Click on “Test Configuration” to test whether the connection is successfully established or not.

A message appears on the top of the screen stating whether the connection test is successful or not.

If the test is successful, click on “Next”.


Then create a new JDBC Data Source. Select a server from the list displayed on the screen. If the desired server name is not displayed on the screen, then go to targets and select the appropriate server name.



 
Then Click on “Finish”.




The following screen will appear which indicates that the datasource is successfully created.



 
If the properties of the connection pool needs to be changed at any point of time, then click on the datasource name displayed on the previous step. The following screen will appear.


Navigate through the displayed tabs to view the various connection pool related properties. If required, edit them and click on “Save”. The edited properties will be saved.

Sunday, July 3, 2011

Setting Up Basic Authentication in Weblogic

Most of the times, it is recommended to use basic authentication mechanism for security purposes, if the SSL security can not be implemented. Here, I am going to show you the mechanism to do that in weblogic server. We need to do amendments in three areas; weblogic server, web.xml and weblogic.xml files.

Hope you enjoy the ride of it.
Create user, group and role in weblogic server.
Open weblogic admin console (home page) and go to “Security Realms” in the left panel





Create the users, groups and roles in weblogic domain
Click on myrealm link


















Click on Users and Groups section























Click on New in User section






















Put Name as “user”; Description as “user”; Password as “password”


















Click on OK to successfully create the user


Click on Groups section to create new group

















Click on New button and provide
Name: usergroup; Description: usergroup; Provider: DefaultAuthenticator
Click on OK to successfully create the usergroup.



Go on “Roles and Policies” section
















Click on ‘+’ to expand the Global Roles link. Click on Roles. It will Open Global Roles Page
















Click on New – Enter new role name

Provide role name as “consumer” provider name as XACMLRoleMapper (note: it is showing as a default one; don’t need to change it)
















Click ‘OK’ after entering the role name, it returns back to the ‘Global Roles’ page with newly created ‘Role’


Click on “Users and Groups” tab or link as part of Navigation bar. Go to Users tab



















Go to the Users section and Click on the “user” hyperlink. It opens the ‘Settings of the user-name’ screen.




















Go to “Groups” section and Select the ‘uergroup’ from the Available list of Groups. Move the selected ‘uergroup’ to right list (Chosen). Click on Save



















Click on “Security Realms” link and then link on myrealm and Go on ‘Roles and Policies’ tab



Click on ‘Global Roles’ + symbol – it expand as in tree-hierarchy


Click on ‘Roles’ + symbol – it expand as in tree-hierarchy


















Select the Radio Button against the newly created Role (consumer), then click on ‘Edit Role’ button


Click on Add Condition button. Choose ‘Group’ as the predicate and click on Next



















Choose ‘Group’ in the Predicate List and click on Next





















On the next page, type the Group name as “usergroup” and click ‘Add’


Click on Finish. On the next page, select the CheckBox against the Group name and Save


















Entries in web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
      id="WebApp_ID" version="2.5">
      <display-name>Sample Rest Interface</display-name>
      <servlet>
            <servlet-name>Sample Rest Interface</servlet-name>
            <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
            <init-param>
                  <param-name>com.sun.jersey.config.property.packages</param-name>
                  <param-value>test</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>
      </servlet>
      <servlet-mapping>
            <servlet-name>Sample Rest Interface</servlet-name>
            <url-pattern>/*</url-pattern>
      </servlet-mapping>
       <security-constraint>
            <web-resource-collection>    
                  <web-resource-name>webservice</web-resource-name>
                  <url-pattern>/*</url-pattern>
                  <http-method>POST</http-method>
            </web-resource-collection>

             <auth-constraint>
                  <role-name>consumer</role-name>
           </auth-constraint>
     </security-constraint>
      <login-config>
            <auth-method>BASIC</auth-method>
            <realm-name>default</realm-name>
      </login-config>
     <security-role>
            <role-name>consumer</role-name>
      </security-role>
</web-app>

Changes in Weblogic.xml
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.2/weblogic-web-app.xsd">
      <security-role-assignment>
            <role-name>consumer</role-name>
            <principal-name>usergroup</principal-name>
      </security-role-assignment>
</weblogic-web-app>
 

Total Pageviews