Skip to main content

Posts

Showing posts from October, 2016

SSH Key Login for Encrypted Home Directory

When the Linux home directory is encrypted, you will not be able to use ssh key login by simply copying ssh-copy-id mechanism. to overcome this issue you will have to move the authorized key out of home directory as default location is inside the home directory which is encrypted in this scenario. Let's take client as the machine your currently logged in and server as the machine you want to access using ssh keys. 1. log in to the client and do a ssh-copy-id ssh-copy-id -i .ssh/id_rsa.pub <user-name>@<server-ip> 2. now log in to server and copy the authorized file to a different location cp ~/.ssh/authorized_keys /etc/ssh/nuwan/authorized_keys 3. check the owner of the file moved. it should be accessible by our user. if not change owner as following sudo chown <user-name> authorized_keys 4. set the file permission  chmode 640 authorized_keys 5. now we should configure sshd file for the new ssh suthorzed file location. go to /etc/ssh/sshd_config and

Failover vs Switchover vs Failback

fail-over when there's an issue in primary system operation will be automatically switched to a secondary system. switch over similar to failover but the switching will be happened with a manual human intervention fail back this is the operation opposite of fail-over, switching all the operations back to the original.

Mediator Design Pattern

when the computer systems are becoming larger, communications between classes becomes complex. this complexity becomes simple by using mediator design pattern. with the mediator pattern, communication between objects is encapsulated with a mediator object. objects no longer directly communicate with each other, instead communicate through the mediator. this reduces the dependencies between communicating objects, thereby lowering the coupling. Good example of mediator is usage of user groups in Linux operating system. it can have many users, system can have many roles can access the system. when the users are letting access the to the system, if the user is directly mapped to the system role it will be very complex when a change is required. solution is groups, system roles are categorized in to many groups and user are categorized to many user groups. mapping between system groups and user groups will automatically let user to access the system. Comparison chain of responsibili

2 Legged OAuth 1.0 with Java Spring REST Client Example

Today I am going to show you how to consume an oAuth 1.0 secured rest service using a java spring rest template class. We can create a simple standalone class to do this exercise.  so let's start by creating simple java spring application. 1. Let's add a new class to the project as MyOAuthSample.java 2. Create a main method so we can execute the application independently. In the main method we will create an instance of MyOAuthSample class and call the showCourseMode() method.     public static void main(String[] args) {         new MyOAuthSample().showCourseMode();     } 3. Write showCourseMode() method. here we will be using spring provided  OAuthRestTemplate class to call the rest service. This template requires OAuth parameters to create. they are passed via getResouces().     private void showCourseMode() {         OAuthRestTemplate authRestTemplate=new OAuthRestTemplate(getResouces());       } 4. Create getResouces() method as following. Here we will

How to convert int to a string?

How to convert int to a string? here is int value 200 is assigned to a variable called i. int intValue =200; how can can we get that 200 to string variable s.                 String stringValue; 1st Option: simply by adding a leading empty string to the integer.         stringValue = "" + intValue ; 2nd Option: use to string method of integer class.         stringValue = Integer.toString(intValue ) ; 3rd Option: use value of method in string class.         stringValue = String.valueOf(intValue );