Privacy On The Net - Anon Proxies

If you think you are safe if you are using a proxy server , think again.

“Yesterday, Cody Kretsinger, a 23-year-old from Phoenix, Arizona was arrested and charged with conspiracy and the unauthorized impairment of a protected computer, according a federal indictment.

How did the Feds track down the alleged LulzSec member? It turns out that a VPN service reportedly used to mask his online identify and location was the one who handed over data to the FBI.”

SOURCE : http://www.securityweek.com/vpn-service-snitched-alleged-lulzsec-member

SOURCE2 : http://blog.hidemyass.com/2011/09/23/lulzsec-fiasco/

The lesson of this? Be careful who you targets at.

Access Levels In OOP | Access Levels

Intro To Access Levels

As I said yesterday in the post on classes , I would be going over the meaning of “Public” , “Private” , “Protected” which are either called access levels or access modifiers or whatever it is called when you read this post. Their main purpose to specify how they can be used by other objects during execution. They are used when we define a variable or a method , such as

public int gear;
.
.
.
public void setGear(int newValue) {
        gear = newValue;
}
.
.
.
.

We shall start with the most obvious of all , “Public” , which you might have guessed , means free for all. Basically , you can use a public method or a public variable anywhere , within classes or packages. That makes sense isn’t it? When you write an employee class , and your partner is writing a department class , you expect he would use some of your employee class variables in his class. Then why not make public the default? Instead of writing a method to set gear , look above for the code , why don’t we all write like this?

b1.gear = 6;

So what then is the difference between these two lines?

b1.gear = 6;
b1.setGear(6);

As per the code above , there isn’t any. You just assigned a value to the attribute of an instance of a Bicycle class. No big deal. But there is a big deal if you want checks and rules. What if a user assigned the gear as this ,

b1.gear = 1000;

Nothing wrong with it. It is still an integer value assigned to an integer-type variable. But there is something wrong with a bicycle with 1000 gears. From the Yahoo Answers , it seems the most gears possible on a bicycle is 24. So how would you ensure that the value of “gear” is no more than 24? You can’t if the variable is public.

But you could prevent others from accessing the variable directly it , or encapsulate it as OOP textbooks would say , by using “Protect” or “Private” access levels instead of “Public. I have not going through sub-classes so lets just take it that the main difference between “Protect” and “Private” access levels is that “Protect” allows the classes in the same package to access but “Private” variable or method is accessible only in the class in which it is defined.

Reworking Of Our Class

private int gear;
.
.
.
public void setGear(int newValue) {
        gear = newValue;
}
.
.
.
.

Changing Access Levels

Now you could no longer access the gear variable directly from outside as before. The method setGear() must be used in order to change its value. You could now place necessary codes in the function to check if the input value is 24 or less or else reject it. It would look like this.

public int setGear(int newValue) {
       if ( newValue <= 24 ) {
       gear = newValue;
       return 0;
       }
       else {
        return 1;
        }
}

Basically , if the input is less than or equal to 24 , the value would be updated and number 0 would be returned and otherwise , 1 would be returned. Of course there are much better and efficient way of checking but for our example , this would suffice.

Concluding Access Levels

Hope this clear up doubts you may have about the access levels. If you have questions , pls feel free to comment below. Cya!