Safenet Code Sample

The following code stub can be used to encrypt/decrypt with the Safenet appliance.  Refer: CryptoTool.java

private static String doEncrypt( final String plainText ) throws Exception
{
NAESession naesession = NAESession.getSession( "mlrtest", "asdf1234" );
SecretKey secretkey = NAEKey.getSecretKey( "test128", naesession );

Cipher cipher =
Cipher.getInstance( "AES/CBC/PKCS5Padding", "IngrianProvider" );
byte [] iv = new byte [16];
String ivString = "1234567890123456";
iv = ivString.getBytes();
cipher.init( Cipher.ENCRYPT_MODE, secretkey, new IvParameterSpec( iv ) );

byte [] outputByteArray = cipher.doFinal( plainText.getBytes() );

return IngrianProvider.byteArray2Hex( outputByteArray );
}

private static String doDecrypt( final String encryptedText )
throws Exception
{
NAESession naesession = NAESession.getSession( "mlrtest", "asdf1234" );
SecretKey secretkey = NAEKey.getSecretKey( "test128", naesession );

Cipher cipher =
Cipher.getInstance( "AES/CBC/PKCS5Padding", "IngrianProvider" );
byte [] iv = new byte [16];
String ivString = "1234567890123456";
iv = ivString.getBytes();
cipher.init( Cipher.DECRYPT_MODE, secretkey, new IvParameterSpec( iv ) );

byte [] decryptedByte =
cipher.doFinal( IngrianProvider.hex2ByteArray( encryptedText ) );
String decrypted = new String( decryptedByte );

return decrypted;
}

Using Third-party jars with Maven

Refer: 20120512 Using Third-party jars with Maven

To use third party jars in a maven project, the steps are as follows:

1) Upload the jar into a repository (either your local repository if it's just for you, or into the shared Nexus repository if you want other people to access the jar as well)
2) Add a section in your pom.xml to tell maven that your application depends on this jar.

Here are the commands to implement those steps:

To upload a jar in your local repository (your local repository is on your vm in ~/.m2/repository):

mvn install:install-file
-Dfile= -DgroupId=com.hal.thirdparty
-DartifactId=
-Dversion=
-Dpackaging= -DgeneratePom=true

Where: the path to the file to load
the group that the file should be registered under
the artifact name for the file
the version of the file
the packaging of the file e.g. jar

To upload a jar into the shared Nexus Repository:

Option A: Command line

mvn deploy:deploy-file -Durl=file://C:m2-repo
-DrepositoryId=some.id
-Dfile=your-artifact-1.0.jar
[-DpomFile=your-pom.xml]
[-DgroupId=org.some.group]
[-DartifactId=your-artifact]
[-Dversion=1.0]
[-Dpackaging=jar]
[-Dclassifier=test]
[-DgeneratePom=true]
[-DgeneratePom.description="My Project Description"]
[-DrepositoryLayout=legacy]
[-DuniqueVersion=false]

See here for the detail of the options: http://maven.apache.org/plugins/maven-deploy-plugin/usage.html

Option B: Using the web interface from Nexus at http://halsvn01:8081/nexus/index.html#view-repositories;thirdparty~uploadPanel

See the attached screenshot.

In both options, you will need Nexus admin credentials to upload artifacts (jars in maven terms) into the shared repository.

2) In your pom.xml, inside the section, add:
com.hal.thirdparty
your-artifact
your-artifact-version

-------------------------------------
Guillaume Radde
Senior Consultant, Red Hat Consulting
guillaume.radde@redhat.com
http://www.redhat.com
-------------------------------------

Remove a workspace in Eclipse

The following will remove it from the dropdown list when your startup Eclipse. Eclipse is not very happy if it thinks there's supposed to be a workspace but it's not there.

Window,Preferences,General,"Startup and Shutdown",Workspaces

From there you can delete a workspace you are no longer using, and then delete if from your drive

How to extract private key RSA code

/hal-parent/hal-ejb/src/main/java/com/hollandamerica/common/encryption/WebKeyFactory.java

Refer: http://stackoverflow.com/questions/150167/how-do-i-list-export-private-keys-from-a-keystore

