1 Lecture 20 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.

Slides:



Advertisements
Similar presentations
Siebel Web Services Siebel Web Services March, From
Advertisements

Web Services Web Services are the basic fundamental building blocks of invoking features that can be accessed by an application program. The accessibility.
 2002 Prentice Hall. All rights reserved. Chapter 9: Servlets Outline 9.1 Introduction 9.2 Servlet Overview and Architecture Interface Servlet and.
® IBM Software Group © 2006 IBM Corporation Securing Your Application With WebSphere Security You will need to develop Login procedures for your web applications.
Web Application Security SSE USTC Qing Ding. Agenda General security issues Web-tier security requirements and schemes HTTP basic authentication based.
Securing web applications using Java EE Dr Jim Briggs 1.
J.Sant Servlets Joseph Sant Sheridan Institute of Technology.
An introduction to Java Servlet Programming
2/16/2004 Dynamic Content February 16, /16/2004 Assignments Due – Message of the Day Part 1 Due – Reading and Warmup Work on Message of the Day.
1 Dickson K.W. Chiu PhD, SMIEEE Reference: Sun J2EE 1.4 Tutorial CSIT600b: XML Programming XML Programming Guide: Getting Started.
Current Topics in Programming Languages Lecture 15_1 George Koutsogiannakis SUMMER
J2EE Security and Enterprise Java Beans Mrunal G. Dhond Department of Computing and Information Sciences Master of Science, Final Defense February 26,
Version # Software Engineering Institute Carnegie Mellon University Pittsburgh, PA Sponsored by the U.S. Department of Defense © 1999 by Carnegie.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
UNIT-V The MVC architecture and Struts Framework.
Java Server Pages B.Ramamurthy. Topics for Discussion 8/20/20152 Inheritance and Polymorphism Develop an example for inheritance and polymorphism JSP.
Chapter 10 EJB Concepts of EJB Three Components in Creating an EJB Starting/Stopping J2EE Server and Deployment Tool Installation and Configuration of.
1 Lecture 22 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
C Copyright © 2009, Oracle. All rights reserved. Appendix C: Service-Oriented Architectures.
Servlets Pranav Maydeo. What is a Servlet ? Servlets are modules of Java code that run in a server application to answer client requests. Servlets are.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
Introduction to JSP Based on: Marty Hall, Larry Brown, Core Servlets and JavaServer Pages.
Chapter 5 Java Servlets. Objectives Explain the nature of a servlet and its operation Use the appropriate servlet methods in a web application Code the.
Introduction to J2EE Architecture Portions by Kunal Mehta.
Message-Driven Beans and EJB Security Lesson 4B / Slide 1 of 37 J2EE Server Components Objectives In this lesson, you will learn about: Identify features.
Java Server Pages A JSP page is a text-based document that contains two types of text: static template data, which can be expressed in any text-based format,
COMP 321 Week 7. Overview HTML and HTTP Basics Dynamic Web Content ServletsMVC Tomcat in Eclipse Demonstration Lab 7-1 Introduction.
第十四章 J2EE 入门 Introduction What is J2EE ?
CSCI 6962: Server-side Design and Programming Web Services.
CGS – 4854 Summer 2012 Web Site Construction and Management Instructor: Francisco R. Ortega Chapter 2.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Lecturer: Prof. Piero Fraternali, Teaching Assistant: Alessandro Bozzon, Advanced Web Technologies: Struts–
Chapter 3 Servlet Basics. 1.Recall the Servlet Role 2.Basic Servlet Structure 3.A simple servlet that generates plain text 4.A servlet that generates.
Source: Peter Eeles, Kelli Houston, and Wojtek Kozaczynsky, Building J2EE Applicationa with the Rational Unified Process, Addison Wesley, 2003 Prepared.
Creating competitive advantage Copyright © 2003 Enterprise Java Beans Presenter: Wickramanayake HMKSK Version:0.1 Last Updated:
Java Servlets & Java Server Pages Lecture July 2013.
Chapter 9: SHARING FILE SYSTEM RESOURCES1 CHAPTER OVERVIEW  Create and manage file system shares and work with share permissions.  Use NTFS file system.
20-Nov-15introServlets.ppt Intro to servlets. 20-Nov-15introServlets.ppt typical web page – source Hello Hello.
@2008 Huynh Ngoc Tin Chapter #2 JAVA SERVLET PRGRAMMING.
Configuring and Troubleshooting Identity and Access Solutions with Windows Server® 2008 Active Directory®
Assignment of JAVA id : BSSE-F10-M-10-JAVA1 Overview of J2EE/Session 2/Slide 1 of 38.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, Responds oriented other.
1 Introduction to Servlets. Topics Web Applications and the Java Server. HTTP protocol. Servlets 2.
JS (Java Servlets). Internet evolution [1] The internet Internet started of as a static content dispersal and delivery mechanism, where files residing.
© FPT SOFTWARE – TRAINING MATERIAL – Internal use 04e-BM/NS/HDCV/FSOFT v2/3 JSP Application Models.
COMP9321 Web Application Engineering Semester 2, 2015 Dr. Amin Beheshti Service Oriented Computing Group, CSE, UNSW Australia Week 3 1COMP9321, 15s2, Week.
Slide 1 Web Application Security ©SoftMoore Consulting.
©SoftMoore ConsultingSlide 1 Overview of Servlets and JavaServer Pages (JSP)
DEVELOPING ENTERPRISE APPLICATIONS USING EJB
HTTP protocol Java Servlets. HTTP protocol Web system communicates with end-user via HTTP protocol HTTP protocol methods: GET, POST, HEAD, PUT, OPTIONS,
Java Programming: Advanced Topics 1 Enterprise JavaBeans Chapter 14.
15 Copyright © 2004, Oracle. All rights reserved. Adding JAAS Security to the Client.
8 Copyright © 2004, Oracle. All rights reserved. Making the Model Secure.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Copyright 2007, Information Builders. Slide 1 iWay Web Services and WebFOCUS Consumption Michael Florkowski Information Builders.
Securing Web Applications Lesson 4B / Slide 1 of 34 J2EE Web Components Pre-assessment Questions 1. Identify the correct return type returned by the doStartTag()
DEVELOPING WEB SERVICES WITH JAVA DESIGN WEB SERVICE ENDPOINT.
1 Lecture 8 George Koutsogiannakis/Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES.
17 Copyright © 2004, Oracle. All rights reserved. Integrating J2EE Components.
Spell Checker web service (you build a web client that interacts with the service) The client uses a servlet class and a JSP page. The user passes information.
1 Web Programming with Servlets & JSPs WEB APPLICATIONS – AN OVERVIEW.
Enterprise Java Beans. Contents  Understanding EJBs  Practice Section.
Web Programming Developing Web Applications including Servlets, and Web Services using NetBeans 6.5 with GlassFish.V3.
Java Servlets By: Tejashri Udavant..
Writing simple Java Web Services using Eclipse
Web Services-JAX-RPC JAX-RPC enables a Web Service endpoint to be developed using either a Java Servlet or Enterprise JavaBeans (EJB) component model.
Objectives In this lesson you will learn about: Need for servlets
Introduction to Web Services
Distributed System using Web Services
Presentation transcript:

