• No results found

Web Application Access Control with Java SE Security

N/A
N/A
Protected

Academic year: 2021

Share "Web Application Access Control with Java SE Security"

Copied!
30
0
0

Loading.... (view fulltext now)

Full text

(1)

Java Forum Stuttgart 2009

Web Application Access Control

with Java SE Security

(2)

Agenda

1. Access Control Basics

2. The Java Authentication and Authorization Service (JAAS) 3. Enhancement and Application of JAAS

4. Role-Based Access Control

5. Instance-Based Access Control

(3)

Access Control Basics

Subject Resource

Environment Action

Subject: A user, system, etc.

Resource: A file, printer, domain object, etc.

Action: An operation on a resource (read, print, create, etc.)

Environment: Access control relevant attributes not available from Subject,

Action or Resource (time, location, …)

(4)

Access Control Architecture

Subject Resource

PEP

PDP

PAP

PEP: Policy Enforcement Point PDP: Policy Decision Point

PAP: Policy Administration Point

Environment Policy Store 1. Business request 6. Business request 5. Access decision 2. Access request 4. Policy 3. Attributes (optional)

(5)

Agenda

1. Access Control Basics

2. The Java Authentication and Authorization Service (JAAS) 3. Enhancement and Application of JAAS

4. Role-Based Access Control

5. Instance-Based Access Control

(6)

Limitations of JEE Security

With the declarative JEE security model, it is difficult to change security policies when new requirements arise

The declarative model limits the expressiveness of security policies Only one authentication method per application allowed

(7)

Java Authentication and Authorization Service (JAAS)

Originally, Java SE Authorization was based exclusively on the code

accessing resources and authentication was based on digital signatures applied to the code

JAAS was designed to address this shortcoming and is part of Java SE since V. 1.4

JAAS authentication is an implementation of the Pluggable Authentication Module (PAM) framework and allows applications to authenticate

independently from the underlying technology (user/password, certificate,…) JAAS authorization allows access control based on who is executing the code

(8)

JAAS Authentication

JAAS Authentication JAAS Configuration javax.security.auth.login.LoginContext API SPI javax.security.auth.spi.LoginModule login() throws javax.security.auth.login.LoginException initialize(Subject s, CallbackHandler c, Map sharedState, Map options);

login() throws LoginException; commit() throws LoginException; abort() throws LoginException; logout() throws LoginException;

(9)

JAAS Authorization

JAAS Authorization

Permission: encapsulates access control relevant attributes of Action and Resource AccessControlException: thrown if access to Resource is denied

ProtectionDomain: provides Subject java.security.AccessController API SPI java.security.Policy checkPermission(java.security.Permission) throws java.security.AccessControlException implies(java.security.ProtectionDomain, java.security.Permission)

(10)

Agenda

1. Access Control Basics

2. The Java Authentication and Authorization Service (JAAS) 3. Enhancement and Application of JAAS

4. Role-Based Access Control

5. Instance-Based Access Control

(11)

Application of JAAS Authentication

JAAS Authentication ServletFilter-driven Enforcement DefaultLoginModule LoginModule LoginContext FormLogin Filter Servlet Filter BasicLogin Filter Servlet Filter CertificateLogin Filter Servlet Filter PinLogin Filter Servlet Filter JAAS Configuration Pluggable Authenticator

(12)

Subject and Principals

javax.security.auth.Subject

UserPrincipal

A successful authenticated subject is represented in Java by a javax.security.auth.Subject instance

A subject is associated with identities. In Java an identity is represented by the java.security.Principal interface

An application provides Principal implementations

java.security.Principal

RolePrincipal

*

(13)

Application of JAAS Authorization

JAAS Authorization Annotation-driven Enforcement Subject Resource Security Annotation Framework (SAF) Access Decision Framework Extensible Access Decision Policy AccessController

(14)

AspectJ

Security Annotation Framework (SAF)

Spring AOP Proxy Spring Bean JAAS Domain Object Subject Resource Resource Method Interceptor AspectJ Advice Spring AOP Created at runtime RT RT

Created at compile time CT 1 1 2 4 3 2 3 4 Enhanced Bytecode CT SAF Access Manager

(15)

public interface RecordService {

@Filter

public Set<Record> findAll();

public Record create (@Secure (SecureAction.CREATE) Record record); }

(16)

@SecureObject

public class Record {

private Set<Medication> medications;

@Secure (SecureAction.UPDATE)

public void addMedication(Medication medication) { medications.add(medication);

} ... }

(17)

Access Decision Framework

java.security. Policy Product * AccessPolicy 1 AccessDecision Voter AccessDecision Combiner Product AccessDecision Combiner Product AccessDecision Voter A Product AccessDecision Voter B 1

(18)

Enabling JAAS in a Web Application

A JEE-compliant Web Application Server (WAS) is required to support JAAS However, the JEE specification does not require a WAS to use JAAS as its own authentication and authorization mechanism

