Monday, April 15, 2013

CSVDE install

Note to self: To get CSVDE you need to install 'Active Directory Lightweight Directory Services' ->


ORA-01882 timezone region not found - Can not connect to database in SQL Developer

Got this nice error when I upgrade my Oracle SQL Developer:

Basically you just need to add a time zone to the SQL Developer Config file (/opt/sqldeveloper/sqldeveloper/bin/sqldeveloper.conf) to resolve. I added the following line:

AddVMOption -Duser.timezone=SAST


Friday, April 12, 2013

How to rename file extentions in Linux

for x in *.csv; do mv "$x" "${x%.dot}.bak"; done

AD Change Password on next Logon

So there seem to be a number of posts on how to set this via Novell IDM. All you really need to do is the the pwdLastSet attribute on a user to 0. Then the next time they log in they will need to change their password. We had a challenge where for certain users on creation we did not what their password to be 'expired'. To acheive this you have to set pwdLastSet to -1. I could not find to many posts on this but this one helped ->

"If the previous value of pwdLastSet is 0, assigning the value -1 results in
Active Directory actually making the value equivalent to the current
date/time (as if the user just changed their password). If the previous
value of pwdLastSet is any other value (even if the password is expired),
assigning the value -1 results in no change. If you want the value of
pwdLastSet to be equivalent to the current time, first assign 0, then
assign -1."

JDBC Driver - Table/view 'TABLENAME' is undefined or unsyncable.

So I was pulling my hair out with this error on the Driver.
I started looking through the changes I'd made to the Driver and could not find anything that would cause this issue. I eventually deployed the backup of the Driver and found the issue still persisted.
At least then I realised the issue was not with the Driver. Someone had made a change to the database to allow for the deletion of records during a cleanup process. They forgot to put the foreign key constraint back for the table. We add the foreign key constraint back to the table, restarted the Driver and we where back in business. The JDBC Driver will not sync data to other tables if the foreign key constraint is not setup correctly.

Tuesday, March 19, 2013

WSDL Cheat Sheet



Service -> ‘Java Class’
Operation -> ‘Java Function’ The Operation defines the name of the Operation and ties the request response messages together.
Port -> A service is assessable on a Port.  A Port has a unique name space and binding attribute. The Port specifies the service address. Web service can be exposed as SOAP or HTTP. The same web service can also be exposed by multiple Ports.
SOAP example:
<port name='WeatherSoapPort' binding='wsdlns:WeatherSoapBinding' >
<soap:address   location='http://localhost/demos/wsdl/devxpert/weatherservice.asp' />
</port>

HTTP example:
<port name='WeatherSoapPort' binding='wsdlns:WeatherSoapBinding' >
<http:address location="http://localhost/demos/wsdl/devxpert/weatherGET.asp"/
</port>

Message -> Normally two messages required i.e. input message and output message. Messages contain zero or more <part> elements. Sample messages below
<message name='Weather.GetTemperature'>
    <part name='zipcode' type='xsd:string'/>
    <part name='celsius' type='xsd:boolean'/>
 </message>

 <message name='Weather.GetTemperatureResponse'>
    <part name='Result' type='xsd:float'/>
 </message>

Binding -> ‘Ties it all together’ - specifies binding(s) of each operation in the PortTypes section

Tuesday, October 16, 2012

Find Class in .jar files

So I had a load of .jar files and was looking for a specific class that should be contain in one of them. I found you can run the following command to search for a class file:

find -name "*.jar" -exec sh -c 'unzip -l "{}" | grep -q <class name>' \; -print

Just replace <class name> with the class name e.g. 

find -name "*.jar" -exec sh -c 'unzip -l "{}" | grep -q HttpServletRequest' \; -print

Ref: http://unix.stackexchange.com/questions/25503/looking-for-a-java-class-in-a-set-of-jars-with-find-unzip-grep

Thursday, October 11, 2012

Microsoft Security Essentials and VMware

Note to self. Make sure you add exclusions to Security Essentials not to scan the vmdk amd vmem files:

Wednesday, August 8, 2012

ECMAScript parseInt

So I seem to have a love hate relationship with ECMAScript. Today is very much not a loving day for ECMAScript.

I needed to convert text like '06' to an integar, so I just used the parseInt function.

What I did not reliase was that if you do not provide a value for the radix you get very strange results like so:

 js> print(parseInt('06'));   
 6  
 js> print(parseInt('08'));  
 NaN  
 js> print(parseInt('08',10));  
 8  

When you add the radix everthting works as expected as can be seen above.
Note to self: Don't assume functions work the same across all programming languages.

Really enjoyed this video: WAT -> https://www.destroyallsoftware.com/talks/wat

This was a nice 'bug' I found using ECMAScript

js> var a = '1';
js> var b = a + 1;
js> print(b);
11
WAT!

js> var a = 1;
js> var b = a + 1;
js> print(b);
2
 

Java Query Soap HTTP and HTTPS

