Site Navigation

Favorite Links Feed

Mar 25, 2015

Simple Command Line File Encryption with 7zip

This is a brief write up on how perform simple file encryption of a directory using the 7zip program. After TrueCrypt was abandoned by its developers, I have looked around a bit for a really simple, easy to use tool for lightweight ecryption. Simple and easy are my goals, not the most secure. You can use something like Gnu Privacy Guard if you want a really full featured suite of security tools.

7zip is a free, open source file compression tool for Windows, OS X, and Linux. Most folks use 7zip to zip and unzip .zip files. But 7zip has its own 7z file format which provides better compression and better encryption than standard .zip files. The 7zip program uses strong AES-256 encryption based on a password you provide when you compress files. Thusly, the goal of quick and easy is met. The password will keep nosy relatives out the file, but I am sure, given enough time, the NSA could get in if they really wanted to. :)

7zip Installation

You can get 7zip from the 7zip web site. That works best for Windows, but for other operating systems you can use a package manager.

Windows

For windows, just go to the main site to download and install the software. The files are:

  • 7zip.exe (Windows 32-bit)
  • 7zip.msi (Windows 64-bit)

OS X

For OS X, the easiest way to install is to use HomeBrew. If you do not have HomeBrew, get it. You can thank me later. It is a fantastic tool for OS X. To install, just use the following from a terminal:

  • brew install p7zip

Ubuntu Linux

For Debian Linux, just use apt. For example:

  • apt-get install p7zip-full

Encrypting your Stuff

The following steps outline how to encrypt your stuff from the command line. The command line options should be the same on any platform, but there could be minor differences. The note was written using OS X.

Compress a Directory

To compress a directory named temp, use the following command:

7z a temp.7z temp/ -pSECRET -mhe

or alternatively

7z a temp.7z temp/ -p -mhe

The second option prompts you for the password to type in. The longer the password, the harder it would be for someone to decrypt the file. But of course, that will also make it hard to remember.

Here is a quick breakdown of the command line options:

  • a – Append files to the archive. Will just update the archive if it exists, so best to make sure the file does not exist.
  • temp.7z – The name of the archive file.
  • temp/ – The directory to be zipped.
  • -p – Prompt for the password.
  • -mhe – Encrypt the archive headers.

On OS X or Linux, the password is case sensitive by default. On Windows, the password is case insensitive by default.

Decompress the Archive

To decompress the archive just use:

7z x temp.7z

You will be prompted to enter your password and the file is uncomressed. For more information on 7zip see this 7zip tutorial which was a big help in writing this post.

That is it. An easy way to encrypt a directory.

Mar 11, 2015

Glassfish 4 Admin Passwords with NetBeans

Question: Where can I find the Admin Password for GlassFish 4?

Most of the time when working with NetBeans and Glassfish for development, you don’t need to know what the password is for the GlassFish server. Starting and stopping the server as well as open in the admin console is automatic. However, if like me, sometimes you work with multiple versions of NetBeans and you may be prompted for a password in the GlassFish admin console. So the username is "admin", but where is the darn password stored?

Usually in one of two the places.

Location 1

The first place to look is in the GlassFish configuration directory.

glassfish-4.0/glassfish/domains/domain1/config/local-password

Location 2

The second place to look is in NetBeans

  1. Click on the Services Tab
  2. Right click on the GlassFish Server
  3. Select Properties
  4. Too see the password, check the Show Password in this Form option

Caveats

Do not change these passwords! GlassFish has to be running to change admin passwords. If you “lose” the passwords for some reason, you will need to re-install.

If you want to change the password, look up the asadmin documentation for more details.

GlassFish 4 Reports a JNDI Lookup Exception for a NetBeans Project

Duke Waving

Here is a quick word around to a problem I ran into at work.

Problem: Calling a Java Servlet with JNDI code results in this error

Other Exception: Lookup failed for 'jdbc/yournamehere' in SerialContext[myEnv={java.naming.factory.initial=com.sun.enterprise.naming.impl.SerialInitContextFactory, java.naming.factory.state=com.sun.corba.ee.impl.presentation.rmi.JNDIStateFactoryImpl, java.naming.factory.url.pkgs=com.sun.enterprise.naming}

The initialization code is similar to the following:

    try {
        Context ctx = new InitialContext();
        DataSource ds = (DataSource) ctx.lookup("jdbc/yournamehere");
        Connection con = ds.getConnection();

You have setup a connection pool and JDBC resource for your NetBeans project. All the configuration data appears to be correct.

Solution

The problem occurs when GlassFish fails to create a JDBC Connection Pool and JDBC Resource on the server when your application deploys. To wordaround the problem, manually create the pool and resource on the Glassfish server using the admin console.

Creating the JDBC Resource is pretty easy, so no additional comments on that.

When you create the JDBC Connection Pool, only include the required properties for your database in the Additional Properties tab. In this case, JavaDB (Derby) was used so the only required properties are:

  • User: YourUsername
  • Password: YourPassword
  • DatabaseName: YourDBName
  • ServerName: localhost
  • PortNumber: 1527

Some of the automatically added properties may cause your connection pool to fail to connect. Use the Ping feature of GlassFish to ensure the server is connecting to the database.

Feb 16, 2015

Website/Blog Update in the Works

Just a quick heads up. Google has mandated that all web sites must use SSL (HTTPS) or risk being down ranked sometime in the near future. I can find no evidence that Google has any interest in updating blogger.com to support their own mandate. So I am in the process of migrating this blog to my blueskyworkshop.com site. For me, this involves creating some very simple blogging software to run both my blog and my site. Consequently, I have not been posting as often as I would like.

I have looked at a number of static site blogging engines like Jekyll, but they all seem to be a bit complicated. So my goal is to create something really simple that supports Markdown with YAML front matter. My hope is to create Ruby and Java versions. So watch this space for updates.

In the meantime, I haved added a section for my favorite links a below the main posts. This is a feed of bookmarks of interest I am posting on https://pinboard.in. So the posts are sorta like a twitter feed except they are organized and indexed in a useful way by Pinboard.

Feb 10, 2015

Jupiter Ascending Quick Review (4/5)

Jupiter Ascending is the story of Jupiter Jones (Mila Kunis), a Russian immigrant who works for her mother in a family housekeeping business. Jupiter’s life seems pretty humdrum until one day some aliens show up and things start to get weird. The bulk of the movie proceeds from here and if you have seen any of the previews, you get the gist.

This is your classic SciFi/Action film with good guys, bad guys, explosions, and a bunch of cool toys. I actually liked the premise and thought the universe created was interesting. Most negative reviews seem to complain that since the film does not rise to the level of Hamlet, it sucks. Haters are gonna hate. Well people, if you like movies like Die Hard, you will probably like this movie.

The visuals in the movie are stunning and well worth a trip to the theater to see on the big screen. The plot moves quickly as Jupiter has to adapt to a new reality. The tech is interesting without being over explained.

My main criticisms would be that some of the action sequences go on too long. Also, one would think that the Jupiter character would be a bit more street smart. But both are minor complaints.

Overall, I liked the film quite a bit.

Jan 20, 2015

Good Git Resources

I have finally started to use git for all my development. Hopefully, I will create a nice cheat sheet when I am done. But for now, here are some good resources.

The documentation is pretty good, but tends to include too much information at times.