Thursday, October 24, 2024

Admin Tips

 To copy files from one linux box to the other linux box:

Using SCP - 

To copy a file from B to A while logged into B:

scp /path/to/file username@a:/path/to/destination

To copy a file from B to A while logged into A:

scp username@b:/path/to/file /path/to/destination

Wednesday, November 24, 2021

Decrypt WebLogic Server Admin Password/SOA DB schema password



  • recover database username and password of JDBC Connection pool – encrypted password resides in $DOMAIN_HOME/config/jdbc directory, in xml files
  • recover password of a keystore where we store SSL certificates
  • any encrypted password from config.xml  located in $DOMAIN_HOME/config dir
Let’s roll:
NOTESerializedSystemIni.dat file exists in $DOMAIN_HOME/security directory. 
1. Create a script decrypt_password.py in $DOMAIN_HOME/security directory and paste the following code into it:
from weblogic.security.internal import *
from weblogic.security.internal.encryption import *
encryptionService = SerializedSystemIni.getEncryptionService(".")
clearOrEncryptService = ClearOrEncryptedService(encryptionService)

# Take encrypt password from user
pwd = raw_input("Paste encrypted password ({AES}fk9EK...): ")

# Delete unnecessary escape characters
preppwd = pwd.replace("\\", "")

# Display password
print "Decrypted string is: " + clearOrEncryptService.decrypt(preppwd)
2. Set domain environment variables
source $DOMAIN_HOME/bin/setDomainEnv.sh
3. Get encrypted password, in this example from boot.properties file of AdminServer
#Username:
grep username $DOMAIN_HOME/servers/AdminServer/security/boot.properties | sed -e "s/^username=\(.*\)/\1/"

#Password:
grep password $DOMAIN_HOME/servers/AdminServer/security/boot.properties | sed -e "s/^password=\(.*\)/\1/"
Or for SOA schema, we can get the encrypted password from $DOMAIN_HOME/config/jdbc/SOADataSource-jdbc.xml
4. Navigate to $DOMAIN_HOME/security directory and run the following command to start decryption:
cd $DOMAIN_HOME/security

java weblogic.WLST decrypt_password.py


Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Please enter encrypted password (Eg. {AES}fk9EK...): {AES}jkIkkdh693dsyLt+DrKUfNcXryuHKLJD76*SXnPqnl5oo\=
Decrypted string is: welcome01
Decrypted value will be displayed on the screen.
 
 Source: http://tinyurl.com/km92oto


Otherwise try oracle suggested steps, but this only works if you are logged on to the same server:
Document 2852454.1 (oracle.com)

2. Run WLST:

cd /u01/app/oracle/middleware/oracle_common/common/bin
./wlst.sh

3. Set the domain and decrypt the password:

domain = "COMPLETE PATH TO DOMAIN HOME"
service = weblogic.security.internal.SerializedSystemIni.getEncryptionService(domain)
encryption = weblogic.security.internal.encryption.ClearOrEncryptedService(service)
print encryption.decrypt("PASSWORD FROM ABOVE datasource xml file")

Tuesday, March 7, 2017

create and post message to AQ with XMLTYPE as the payload type.

This post shows how to create an AQ with XMLTYPE as the payload type.
This is useful when the payload structure is not known or DB guys do not want to define objects and just go with XMLTYPE.
It can accept any xml request, which can then be consumed and transformed accordingly in SOA for further use.

I assume you already have privileges to create AQ. (If not then refer this post to grant privileges.)


--Queue Table
BEGIN
 DBMS_AQADM.CREATE_QUEUE_TABLE( Queue_table => 'QT_SampleQueue', Queue_payload_type => 'SYS.XMLTYPE', Sort_list => 'ENQ_TIME', COMMENT => 'A sample queue table');
END;

--Queue
BEGIN
DBMS_AQADM.CREATE_QUEUE (
queue_name =>'SampleQueue',
queue_table=>'QT_SampleQueue');
END;


SELECT queue_table,type,object_type,recipients FROM USER_QUEUE_TABLES;


exec DBMS_AQADM.START_QUEUE('SampleQueue');




--Post request
DECLARE
 
  queue_options DBMS_AQ.ENQUEUE_OPTIONS_T;
  message_properties DBMS_AQ.MESSAGE_PROPERTIES_T;
  message_id RAW(16);
  message SYS.XMLType;
 