import org.apache.axis.encoding.Base64;

//NOTE: DO NOT MIGRATE THIS CODE!!!
System.out.println("ifw.getPassword()"+ifw.getPassword().toString());

decryptionKey = (RSAPrivateKey)newKeyStore.getKey(
Keystore.END_ENTITY_ALIAS,ifw.getPassword());
System.out.println("maurice:decryptionKey"+decryptionKey.toString());
//String b64 = new BASE64Encoder().encode(key.getEncoded());
String b64 = new String(Base64.encode(decryptionKey.getEncoded()));
System.out.println("-----BEGIN PRIVATE KEY-----");
System.out.println(b64);
System.out.println("-----END PRIVATE KEY-----");

Example to turn off features

From: Thompson, Sonya (HAL)
Sent: Thursday, May 03, 2012 2:37 PM
To: Fillman, Eric (HAL); Bojja, Sridhar (HAL Contractor); Phatak, Sheetal (HAL); Ruckman, Maurice (HAL); Klein, Brian (HAL); Hartman, Mario (HAL Contractor); Florencia Castro (fcastro@hexacta.com); Daniela Greca (dgreca@hexacta.com)
Cc: Augustine, Anila (HAL)
Subject: Created a new teamsite file in support of continuous integration

Dev team,

In support of continuous integration, here's a way to "turn a feature off" or "hide a feature from end users".

Add an element to this new teamsite file: //prdcms01/default/main/hollandamerica/WORKAREA/baseline/cms/web/copy/features/featureToggles.xml

<?xml version="1.0" encoding="utf-8"?>
<toggles>
<cancelFeeDetailsDE><![CDATA[false]]></cancelFeeDetailsDE>
<upsellCategories_hal><![CDATA[true]]></upsellCategories_hal>
<upsellCategories_sbn><![CDATA[true]]></upsellCategories_sbn>
</toggles>

In your JSP, import the teamsite file:
<s:set var="featureMap" value="#application.staticXmlDataList.staticXmlFileMap['web.copy.features.featureToggles.xml']"/>

Add an if statement around the new feature in your JSP:
<s:if test="#featureMap['toggles.upsellCategories_hal'] == 'true'">
<%--put your feature code here-->
</s:if>

How Debug JBoss 100% CPU Usage

Refer: 20120503 Debugging JBoss 100 Percent CPU Usage.pdf

There's a quick and dirty way of identifying which threads are using up the CPU time on JBoss. Go the the JMX Console with a browser (usually on http://localhost:8080/jmx-console, but may be different for you), look for a bean called ServerInfo, it has an operation called listThreadCpuUtilization which dumps the actual CPU time used by each active thread, in a nice tabular format. If there's one misbehaving, it usually stands out like a sore thumb.

There's also the listThreadDump operation which dumps the stack for every thread to the browser.

Not as good as a profiler, but a much easier way to get the basic information. For production servers, where it's often bad news to connect a profiler, it's very handy.

Integrate Merge / Commits with Jira

-----Original Message-----
From: Guillaume Radde [mailto:guillaume.radde@redhat.com]
Sent: Thursday, April 12, 2012 12:24 PM
To: Mirza, Masood (HAL Contractor); Thompson, Sonya (HAL); Doan, Thomas (HAL Contractor); zzSmith, Robert (HAL Contractor); Ruckman, Maurice (HAL); Phatak, Sheetal (HAL); Bojja, Sridhar (HAL Contractor); Fillman, Eric (HAL); Augustine, Anila (HAL)
Subject: Jira-Subversion integration

You may have noticed that in Jira tickets, there is a tab at the bottom of the page that says "Subversion Commits". You can attach a commit to a Jira ticket by putting the Jira ticket number in the commit message.

Example:

$ svn commit -m "Remove duplicated method declaration. Fix JBM-319"

And the created commit will be added to the Jira ticket JBM-319.

Jira parses subversion commit logs every hours looking for Issue numbers so it's normal if you don't see your commit right away.