1 Lecture 20 George Koutsogiannakis Summer 2011 CS441 CURRENT TOPICS IN PROGRAMMING LANGUAGES

Topics Realms, Users, Groups. Web Security Example. Application Server Security. Web Services definitions. 2

Realms, Users, Groups A Realm is defined on the Application Server or the Web Server. In this lecture we assume that GlassFish is used regardless if the application is just a web application or a combination of web/ejb. 3

Realms, Users, Groups A REALM – Contains a collection of users that are covered by the same authentication policy. – Users are assigned to roles as discussed in previous lecture. – A Group is a set of authenticated users classified by common traits defined in the Application Server. 4

Realms, Users, Groups Realm appears as a data source (can be a table) of users and groups. There are 3 mappings of Realm: – file:all clients except those that use certificates and HTTPS. – certificate: clients are authenticated using certificates and HTTPS – admin-realm: special realm reserved for administrators to manage users. 5

Realms, Users, Groups Realm contains a collection of users which may or may not be assigned to a group. – For a web application, a realm is a complete database of users and groups that identify valid users of a web application (or a set of web applications) and are controlled by the same authentication policy. 6

Realms, Users, Groups A user is an individual (or application program) identity that has been defined in the Application Server. – In a web application, a user can have a set of roles associated with that identity, which entitles them to access all resources protected by those roles. Users can be associated with a group. 7