BEGIN
 
  message := sys.XMLType.createXML('<catalog>
   <book id="bk101">
      <author>Gambardella, Matthew</author>
      <title>XML Developer's Guide</title>
      <genre>Computer</genre>
      <price>44.95</price>
      <publish_date>2000-10-01</publish_date>
      <description>An in-depth look at creating applications 
      with XML.</description> 
</book></catalog>');

  DBMS_AQ.ENQUEUE( queue_name => 'SampleQueue',
                   enqueue_options => queue_options,
                   message_properties => message_properties,
                   payload => message,
                   msgid => message_id);
  COMMIT;
END;

Generate a Unique ID to be used as Correlation for Asynchronous flows in SOA

In case of asynchronous flow, sometimes we need a unique ID to track the flow across different system or different services. we can use the XSLT function oraext:generate-guid() to generate the ID.

In below example I am defining a variable as assigning the unique ID to it, and later restructuring.
you can also directly use it in a XSLT transformation.


      <variables>
        <variable name="correlationID" type="xsd:string">
          <from>oraext:generate-guid()</from>
        </variable>
      </variables>  

        <assign name="Assign_ServiceRequestDetails">
          <copy>
            <from>concat(substring($correlationID,1,8),'-',substring($correlationID,9,4),'-',substring($correlationID,13,4),'-',substring($correlationID,17,4),'-',substring($correlationID,21))</from>
            <to>$serviceRequest/ns14:CorrelationID</to>
          </copy>
       </assign>



After restructuring in assign:

This id can be use in all the subsequent bpel processes to track the flow.


Tuesday, May 31, 2016

WLST script to get coherence server status


If coherence is installed on weblogic server, we can monitor the status of the coherence server using below WLST script. In this script I am passing connection details as a parameter, you can follow any other approach or simply provide details in "connect()" function.

save below script as getCoherenceHealth.py 

#redirect wlst's own output to null, print lines in the script itself
redirect('/dev/null', 'false')

wlsuser = sys.argv[1]
wlspassword = sys.argv[2]
wlsurl = sys.argv[3]
#targetServer = sys.argv[4]

connect(wlsuser,wlspassword,wlsurl)

servers = cmo.getCoherenceServers()
domainRuntime()
stoppedServers = []

for server in servers:
    try:
        cd('/CoherenceServerLifeCycleRuntimes/' + server.getName())
        currentState = cmo.getState()
        if currentState == 'RUNNING':
            print server.getName() + ': ' + 'RUNNING'
        else:
            print server.getName() + ': ' + 'DOWN (' + currentState + ')'

    except WLSTException, e:
        print server.getName() + ': ' + 'SHUTDOWN'
        stoppedServers.append(server.getName())

disconnect()
#rm ./wlst.log
exit()


you can call this script by passing required arguments:
java -cp $WL_HOME/server/lib/weblogic.jar weblogic.WLST getCoherenceHealth.py $WebUSER $WebPass $WL_URL

Sunday, December 20, 2015

Useful Excel functions for a SOA resource

VLOOKUP Function:

One simple requirement for VLOOKUP function is to compare two sheet and find out the matching rows.
For example here we have two tables of Order ID’s and we want to match them (get matching and not matching ID’s).
We can copy both the list in same or to be more clear in different sheets.

                                            


On an available cell, we need to write the VLOOKUP function as below, So this lookups for a value in
 an array range and if found returns a column of that matched row.
Range lookup = true – approx. match will be returned
Range lookup = false – exact match will be returned


range_lookup   (optional)
A logical value that specifies whether you want VLOOKUP to find an exact match or an approximate match:
·         TRUE assumes the first column in the table is sorted either numerically or alphabetically, and will then search for the closest value. This is the default method if you don't specify one.
·         FALSE searches for the exact value in the first column.
 
So below function fulfils our purpose.

 

Wednesday, October 14, 2015

BPEL correlation and Message Aggregation


How does BPEL identify which response is for which request?
We all know that there are two major type of processing synchronous and asynchronous and for synchronous processing it uses same TCP connection or in simpler terms single port. So there is no need of correlation for synchronous process.
For Asynchronous processing, BPEL process will usually correlate message using "WS-Addressing", it’s something like web session cookies, which happens internally and we do not need to worry about correlating response messages.


WS-Addressing
The basic question every beginner has is how an asynchronous response gets mapped to the correct instance out of many waiting instances. The answer is, whenever asynchronous service is invoked, Oracle BPM adds a message UID in WS-Addressing headers that flows with SOAP packets, which are used internally by BPEL server to correlate the request/response.

So when does we need manual Correlation?
Below are the scenarios when we will require correlation:
  • When external web service doesn’t support WS-Addressing
  • When the message travels through several services and the response is solicited by the initial service from the last service directly. For example, Request path is A > B > C and response comes to A directly from C, i.e. C > A
  • When receiving unsolicited messages from another system.
  • When communicating via files, i.e. When BPEL instance is expecting messages from a third party.

What is correlation?
It is a BPEL technique called correlation set to match or correlate the messages based on content of the message.
It is a collection of properties used by the BPEL process service engine to allow custom correlation.


Before starting with our example we need to understand in which activities do we need correlation. Well the answer is quite self-explanatory, we need correlation whenever data is going out or coming in to the BPEL process, i.e.
  • Receive activity
  • Reply activity
  • Invoke activity
  • onMessage branch
  • onEvent branch

I will first give the scenario of our example:

you can download the sample from here.
we will have two receive activities in our BPEL process,
One receive will take input as Country Name and Language
Other receive will take input as Country Name and Capital.
The response will have Country Name, Language and Capital.

Monday, October 12, 2015

SOA12C: Getting started – Hello World project OSB

One of the major change in 12C is the integration of OSB IDE within Jdeveloper and hence development and testing of SOA as well as OSB can now be done from within Jdeveloper without the need of installing Eclipse & OSB.
In our previous post we did a Hello World project in SOA, If you have not done that, first do SOA part as in this example we will be calling SOA service, now let’s get started with OSB.

In this sample we will call the Hello World project we created in SOA through business service.

you can download this sample from here.

Let’s first create a new application for service bus:


Name your project accordingly: