Friday, March 28, 2014

How to set up a test cas server on windows

Set up tomcat 

1)  install tomcat

2) download cas from

3) Extract the download and copy the war file from the modules folder to webapps folder in your tomcat root

4) Create a self-signed certificate with keytool (or get a certificate)

keytool -genkey -keyalg RSA -keysize 2048 -keystore c:\path\to\keystore.jks -alias mykey -validity <days>

Replace <days> with number days the certificate will be valid for.

Answer all the questions and put in a keystore password. This will be used in the tomcat configuration later.
Certain password characters like ampersands may need to be escaped in the tomcat config

4) Edit your server.xml

Add the following line under the <server ..> tag

    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
                   maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS"  keystorePass='<password here>' keystoreFile="C:/path/to/keystore.jks"/>

5) restart Tomcat and the war should installed

Config CAS

6)  Open the webapps/cas-server-webapp-version/web-inf/deployerConfigContext.xml file

Comment out the bean


like this

class="" />-->


Add the generic authentication method:

<bean class="org.jasig.cas.adaptors.generic.AcceptUsersAuthenticationHandler">
   <property name="users">
            <entry key="testuser" value="test" />

Under the authenticationHandlers tag.

8) Copy the cas-server-support-version.jar to webapps/cas-server-webapp-version/web-inf/lib folder

9) Restart tomcat

10) you should be able to login by going to the following url:


Tips for the CAS clients to avoid redirect loops

CAS clients are pretty particular about the ssl certificates. If the certificate is not trusted by the web application using your CAS server you may get redirect loops.

To avoid this buy a certificate or put your self-signed certificate in the trusted store on the computer where the web server is.

Helpful links

To set up CAS you have a good knowledge of SSL, tomcat and java keystores, especially if you want to do proxy authentication. There are many links below that can shed some light on these concepts and related issues.

Saturday, March 1, 2014

GIT 101

I apologize in advance. I'm a lot more familiar with svn.

In the process of playing with git, I put together some steps on how to accomplish some basic git tasks. The main goal is to set up a repository on a server and get your developer stations synching with it.

Git is a little bit of a change from svn and make take a little getting used to.

How to set up a git repository and configure for ssh on LInux.

From the command line: (you can check by typing whereis git )
If you don't already have git installed

1) Download git

 wget --no-check-certificate

2) unzip git-master
3) cd git-master
4) make
5) make install
6) make sure git is in your path
May want to edit your ~/.bashrc or whatever loginscript you have to edit your path.
Or you can just create a link to it in one of your bin folders : /bin, /usr/local/bin, etc.

To create a repository on the server

1) Make sure git is in your path
Create a new git folder for your projects.
mkdir git
2) cd git
3) create a new project directory
mkdir project1.git
4) cd project1.git
5) git init --bare

To push your code onto the remote repository
1) git remote add origin ssh://username@server_ip/home/pathto/git/project1.git
2) git push

To get the project onto another machine and commit changes
1) git clone ssh://username@server_ip/home/pathto/git/project1.git
2) git remote add origin ssh://username@server_ip/home/pathto/git/project1.git
3) git add whatever_file_you_changed_or_added
4) git commit -m "message here"
5) git push

To update your local copy 
1) git pull origin master
This calls git fetch and merge to get the  latest changes.

For windows you may want to install the google code project msysgit

Reference links


Wednesday, May 29, 2013

How to manually add entity to edmx

Recently had to add entities manually to edmx file since using the "update model from database" feature kept erasing mappings.

The edmx was originally generated using Huagati edmx tool : which I didn't have.

Steps to manually table to edmx:

Note: you should have some entities in your edmx file already so you can follow their naming conventions and patterns.

1) Open the edmx file with a xml editor
2) navigate to the SSDL section and add a new EntitySet tag under EntityContainer
3) also in SSDL within EntityContainer, create a new EntityType tag
the property tags will match the column names for the database table

4) In CSDL, under EntityContainer, create an EntitySet tag
5) Now add the EntityType also under EntityContainer
6) Save and open in the designer so you can add the mappings in (map model to database fields).

Environment I used:

Visual Studio 2012
Entity Framework 5

Good references: 

Sunday, April 28, 2013

Convert xml formatting using python

Need a script to convert from one xml formatting to another.

For instance,

Change this:

<subSection name="tag1" title="tag 1 title" >


<subForm name="tag1form" title="tag 1 title" >
<section name="tag1" >


I tried doing this with bash but it didn't seem feasible since I wanted to change the name of xml attribute values. sed at first was the obvious choice.

Here was my attempt with sed but it's not done:

#$1 input file

while read line
echo $line | sed -e 's/subSection/<subForm/g'  -e 's/<\/subSection/<\/subForm/g'
done < $1

A quick and dirty solution seemed more likely in python:

#usage python source_file.xml > converted_file.xml

import sys
import re

formNameMatch = re.compile('[nN]ame= *["\'][a-zA-Z0-9_\-]+["\']')

def ProcessXML(file):
f = open(file,'r')
for line in f.readlines():

def ProcessLine(line):

line = re.sub(r'subSections','subForms',line)
print line

line = re.sub(r'subSection','subForm',line)

nameMatch =
if nameMatch != None:
name =
nameForm = re.sub(r'"$','Form"',name)
nameForm = re.sub(r'\'$','Form\'',nameForm)
line2 = formNameMatch.sub(nameForm,line)
print line2
print " <sections>"
print " <section ",name," >"

print "ERROR!!!"
elif'<\/subSection *>',line):
print " </section>"
print " </sections>"
line = re.sub(r'subSection','subForm',line)
print line
print re.sub(r'subSections','subForms',line)
line = re.sub(r'subSection','subForm',line)
line = re.sub(r'SubSection','SubForm',line)
nameMatch =
if nameMatch != None:
name =
nameForm = re.sub(r'"$','Form"',name)
nameForm = re.sub(r'\'$','Form\'',nameForm)
line2 = formNameMatch.sub(nameForm,line)
print line2
print line

def main(*args):
if len(args) != 2:
print "must supply file to process"

if __name__ == "__main__":

Wednesday, March 20, 2013

New update to Common Sense Tips App - view categories

Have you lost touch with reality and need a boost in common sense? This app may be for you. It downloads common knowledge regarding different subjects which you go page through. You can even add your own! Also, you can look up more info on the tip if you are curious. Use this tool as a daily source of common source. New!!! Now you can view tips by category!

See common sense tips app here on the market !

Select the category you want to view tips for

Friday, March 15, 2013

How to read the AndroidManifest.xml file for an apk file

Recently I wanted to check the permissions that were being set for my application. I found that they are set in AndroidManifest.xml.

1) May need to install android sdk  (not sure if you need this)
2) Download the apk-tool like in these directions:

I just copied the jar file into the same folder as the batch file and aapt.exe.

So you have:
- aapt.exe
- apktool.jar

3) Copy your apk to the same folder
4) run 
apktool d yourapp.apk

Now you can read the AndroidManifest.xml file in decrypted form

Friday, January 25, 2013

Scripting exercises

Say you have a log with a particular IP you want to remove. Can you write a script to save the log with out this IP?

The shorter the number of commands of commands the better.