Realms, Users, Groups A group is a set of authenticated users, classified by common traits, defined in the Application Server. Principal: A principal is an entity that can be authenticated by an authentication protocol in a security service that is deployed in an enterprise (in other words a user). Security policy domain (also known as security domain or realm): A security policy domain is a scope over which a common security policy is defined and enforced by the security administrator of the security service. 8

9

Web Security Example Overview of Web Application Security – In the Java EE platform, web components provide the dynamic extension capabilities for a web server. Web components are either Java servlets, JSP pages, JSF pages, or web service endpoints. 10

11

Web Security Example Basic Authentication with a Servlet 1.Add an authorized user to the Application Server. Start the Application Server in NetBeans services window. Start the Admin Console by right clicking on the server in NetBeans and choosing view admin console.. To log in to the Admin Console, enter the user name and password of a user in the admin-realm who belongs to the asadmin group. The name and password entered during installation will work, as will any users added to this realm and group subsequent to installation. Expand the Configuration node in the Admin Console tree. 12

Web Security Example-Add user to Application Server Expand the Security node in the Admin Console tree. Expand the Realms node. Select the file realm to add users you want to enable to access applications running in this realm. (For the example security applications, select the file realm.) Select the admin-realm to add users you want to enable as system administrators of the Application Server. You cannot enter users into the certificate realm using the Admin Console. You can only add certificates to the certificate realm. 13

Web Security Example-Add user to Application Server Click the Manage Users button. Click New to add a new user to the realm. Enter the correct information into the User ID, Password, and Group(s) fields. If you are adding a user to the file realm, enter the name to identify the user, a password to allow the user access to the realm, and a group to which this user belongs. 14

Web Security Example-Add user to Application Server For the example security applications, enter a user with any name and password you like, but make sure that the user is assigned to the group of user. If you are adding a user to the admin-realm, enter the name to identify the user, a password to allow the user access to the Application Server, and enter asadmin in the Group field. Click OK to add this user to the list of users in the realm. Click Logout when you have completed this task. 15

