Friday, June 20, 2014

Install Mono 3.4.0 in Ubuntu 14.04 LTS from a repo

Friday, June 20, 2014 Posted by Andre Broers , , No comments
This is what I did to install Mono 3.4.0 in Ubuntu 14.04 LTS

sudo apt-get install software-properties-common
sudo add-apt-repository ppa:inizan-yannick/mono
sudo apt-get update
sudo apt-get install mono-devel
or
sudo apt-get install mono-runtime

mono --version
Mono JIT compiler version 3.6.1 (tarball Sat May 31 16:07:15 UTC 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS:           __thread
SIGSEGV:       altstack
Notifications: epoll
Architecture:  amd64
Disabled:      none
Misc:          softdebug 
LLVM:          supported, not enabled.

GC:            sgen

Install ElasticSearch in Ubuntu 14.04 server

Friday, June 20, 2014 Posted by Andre Broers , , No comments

This is how I installed ElasticSearch on my Ubuntu box

sudo apt-get install openjdk-7-jre-headless -y
sudo wget -O - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | apt-key add -

Add the following line to /etc/apt/sources.list

deb http://packages.elasticsearch.org/elasticsearch/1.2/debian stable main

sudo apt-get update
sudo apt-get install elasticsearch
sudo update-rc.d elasticsearch defaults 95 10
sudo /etc/init.d/elasticsearch start

curl http://127.0.0.1:9200
{
  "status" : 200,
  "name" : "Andromeda",
  "version" : {
    "number" : "1.2.1",
    "build_hash" : "6c95b759f9e7ef0f8e17f77d850da43ce8a4b364",
    "build_timestamp" : "2014-06-03T15:02:52Z",
    "build_snapshot" : false,
    "lucene_version" : "4.8"
  },
  "tagline" : "You Know, for Search"

}

Friday, May 9, 2014

How to Authenticate MVC5 Web Users with Azure Active Directory Access Control ACS

Friday, May 09, 2014 Posted by Andre Broers , , , , No comments
In this example I will show how to do authentication with Azure ACS from an MVC 5 web application. For this example I will use Visual Studio 2013. But we will start with some work in the Azure Management Portal.
The first thing we do is create a new Access Control Namespace. Click new in the bottom of the portal and select Access Control - Quick Create and type a unique namespace name (in my case my1stacs) and select your region.



Click create to create the new ACS namespace. Now select the tab ACCESS CONTROL NAMESPACES to find your new namespace. Select it and click on MANAGE in the bottom.



Now it is time to fire up Visual Studio and create our MVC 5 Website.
Open Visual Studio 2013 and click New Project. Select an ASP.NET Web Application, give it a location and a name and click OK.



Select MVC as the template and click on Change Authentication. Choose Organizational Accounts and select On-Premises as option. (On-Premises? Yes :-) )


Now go back to our ACS management portal and click on Development Application integration on the left and select the WS-Federation Metadata url.


Copy this url and paste it in the On-Premises Authority field in Visual Studio.


You can leave the App ID URI empty. You can change this value later when you deploy to another location in the web.config.
Click OK. And again on OK. Our web application is being generated.

Check the web.config for our Realm.

Now go back to our ACS management portal and create a new Relying Partner (our web application).
Click Trust relationships - Relying party application and click Add.


Type the Name and the Realm and the Return URL. The Realm and the Return URL are the same and are as seen in the web.config.


Leave the rest default and press Save on the bottom of the form.

We have now created a Relying party for the default Windows Live provider.


And it has created a default rule group.

Open this Rule Group and click on the Default rule group:



Now click on generate to add the default rule where it copies a claim from the Windows Live Provider to our ACS Relying Party.


Click on generate and Save.

How to implement ACS Single Sign-off functionality


Now go back to Visual Studio. The first thing we want to create is a logoff button so we can logoff and retry our demo without removing cookies etc.etc.

Edit the file _LoginPartial.cshtml


So that it looks like this:



In this you have to change the hostname to the one of your acs and the wtrealm to your realm and the last link is the one of the page to return to after the logoff. In our case the home page where you get redirected again to the Windows Live login page.

Try running the WebApplication. You immediately get redirected to the login page. When you login to the Identity Provider it wil redirect you to the home page of you application. Use the logoff link to disconnect again.

Only protect a certain area of the site

In the next example we only gonna protect the About page. So all pages of our Web Application are open but when you link to the About page you have to authorise. It's as simple as we always did with ASP.NET web applications by editing the web.config file:


Lets comment out both authorisation sections from the web.config so that we have no authentication on our web application anymore.
Next open up the HomeContoller.cs and add an Authorize attribute to our About method.


When we run our WebApplication1 we can browse our app freely as long as we stay away from the About page. (If you are still connected hit the logoff link to sign out and see that you can still access the web application). When you click the About page you will get redirected to Windows Live to logon and after this you will get redirected to the About page.

How to access the claims we got from ACS?

Use the following code to access the claims from the connected user:





Happy .netting

Sunday, May 4, 2014

Golang Trie implementation

Sunday, May 04, 2014 Posted by Andre Broers No comments
For a webcrawler I needed a low memory solution to keep track of the already crawled web urls. Because this list grows fast I choose a Trie (wiki) implementation. I just started playing with the Golang language so my implementation will be in this language.
The first thing I tried was an implementation based on maps. But it turned out the creation of maps is very memory intensive. My test of one million records failed on an out of memory error.
The code of my first attempt:

I implemented the functions again using a slice. Which turns out to be way faster and consuming less memory. It runs the tests in less than 3 seconds on a basic Microsoft Azure Ubuntu extra small instance.

I published this as a golang module to github at :
https://github.com/broersa/trie

Feel free to use it.

Sunday, April 27, 2014

Install Oracle JDK in Ubuntu

Sunday, April 27, 2014 Posted by Andre Broers , No comments
While installing OpenJDK in Ubuntu is simple, installing the Oracle variant is a little more complicated. Because some installations prefer the Oracle (Sun) version of the JDK I will explain the installation of the Oracle (Sun) version of the JDK.

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

After accepting the Oracle licenses the installation will start. When finished you will be able to use the java binaries:

azureuser@mygo01:~$ java -version
java version "1.7.0_55"
Java(TM) SE Runtime Environment (build 1.7.0_55-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.55-b03, mixed mode)
azureuser@mygo01:~$

Tuesday, March 25, 2014

Facebook Long Live Access Token Post from App to Page

Tuesday, March 25, 2014 Posted by Andre Broers , No comments
How to get a long live access token.

Goto the page graph explorer and generate a short live access token with extended permissions publish_stream and manage_pages rights

Give permission in the popup box

copy the app_id, app_secret and access_token in the following url:

https://graph.facebook.com/oauth/access_token?             
    client_id=APP_ID&
    client_secret=APP_SECRET&
    grant_type=fb_exchange_token&
    fb_exchange_token=EXISTING_ACCESS_TOKEN 
and get the long lived access token.

Now open https://graph.facebook.com/me/accounts?access_token=<long lived token>

now copy the access_token from the page you want.

Happy posting for about 60 days..

Wednesday, March 12, 2014

Microsoft RDP on Mac OSX and Ctrl-Alt-Del

Wednesday, March 12, 2014 Posted by Andre Broers No comments
Just wanted to change my password on a Azure Windows 2012 server from my Macbook Air using Microsoft Remote Desktop.

Well had to do some googling but this is a way to do it:

use Cmd-r to run a command.
type osk<enter>
   (to enable on screen keyboard)

now press Ctrl-Option and click on the Del on the OnScreenKeyboard.

There you are....