Security CS-328. The need for security In most of the programming classes that we’ve taken the emphasis has always been on getting the “job” done and.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
Advertisements

© 2003 School of Computing, University of Leeds SY32 Secure Computing, Lecture 17 Secure Coding in Java and.NET Part 2: Code Access Control.
Applet Security Gunjan Vohra. What is Applet Security? One of the most important features of Java is its security model. It allows untrusted code, such.
Java Security. Overview Hermetically Sealed vs. Networked Executable Content (Web Pages & ) Java Security on the Browser Java Security in the Enterprise.
Remote Method Invocation
Applets The objectives of this chapter are: To describe applets and their purpose To discuss embedding applets in HTML pages.
LAB#2 JAVA SECURITY OVERVIEW Prepared by: I.Raniah Alghamdi.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
11-Jun-15 Exceptions. 2 Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a.
Remote Method Invocation Chin-Chih Chang. Java Remote Object Invocation In Java, the object is serialized before being passed as a parameter to an RMI.
18-Jun-15 JSP Java Server Pages Reference: Tutorial/Servlet-Tutorial-JSP.html.
Object-Oriented Enterprise Application Development Javadoc Last Updated: 06/30/2001.
Certificates By Purvi Shah. What is a Certificate A certificate is basically a digitally signed statement from one entity (person, company, etc.), saying.
Introduction to Java A lab course by Dr. Junaid Ahmed Zubairi SUNY Fredonia.
Linux Operations and Administration
Chapter 5 Roles and features. objectives Performing management tasks using the Server Manager console Understanding the Windows Server 2008 roles Understanding.
Microsoft Windows 2003 Server. Client/Server Environment Many client computers connect to a server.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Week 14 - Monday.  What did we talk about last time?  Image manipulation  Inheritance.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
CS0007: Introduction to Computer Programming File IO and Recursion.
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Security in Java Sunesh Kumra S
Moodle (Course Management Systems). Assignments 1 Assignments are a refreshingly simple method for collecting student work. They are a simple and flexible.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
JAVA SERVER PAGES. 2 SERVLETS The purpose of a servlet is to create a Web page in response to a client request Servlets are written in Java, with a little.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
POS 406 Java Technology And Beginning Java Code
Java 2 security model Valentina Casola. Components of Java the development environment –development lifecycle –Java language features –class files and.
CS 320 Assignment 1 Rewriting the MISC Osystem class to support loading machine language programs at addresses other than 0 1.
Deployment via jars and Webstart. How do we distribute our application? Lab says you need to submit CD Lab says you need to submit CD Limitations of CD.
JAVA SECURITY BASIC NETWORKING MULTITHREATING Deniz HASTORUN
1 Administering Shared Folders Understanding Shared Folders Planning Shared Folders Sharing Folders Combining Shared Folder Permissions and NTFS Permissions.
Microsoft Office Outlook 2013 Microsoft Office Outlook 2013 Courseware # 3252 Lesson 6: Organizing Information.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
1 Recitation 8. 2 Outline Goals of this recitation: 1.Learn about loading files 2.Learn about command line arguments 3.Review of Exceptions.
1 Week 12 l Overview of Streams and File I/O l Text File I/O Streams and File I/O.
Software Documentation Section 5.5 ALBING’s Section JIA’s Appendix B JIA’s.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Csci5931 Web Security1 Java Security Model (GS: Ch. 7)
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming – Home and reload buttons for the webbrowser, Applets.
CS 4244: Internet Programming Network Programming in Java 1.0.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
Jaas Introduction. Outline l General overview of Java security Java 2 security model How is security maintained by Java and JVM? How can a programmer.
Week 14 - Monday.  What did we talk about last time?  Inheritance.
Manage Directories and Files in Linux Part 2. 2 Identify File Types in the Linux System The file types in Linux referred to as normal files and directories.
Java Security Session 19. Java Security / 2 of 23 Objectives Discuss Java cryptography Explain the Java Security Model Discuss each of the components.
Project Scenario for OpX. High-level Overview In the Test GUI Controller, opXController, for the opX command there is conceptually a call to an appropriate.
CIS Intro to JAVA Lecture Notes Set July-05 GUI Programming –TextField Action Listeners, JEditorPane action listeners, HTML in a JEditorPane,
Java Security cont’d. Using SecurityManager  The basic SecurityManager architecture is simple. Throughout the JDK, the Java security team had to:  Identify.
SourceAnatomy1 Java Source Anatomy Barb Ericson Georgia Institute of Technology July 2008.
UMBC Distributed Computing with Objects RMI/Corba CMSC 432 Shon Vick.
Winter 2006CISC121 - Prof. McLeod1 Stuff We had better discuss a midterm date… –27 Feb. to 3 March or –6 to 10 March.
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
Today Javadoc. Packages and static import. Viewing API source code. Upcoming Topics: –protected access modifier –Using the debugger in Eclipse –JUnit testing.
Introduction to Exceptions in Java CS201, SW Development Methods.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
1 cs205: engineering software university of virginia fall 2006 Running Untrustworthy Code Project team requests: extended until 11pm tonight.
Diagrams and Sample Code from the Java Tutorial,
Remote Method Invocation
Topic: Java Security Models
Week 14 - Wednesday CS 121.
Creating and Modifying Text part 2
Knowledge Byte In this section, you will learn about:
Fall 2018 CISC124 12/1/2018 CISC124 Note that the next assignment, on encapsulation, is due next Wednesday at 7pm – not Friday. The next Quiz is not until.
Introduction to Computing Using Java
Defensive Programming
Presentation transcript:

Security CS-328

The need for security In most of the programming classes that we’ve taken the emphasis has always been on getting the “job” done and the idea of application security is usually not considered. Now that we’re building more and more network centric applications security must be considered. Since its inception, security has been a part of Java and there has been a security model (whether or not we realized it) in place whenever we’ve written a Java application. Probably the first time you run into the idea of security in Java is in writing your first applet, at this point it’s a bother –you can’t write to the local hard drive –you can’t open a socket to where you want to talk to –you can’t access the local printer. This is your first exposure to the SecurityManage, which has a different model for applications and applets.

The SecurityManager The Securuty Manager class has been in Java since version 1.0 –part of java.lang contains many checkNNNN( ) methods –where NNNN represents an operation that could possibly be harmful ex. checkWrite( ) check whether writing to the local hard drive is enabled. If the operation is OK then the method returns normally, if nor a SecurityException is thrown. Public FileOutputStream( String name.boolean append) throws FileNotFoundException { SecurutyManager security = System.getSecurityManager( ); if (security != null) { security.checkWrite(name); }

Notice... The check only takes place when the SecurityManager is active. Java applications normally runs without a SecurityManager, that’s why everything is allowed from an application What if you found a jar file out on the internet that looked like it had some useful classes and methods in it. Would you down load it and just use it as part of your application or would it be better to test it installed under a SecurityManager first and make sure that there isn’t a Trojan Horse hidden in the jar that might do something harmful to your machine (like wipe out you hard drive or use your machine to send out thousands of s all over the network.

Running the SecurityManager The SecurityManager can be run two ways: –from the command line when you initially run your program java -Djava.security.manager MyApp –or explicity from your code Public static void main( String[] args) { SecurityManager manager = new SecurityManager(); System.setSecurityManager(manager); This installs the default/base security manager, it could have just as easily installed a subclass of the default that custonized the rules by overloading the methods (Java 1.0)

problems with doing this… The main problem with this is that the security rules were defined directly in the Java source code, so you had to get a copy of the source code and modifiy it and modify and add to the base classes and things get really messy What was needed was a SecurityManager that kept the rules externalized so that they could be easily modified without modifying the code. In most ways the Java 2 SecurityManager still operates the same way –checkNNNN methods are still called before possibly dangerous operations. What is different is that the checkNNNN methods delegate the decision on throwing SecurityException to the AccessController class –java.security package

AccessController Instead of have many methods corresponding to the many possibly harmful operations it has a single checkPermission( ) method. –Passed a parameter that indicates the kind of operation requested this parameter is an instance of a Permission subclass –the specific subclass will identify the operation and encapsulate any parameters needed – for example… the previous call to checkWrite –will result in an instance of FilePermission being passed to checkPermission( ) and that FilePermission object will describe the type of access (read or write) requested and identify the specific file involved Public void checkWrite(String file) { checkPermission(new FilePermission(file, “write”)); } public void checkPermission(Permission perm) { java.security.AccessControler.checkPermission(perm) }

This is pretty much the story... except, how does the AccessController determine whether to throw a Security Exception? This is determined by what it finds in the currently active policy file(s) a policy file is a text file containing a set of permission descriptions each permission contains the name of a particular Permission subclass ex to grant permission to write to c:\myapp\data.txt grant{ permission java.io.FilePermission “ c:\myapp\data.txt”, “write”;

policytool To save you the bother of creating permission files with a text editor the JSDK provides a GUI tool for creating policy files I find it just as easy to use wordpad (but that’s just my opinion)

Telling the JVM to use the policy Two ways: –modify the java.security configuration file that the JVM uses at start up look in /lib/security beneath you home directory –specify it when you start the JVM java -Djava.security.manager -Djava.security.policy=mypolicy.policy myapp this will cause the JVM to use mypolicy.policy in addition to whatever it finds in java.security to use the specified file in place of java.security use = = java -Djava.security.manager -Djava.security.policy= =mypolicy.policy myapp

URL specific permissions To assign permissions to files loaded from specific locations we’ll include a URL ex. To allow only classes loaded from the local C:/java directory to write to output.txt Grant codebase “file:/C:/java/” { permission java.io.FilePermission “C:/myapp/outpot.txt”, “write” } This will apply to all classes in c:/java but not to classes in a.jar file in c:\java; to get them add an “*” at the end of the URL; to incluse child directories us a “-”

Signing JAR files Its also useful to assign permissions based on the originator of the specific code being used, this can be done by adding a digital signature to the jar file use the keytool and jarsigner utilities from the JSDK this same approach can be used to assign user specific permissions