One of the end points that we query was suddenly changed from HTTP and HTTPS using a self signed cert and invalid host name in the cert. Sadly you can't just change the URL in your config file and everything works. What I needed to do was to change my querySOAP function to work for both HTTP and HTTPS. Here's what I came up with.Oh and this function also supports HTTP authentication. Nice!

      public static String querySoap(String url, String soapAction, String msg, final String username, final String password) {  
           String ret = null;   
           try {  
                boolean HTTPS = false;  
                if( url.substring(0, 5).equalsIgnoreCase("https") ) HTTPS = true;  
                Config c = new Config();  
                Log.log(Level.INFO, "Url: " + url  
                     + "\r\nSoapAction: " + soapAction  
                     + "\r\nSoapMessage: " + msg);       
                URLConnection connection;  
                URL u = new URL(url);       
                if( HTTPS ) {  
                     Log.log(Level.INFO, "We use SSL to connect to : " + url);  
                     // Create a trust manager that does not validate certificate chains  
                     TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {  
                               public java.security.cert.X509Certificate[] getAcceptedIssuers() {  
                                    return null;  
                               }  
                               public void checkClientTrusted(X509Certificate[] certs, String authType) {  
                               }  
                               public void checkServerTrusted(X509Certificate[] certs, String authType) {  
                               }  
                          }  
                     };  
                     // Install the all-trusting trust manager  
                     try {  
                       SSLContext sc = SSLContext.getInstance("SSL");  
                       sc.init(null, trustAllCerts, new java.security.SecureRandom());  
                       HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());  
                     } catch (Exception e) {  
                     }                 
                     // Create all-trusting host name verifier  
                     HostnameVerifier allHostsValid = new HostnameVerifier() {  
                          public boolean verify(String hostname, SSLSession session) {  
                               return true;  
                          }  
                     };  
                     // Install the all-trusting host verifier  
                     HttpsURLConnection.setDefaultHostnameVerifier(allHostsValid);  
                } else {  
                     Log.log(Level.INFO, "We do not use SSL to connect to : " + url);  
                }  
                connection = u.openConnection();  
                connection.setConnectTimeout(c.httpConTimeout);  
                connection.setReadTimeout(c.httpConReadTimeout);  
                connection.setDoOutput(true);  
                connection.setDoInput(true);  
                connection.setUseCaches(false);  
                connection.setRequestProperty("Content-Type","text/xml;charset=UTF-8");  
                connection.setRequestProperty("SOAPAction", soapAction);  
                connection.setRequestProperty("User-Agent","Jakarta Commons-HttpClient/3.1");                 
                connection.setRequestProperty("Content-Length","" + msg.length());  
                if( username != null && password != null) {  
                     String login = username + ":" + password;  
                     String encodedLogin = Base64.encodeBytes(login.getBytes());  
                     connection.setRequestProperty("Authorization", "Basic " + encodedLogin);  
                }  
                OutputStream out = connection.getOutputStream();       
                Writer wout = new OutputStreamWriter(out);  
                wout.write(msg);  
                wout.flush();  
                wout.close();  
                StringBuffer strBuf = new StringBuffer();  
                String inputLine;                 
                BufferedReader bufRead = new BufferedReader(new InputStreamReader(connection.getInputStream(),"UTF-8"));                 
                while ((inputLine = bufRead.readLine()) != null) {  
                     strBuf.append(inputLine);  
                }  
                bufRead.close();  
                ret = strBuf.toString();  
                Log.log(Level.INFO, "SoapResponse: " + ret);  
           } catch (Exception e) {  
                e.printStackTrace();            
           }            
           return ret;  
      }  

Reference: http://www.nakov.com/blog/2009/07/16/disable-certificate-validation-in-java-ssl-connections/

Monday, August 6, 2012

Sunrise

The traffic ain't so bad when you can watch the Sunrise like this:



Note to self: Look for the Good in the World.

Thought for the day: 'While chasing the moon some people miss the flowers blossoming at their feet.'


Tuesday, July 24, 2012

How to invoke a Web service using curl

To invoke a Web service using curl you basically just need to post the soap envelope and the required soap action. I needed to invoke a Web service from cron so I wrote this script to do it using this method:

#!/bin/bash
LOG_FILE="/var/log/armcron.log"
echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:arm=\"http://www.com.co.za/ARM/\">
   <soapenv:Header/>
   <soapenv:Body>
      <arm:warnForEndDate/>
   </soapenv:Body>
</soapenv:Envelope>" > /tmp/warnForEndDate
echo "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:arm=\"http://www.com.co.za/ARM/\">
   <soapenv:Header/>
   <soapenv:Body>
      <arm:revokeForEndDate/>
   </soapenv:Body>
</soapenv:Envelope>" > /tmp/revokeForEndDate

curl -H 'SOAPAction: "http://www.com.co.za/ARM/warnForEndDate"' -X POST -H 'Content-Type: text/xml;charset=UTF-8' -d @/tmp/
revokeForEndDate http://localhost:8080/armws/services/ARM/ >> $LOG_FILE 2>&1

Friday, July 13, 2012

Novell RBPM Logging Configuration to Debug Workflow

Set the following log levels to trace to debug the workflow:

- com.novell.soa.af.impl
- com.novell.soa.script

Thursday, July 12, 2012

How not to do XML

This is some sample XML I get from a customers Web service. In my opinion this is a prime example on how not to represent data using XML.

  <ImplementorList>
               <Implementor xsi:nil="true">
                  <ArrayOfImplementorItem>
                     <OID xsi:nil="true"/>
                     <Name xsi:nil="true"/>
                     <Email xsi:nil="true"/>
                  </ArrayOfImplementorItem>
               </Implementor>
               <OID>
                  281527649831711
                  <Implementor>
                     <ArrayOfImplementorItem>
                        <OID xsi:nil="true"/>
                        <Name xsi:nil="true"/>
                        <Email xsi:nil="true"/>
                     </ArrayOfImplementorItem>
                  </Implementor>
               </OID>

Followers