Monday, September 24, 2012

Difference between SID and Service for WLST Config


How to define a datasource in Oracle WebLogic WLST Configuration

For a SID:
<attribute name="Url" value="jdbc:oracle:thin:@hostname:1521:SID" />

For a Service:
<attribute name="Url" value="jdbc:oracle:thin:@hostname:1521/Service" />

Monday, September 10, 2012

javax.security.auth.callback.UnsupportedCallbackException: [Security:090175]

Application throwing Unrecognized Callback exception when connecting through t3:
javax.security.auth.callback.UnsupportedCallbackException: [Security:090175]Unrecognized Callback com.abc.def.security.identityassertion.DramaCallback@32a4755]
at weblogic.jndi.internal.ExceptionTranslator.toNamingException(ExceptionTranslator.java:44)
at weblogic.jndi.WLInitialContextFactoryDelegate.toNamingException(WLInitialContextFactoryDelegate.java:788)
at weblogic.jndi.WLInitialContextFactoryDelegate.pushSubject(WLInitialContextFactoryDelegate.java:675)
at weblogic.jndi.WLInitialContextFactoryDelegate.newContext(WLInitialContextFactoryDelegate.java:469)
at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLInitialContextFactoryDelegate.java:376)
at weblogic.jndi.Environment.getContext(Environment.java:315)
at weblogic.jndi.Environment.getContext(Environment.java:285)
at weblogic.jndi.Environment.createInitialContext(Environment.java:208)
at weblogic.jndi.Environment.getInitialContext(Environment.java:192)
at weblogic.jndi.Environment.getInitialContext(Environment.java:170)
at weblogic.jndi.Environment.getContext(Environment.java:215)


Normally the application works fine when connected through http protocol.
Following are the suggestions to get rid of this error:
1. Move the default SQL authenticator to the top and make it sufficient
2. Don't throw any exception when UnsupportedCallbackException is caught during callback handler handle call

However you may need to watch out for the pros and cons of these solutions provided here.

Default Roles not listed when using RolePolicyManager api


When using RolePolicyManager api, default roles are not listed
If no roles are created by default following two roles are provided for each portal web application:
- AnonymousVisitor
- AuthenticatedVisitor
These can be verified using portal admin console, however these never appear when using the following api:
RolePolicyManager.listRolesForResource(EARName, WEBName, EntitlementConstants.P13N_ROLE_POLICY_POOL);
To make these default roles visible, create a custom role in the web application and same api will list all the three roles:
- AnonymousVisitor
- AuthenticatedVisitor
- Custom role

Find out if database sessions are locked


To Check if there is any database session locked

SELECT s1.username || '@' || s1.machine
    || ' ( SID=' || s1.sid || ' )  is blocking '
    || s2.username || '@' || s2.machine || ' ( SID=' || s2.sid || ' ) ' AS blocking_status
    FROM v$lock l1, v$session s1, v$lock l2, v$session s2
    WHERE s1.sid=l1.sid AND s2.sid=l2.sid
    AND l1.BLOCK=1 AND l2.request > 0
    AND l1.id1 = l2.id1
    AND l2.id2 = l2.id2 ;

select * from v$lock
select * from v$session

Display the session count, max sessions, highwater etc.
select sessions_max, sessions_current, sessions_highwater from v$license;

Oracle sample queries


Sample Oracle queries run on 11g (and 10g comparisons)

Query to display stored procedures:
select OBJECT_NAME from user_procedures
select OBJECT_NAME from user_objects where object_type = 'PROCEDURE'
both returns list of stored procedures
"select OBJECT_NAME from user_procedures" returns the stored procedures and triggers as well for Oracle 11g while
"select OBJECT_NAME from user_objects where object_type = 'PROCEDURE'" returns list of stored procedures only

select * from user_sequences
select * from user_objects where object_type = 'SEQUENCE'

select * from user_tables
select * from user_objects where object_type = 'TABLE'

select * from user_triggers
select * from user_objects where object_type = 'TRIGGER'

select * from user_indexes in 10g returns the LOB as well
select * from user_objects where object_type = 'INDEX'

Display all the roles, previleges, tables
select * from user_tab_privs order by grantee, table_name

Display all the synonyms for the table owner
SELECT * FROM all_synonyms where table_owner = 'XYZ' order by owner, synonym_name;

Select from a table and concat two or more columns
SELECT column1_name || ' # ' || column2_name  as column_both FROM table_name

Grant Privileges on tables/sequences to a role
grant select/insert/update/delete on [Schema].[Table/Sequence] to [Role_Name];

Create public synonyms for table, views, sequences

Create public synonyms for table, views, sequences for the schema XYZSchema


declare
  CURSOR xcur is
    select object_name, object_type from all_objects
where object_type IN ('TABLE', 'VIEW', 'SEQUENCE')
and owner = 'XYZSchema'
     ;

    xdat xcur%ROWTYPE;

begin
  for xdat in xcur loop
    begin
      execute immediate 'create or replace public synonym '|| xdat.object_name || ' for XYZSchema.'||xdat.object_name;
    exception when others
     then null;
    end;
   end loop;
 end;
/