JAAS has to be enabled by the web application itself: Set the JAAS policy during application startup,

i.e. call java.security.Policy.setPolicy(customPolicy) in the ContextListener Use one (or more) JAAS authentication servlet filter/s

Use a JAAS authorization servlet filter that adds a Subject to the JAAS access control context (i.e. call javax.security.auth.Subject.doAsPrivileged(…)

JAAS Authentication Filter request JAAS Authorization Filter request Servlet request

(19)

Agenda

1. Access Control Basics

2. The Java Authentication and Authorization Service (JAAS) 3. Enhancement and Application of JAAS

4. Role-Based Access Control

5. Instance-Based Access Control

(20)

Role-Based Access Control (RBAC)

Role A Role B Role C

P1 P2 P3 “Bob” P4 Pn Permission n Permission Assignment Principal

JAAS Subject “Bob”:

Bob Role A Role B Role C P4 P1 -P2,P3 Permission Role Assignment

(21)

Hierarchical Role-Based Access Control (HRBAC)

User Professional Physician P1 P2 P3 “Bob” Physician Bob Permission Principal

Effective Permissions for Subject “Bob”: P1,P2,P4 JAAS Subject “Bob”:

Pharmacist Non-Professional P4 -P4 P2 P1 Professional User

(22)

Principal Provider Pattern

JAAS Authentication Composite PrincipalProvider LoginModule LoginContext JAAS Configuration Role PrincipalProvider Organization PrincipalProvider PrincipalProvider DefaultLoginModule Product *

(23)

Agenda

1. Access Control Basics

2. The Java Authentication and Authorization Service (JAAS) 3. Enhancement and Application of JAAS

4. Role-Based Access Control

5. Instance-Based Access Control

(24)

Instance-Based Access Control (IBAC)

“Bob” :Record owner=“Bob” :Record owner=“Alice” :Record owner=“Paul” :Record owner=… Policy:

Bob has access on Records

No Access on other Records

Instances of domain objects are secured resources

Access decisions are based on the state of the instances

:Record owner=“Sue”

(25)

@SecureObject

public class Record { ...

@SecurityRelevant

private String owner;

... }

Annotation-Driven IBAC

The PEP extracts all security relevant attributes from the domain object instance and puts them into a java.security.Permission implementation.

(26)

Agenda

1. Access Control Basics

2. The Java Authentication and Authorization Service (JAAS) 3. Enhancement and Application of JAAS

4. Role-Based Access Control

5. Instance-Based Access Control

(27)

Sample Application

Record

Use Cases

- Create a new user with roles and an associated new record - Grant access rights to a user

Add medications and observations to a record Medication

*

Personal Health Record User Management

Observation * * User Role * Domain Model owner 1

(28)

Sample Application Technology

Libraries:

Java SE 6

Spring IOC / AOP / MVC V. 2.5

Security Annotation Framework (SAF) V. 0.9 Servlets V. 2.5 AspectJ V. 1.6 Testing JUnit V. 4.4 EasyMock V.2.4 Build Maven V. 2.0 Platform Tomcat V. 6.0

(29)

Resources

Java SE Security

http://java.sun.com/javase/technologies/security/

Security Annotation Platform (SAF)

http://safr.sourceforge.net/

OASIS eXtensible Access Control Markup Language (XACML)

http://www.oasis-open.org/committees/tc_home.php?wg_abbrev=xacml

Enterprise Java Security: Building Secure J2EE Applications by Marco Pistoia et al., Addison Wesley, 2004

Creative Commons Icons

(30)

Contact

E-Mail: [email protected] www.icw-global.com InterComponentWare AG Jürgen Groothues Industriestraße 41 69190 Walldorf, Germany

References

Related documents

P3,I1 Computer Engineer P3,I1 Computer Programmer P3,I1 Geotechnologist P3,I1 Industrial Engineer P3,I1 Network Controller P3,I1 Paint Technologist P3,I1 Paper

• Four concrete cells of size 150 cm x 30 cm and a depth of 60 cm received wastewater from the Maturation Waste Stabilization Ponds: the four cells were planted with macrophytes

Penguasaan bahasa Indonesia akan lebih memudahkan pembelajar penutur bahasa asing untuk berkomunikasi, baik komunikasi secara lisan maupun tulis. Pembelajar penutur asing

The last stage of a natural products screening programme is to determine whether metabolites isolated exhibit biological activity.. There are a number of screens

Academic Success mempunyai 3 faktor yang pertama adalah hope (harapan) dimana individu yang memiliki harapan positif pada masa depannya maka akan memiliki

Explain to students that a business plan is no different to any other sort of plan and will give students the opportunity to think through all of the things that will help to make

García Ansola P., García A., Encinas J.C., De las Morenas J., &#34;Experimental platform for the analysis of the RFID enhanced agent based management system of a