Web Security Example-Add roles 2.Add roles: – You can add roles in the web.xml descriptor file. The following is an example of a security constraint from a web.xml application deployment descriptor file where the role of DEPT-ADMIN is authorized for methods that review employee data and the role of DIRECTOR is authorized for methods that change employee data. view dept data /hr/employee/* ` GET POST 16

Web Security Example-Add roles DEPT_ADMIN CONFIDENTIAL 17

Web Security Example-Add roles change dept data /hr/employee/* GET PUT DIRECTOR CONFIDENTIAL 18

Web Security Example-Add roles Notice the element This element requires that all security contraint URL pattrens and HTTP methods are received over a protected transport layer. – The choice COFIDENTIAL means that the transmitted data can not be accessed by other entities. HTTPS is used (SSL) Notice the element is used to define the users in their roles. The element idetifies the URLs (resources) to be protected. Another element (not shown) is is used to authenticate access to the web content by a user (before any request is processed base don a role). 19

Web Security Example-Add roles 3.The last step is to map the security role to the name of a user, or principal (in the application server). – The security architecture provides a mechanism for mapping the roles defined in the application to the users or groups defined in the runtime realm. – Use the security-role-mapping element in the runtime deployment descriptor (sun-application.xml, sun-web.xml, or sun-ejb-jar.xml) file. 20

Web Security Example-Add roles – The entry needs to declare a mapping between a security role used in the application and one or more groups or principals defined for the applicable realm of the Application Server. An example for the sun-web.xml file is shown below: – DIRECTOR mcneely DEPT_ADMIN administrators 21

Web Security Example-Servlets Create a web module hello2. The subsequent steps discuss adding security to this basic application. The files for this example application are in tut- install/javaeetutorial5/examples/web/hello2_basica uth/. – There are two servlets: – GreetingSerlet.java – ResponseServlet.java 22

Web Security public class GreetingServlet extends HttpServlet { public void doGet( HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); response.setBufferSize(8192); PrintWriter out = response.getWriter(); // then write the data of the response out.println(" " + " Hello "); out.println(" " 23

Web Security Example-Servlets + " " + " Hello, my name is Duke. What's yours? " + " " + " " + " " + " " + " "); String username = request.getParameter("username"); if ((username != null) && (username.length() > 0)) { RequestDispatcher dispatcher = getServletContext().getRequestDispatcher( "/response"); if (dispatcher != null) { dispatcher.include(request, response);} } out.println(" "); out.close(); } 24

Web Security Example-Servlets public String getServletInfo() { return "The Hello servlet says hello."; } 25

Web Security Example-Servlets public class ResponseServlet extends HttpServlet { public void doGet( HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); // then write the data of the response String username = request.getParameter("username"); if ((username != null) && (username.length() > 0)) { out.println(" Hello, " + username + "! "); } public String getServletInfo() { return "The Response servlet says hello."; } 26

Web Security Example-Servlets Declare the roles that will be used in this application. For this example, this is done by adding annotation to GreetingServlet.java. The deployment descriptor web.xml should have the role described : 27

Web Security Example-web.xml SecurityConstraint WRCollection /greeting helloUser NONE BASIC file 28

Web Security Example- sun-web.xml (Application Server) Map the role name defined for this resource (helloUser) to a group of users defined on the Application Server. – That is the roles define din the web.xml must be linked to the users in the Application Server. – Mapping Application Roles to Application Server Groups Map the role of helloUser defined in the application to the group of user defined on the Application Server by adding a security- role-mapping element to the sun-web.xml runtime deployment descriptor file. 29

Web Security Example- sun-web.xml The runtime deployment descriptor is an XML file that contains information such as the context root of the web application and the mapping of the portable names of an application’s resources to the Application Server’s resources. 30

Web Security Example- sun-web.xml /hello2_basicauth helloUser user 31

Web Security Example Add authorized users to the file type realm of the Application Server Build, package, and deploy the web application. 32

Summary of Security Settings for a Web Application 1.Identify realms. Groups and users in the Application server. 2.Create the web.xml security role sin combination with annotations in your web resources code. Identify the security roles. 33

Summary of Security Settings for a Web Application 3.Map the security roles to the security constraints in the Application server. Elements of the security constraints will define the users/group that pertain to the particular role and the security restrictions for that role. Notice that the security restrictions are linked to particular resources defined in the proper element. 34

Security for Java EE Components. Let us discuss security for Enterprise Beans. – Enterprise Beans can be called from application clients or from web applications (as in previous slides). – The EJB container can provide additional security pertaining to the beans. This can be accomplished in a declarative way and/or in a programmatic way. 35

36

Security for Java EE Components You can protect enterprise beans by doing the following: – Accessing an Enterprise Bean Caller's Security Context – Declaring Security Role Names Referenced from Enterprise Bean Code – Defining a Security View of Enterprise Beans – Using Enterprise Bean Security Annotations – Using Enterprise Bean Security Deployment DescriptorElements. 37

Security for Java EE Components Accessing an Enterprise Bean Caller’s Security Context – In general, security management should be enforced by the container in a manner that is transparent to the enterprise beans’ business methods. – The security API described in this section should be used only in the less frequent situations in which the enterprise bean business methods need to access the security context information. 38

Security for Java EE Components – The javax.ejb.EJBContext interface provides two methods that allow the bean provider to access security information about the enterprise bean’s caller. java.security.Principal getCallerPrincipal (); The purpose of the getCallerPrincipal method is to allow the enterprise bean methods to obtain the current caller principal’s name. The methods might, for example, use the name as a key to information in a database. boolean isCallerInRole(String roleName); The purpose of the isCallerInRole(String roleName) method is to test whether the current caller has been assigned to a given security role. 39

Security for Java EE Components If we assume, for example, that the current caller user contains the primary key used for the identification of employees (for example, employee number): / /obtain the caller principal callerPrincipal = ctx.getCallerPrincipal(); // obtain the caller principal’s name. callerKey = callerPrincipal.getName(); // use callerKey as primary key to find EmployeeRecord EmployeeRecord myEmployeeRecord = em.findByPrimaryKey(EmployeeRecord.class, callerKey); 40

Security for Java EE Components Declaring Security Role Names Referenced from Enterprise Bean Code – You can declare security role names used in enterprise bean code using either annotation (preferred) or the security-role-ref elements of the deployment descriptor. 41

Security for Java EE Components Defining a Security View of Enterprise Beans – You can define a security view of the enterprise beans contained in the ejb-jar file and pass this information along to the deployer. – When a security view is passed on to the deployer, the deployer uses this information to define method permissions for security roles. – If you don’t define a security view, the deployer will have to determine what each business method does to determine which users are authorized to call each method. 42

Security for Java EE Components A security view consists : – of a set of security roles, a semantic grouping of permissions that a given type of users of an application must have to successfully access the application. Security roles are meant to be logical roles, representing a type of user. – You can define method permissions for each security role. A method permission is a permission to invoke a specified group of methods of the enterprise beans’ business interface, home interface, component interface, and/or web service endpoints. You can specify an authentication mechanism that will be used to verify the identity of a user. 43

Security for Java EE Components Use annotations to define security roles using Java language annotations. The set of security roles used by the application is the total of the security roles defined by the security role names used in annotations (multiple roles can be defined). 44

Security for Java EE Components Enterprise JavaBeans components use an EJB deployment descriptor that must be named : – META-INF/ejb-jar.xml (must be contained in the EJB JAR file). – The role of the deployment descriptor is to relay information to the deployer about security and other aspects of the application. Specifying this information in annotations or in the deployment descriptor helps the deployer set up the appropriate security policy for the enterprise bean application. 45

Security for Java EE Components The following is a listing of deployment descriptor elements that address security: – The security-role-ref element declares each security role referenced in the code. – The security-role element defines broad categories of users, and is used to provide access to protected methods. – The method-permission element is used to specify method permissions. – The run-as element is used to configure a component’s propagated security identity. 46

Security for Java EE Components You can augment the set of security roles defined for the application by annotations using the security-role deployment descriptor in the ejb-jar.xml file. i.e. This role includes the employees of the enterprise who are allowed to access the employee self-service application. This role is allowed only to access his/her own information. employee 47

Security for Java EE Components We have two levels of security: – We are trying to set the security references of the component. – We also have the security references at the application level. – The two need to be linked. In the absence of explicit linking a role at the component level will be linked automatically to a role with the same name at the application level. Or, you can explicitly link all the security role references declared in annotation or security-role-ref elements for a component to the security roles defined by the use of annotations and/or in the security-role elements. 48

Security for Java EE Components You can use the role-link element to link each security role reference of a component to a security role at the application level i.e. AardvarkPayroll com.aardvark.payroll.PayrollBean... This role should be assigned to the employees of the payroll department. Members of this role have access to anyone’s payroll record. The role has been linked to the payroll-department role. payroll payroll-department... 49

Security for Java EE Components Specifying Method Permissions – If you have defined security roles for the enterprise beans in the ejb-jar file, you can also specify the methods of the business interface, home interface, component interface, and/or web service endpoints that each security role is allowed to invoke. 50

Security for Java EE Components Specifying Method Permissions Using Annotations – The method permissions for the methods of a bean class can be specified on the class, the business methods of the class, or both. – Method permissions can be specified on a method of the bean class to override the method permissions value specified on the entire bean list-of-roles is a list of security role names to be mapped to the security roles that are permitted to execute the specified method or methods. Specifying this annotation on the bean class means that it applies to all applicable business methods of the class. 51

Security for Java EE Specifies that all security roles are permitted to execute the specified method or methods. Specifying this annotation on the bean class means that it applies to all applicable business methods of the Specifies that no security roles are permitted to execute the specified method or methods. 52

Security for Java EE public class SomeClass { public void aMethod () {...} public void bMethod () {...}... public class MyBean implements SomeClass public void aMethod () {...} public void cMethod () {...}... } The method permissions values of methods aMethod and bMethod and respectively. The method permissions for method cMethod have not been specified. 53

WEB SERVISES What are Web Services? – a software system designed to support interoperable machine-to-machine interaction over a network". – Web services are frequently just Web application programming interfaces (API) that can be accessed over a network, such as the Internet, and executed on a remote system hosting the requested services 54

WEB SERVICES What are Web Services? – Web services are application components – Web services communicate using open protocols – Web services are self-contained and self-describing – Web services can be discovered using UDDI – Web services can be used by other applications – XML is the basis for Web services 55

WEB SERVICES The basic Web services platform is XML + HTTP. – XML provides a language which can be used between different platforms and programming languages and still express complex messages and functions. – The HTTP protocol is the most used Internet protocol. – Web services platform elements: SOAP (Simple Object Access Protocol) UDDI (Universal Description, Discovery and Integration) WSDL (Web Services Description Language) 56

Study Guide Read Chapters 29 and 30 of EE5 Tutorial or corresponding chapters in EE6 tutorial. 57