-------------------------------------
Guillaume Radde
Senior Consultant, Red Hat Consulting
guillaume.radde@redhat.com
http://www.redhat.com_o<
-------------------------------------

-----Original Message-----
From: Guillaume Radde [mailto:guillaume.radde@redhat.com]
Sent: Thursday, April 12, 2012 12:24 PM
To: Mirza, Masood (HAL Contractor); Thompson, Sonya (HAL); Doan, Thomas (HAL Contractor); zzSmith, Robert (HAL Contractor); Ruckman, Maurice (HAL); Phatak, Sheetal (HAL); Bojja, Sridhar (HAL Contractor); Fillman, Eric (HAL); Augustine, Anila (HAL)
Subject: Jira-Subversion integration

You may have noticed that in Jira tickets, there is a tab at the bottom of the page that says "Subversion Commits". You can attach a commit to a Jira ticket by putting the Jira ticket number in the commit message.

Example:

$ svn commit -m "Remove duplicated method declaration. Fix JBM-319"

And the created commit will be added to the Jira ticket JBM-319.

Jira parses subversion commit logs every hours looking for Issue numbers so it's normal if you don't see your commit right away.

-------------------------------------
Guillaume Radde
Senior Consultant, Red Hat Consulting
guillaume.radde@redhat.com
http://www.redhat.com_o<
-------------------------------------
-----Original Message-----
From: Guillaume Radde [mailto:guillaume.radde@redhat.com]
Sent: Thursday, April 12, 2012 12:24 PM
To: Mirza, Masood (HAL Contractor); Thompson, Sonya (HAL); Doan, Thomas (HAL Contractor); zzSmith, Robert (HAL Contractor); Ruckman, Maurice (HAL); Phatak, Sheetal (HAL); Bojja, Sridhar (HAL Contractor); Fillman, Eric (HAL); Augustine, Anila (HAL)
Subject: Jira-Subversion integration

You may have noticed that in Jira tickets, there is a tab at the bottom of the page that says "Subversion Commits". You can attach a commit to a Jira ticket by putting the Jira ticket number in the commit message.

Example:

$ svn commit -m "Remove duplicated method declaration. Fix JBM-319"

And the created commit will be added to the Jira ticket JBM-319.

Jira parses subversion commit logs every hours looking for Issue numbers so it's normal if you don't see your commit right away.

-------------------------------------
Guillaume Radde
Senior Consultant, Red Hat Consulting
guillaume.radde@redhat.com
http://www.redhat.com_o<
-------------------------------------

Enable / Disable Session Replication

-----Original Message-----
From: Guillaume Radde [mailto:guillaume.radde@redhat.com]
Sent: Tuesday, May 01, 2012 2:48 PM
To: Ruckman, Maurice (HAL)
Cc: Augustine, Anila (HAL); Thompson, Sonya (HAL); Fillman, Eric (HAL); Phatak, Sheetal (HAL); Bojja, Sridhar (HAL Contractor); Klein, Brian (HAL); Schumacher, Mike (HAL)
Subject: Re: prioritized/categorized list

I believe the only thing to do to re-enable session replication is to uncomment the <distributable> tag in hal-web/src/main/webapp/WEB-INF/web.xml.

Guillaume

HAL’s JBoss Configuration

Turnover documentation for HAL's JBoss Configuration.
Compete Red Hat Documentation concerning JBoss.

-----Original Message-----
From: Jeff Lindesmith [mailto:jlindesm@redhat.com]
Sent: Friday, April 13, 2012 12:00 PM
To: Ruckman, Maurice (HAL); Thompson, Sonya (HAL); Fillman, Eric (HAL); Phatak, Sheetal (HAL); Bojja, Sridhar (HAL Contractor)
Cc: Hofsetz, Therron (HAL); Augustine, Anila (HAL); guillaume radde; Randy Gullett
Subject: JBoss configuration documentation

Hi All,

Attached is a document that contains some documentation on JBoss configuration.

Good luck with everything.

Thanks,

Jeff Lindesmith
Senior Consultant - Red Hat Consulting
Red Hat , Inc.
405-659-3895
jlindesm@redhat.com
www.redhat.com