Sie sind auf Seite 1von 93

Keep

Learning with Oracle University

Classroom Training

Cloud

Learning SubscripFon

Technology

Live Virtual Class

ApplicaFons

Training On Demand

Industries

educa7on.oracle.com
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

Session Surveys
Help us help you!!
Oracle would like to invite you to take a moment to give us your session
feedback. Your feedback will help us to improve your conference.
Please be sure to add your feedback for your aQended sessions by using
the Mobile Survey or in Schedule Builder.

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

Finally, EE Security API


JSR 375
Alex Kosowski
JSR 375 SpecicaFon Lead
Oracle, WebLogic Server Security
October 27, 2015

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

Safe Harbor Statement


The following is intended to outline our general product direcFon. It is intended for
informaFon purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or funcFonality, and should not be relied upon
in making purchasing decisions. The development, release, and Fming of any features or
funcFonality described for Oracles products remains at the sole discreFon of Oracle.

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

Program Agenda
1

MoFvaFons

A New JSR

Ideas

Get Involved

Q & A

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

Program Agenda
1

MoFvaFons

A New JSR

Ideas

Get Involved

Q & A

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

Why a Java EE Security API JSR?


EE 8 survey results
4500 total responses
PrioriFes Pie Chart

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

Whats wrong with Java EE Security?


The community says

"The ul(mate goal is to have basic security working without


the need of any kind of vendor specic congura(on,
deployment descriptors, or whatever.
Arjan Tijms

[The EE security] model is problema(c in cloud/PaaS
environments where developers do not necessarily have easy
access to non-standard vendor run(me features and a self-
contained applica(on is much easier to manage.
Reza Rahman
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

10

Whats wrong with Java EE Security?


Java EE Security viewed as not portable, abstract/confusing, anFquated
Doesnt t cloud app developer paradigm: requires app server
conguraFon
Losing value to non-standard 3rd Party Frameworksless likely to move
back to Java EE

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

11

What to do?
Plug the portability holes
Modernize
Contexts and Dependency InjecFon (CDI)
Intercept at Access Enforcement Points: POJO methods

Expression Language (EL)


Enable Access Enforcement Points with complex rules

Lambda Expressions

App Developer Friendly


Common security conguraFons not requiring server changes
AnnotaFon defaults not requiring XML
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

12

Program Agenda
1

MoFvaFons

A New JSR

Ideas

Get Involved

Q & A

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

13

JSR 375 History


August 2014: First proposed to Oracle Java EE Architects
December 2014: Approved by JCP
Expert Group nominaFons:
EE API veterans: many JSRs, many years struggling with Security API
3rd party security framework creators/developers
EE plaporm security implementers

March 2015: Expert Group started discussions

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

14

JSR 375 Expert Group


Name

Represen7ng

Adam Bien

Individual

David Blevins

Tomitribe

Rudy De Busscher

Individual

Ivar Grimstad

Individual

Les Hazlewood

Stormpath, Inc.

Will Hopkins

Oracle

Werner Keil

Individual
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

15

JSR 375 Expert Group


Name

Represen7ng

MaQ Konda

Jemurai

Alex Kosowski

Oracle

Darran Lorhouse

RedHat

Jean-Louis Monteiro

Tomitribe

Ajay Reddy

IBM

Pedro Igor Silva

RedHat

Arjan Tijms

ZEEF
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

16

JSR 375 Expert Group


In rst month, expert group had an EXPLOSION of acFvity
Lot of Brainstorming!
237 messages on EG mailing list
81 commits in Github playgrounds for examples and proposals
24 JIRA issues

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

17

JSR 375 Roadmap

Early Drar
Review

Public
Review/RI

Proposed
Final Drar

Final Release/
RI/TCK

Q4 2015

Q1 2016

Q3 2016

H1 2017

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

18

Program Agenda
1

MoFvaFons

A New JSR

Ideas

Get Involved

Q & A

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

19

Ideas
To modernize, standardize, simplify

Terminology
API for AuthenFcaFon Mechanism
API for IdenFty Store
API for Password Aliasing
API for Role/Permission Assignment
API for Security Context
API for AuthorizaFon Interceptors

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

20

Ideas
To modernize, standardize, simplify
Role/Permission
Assignment

IdenFty Store

AuthenFcaFon
Mechanism

Security Context

AuthorizaFon
Interceptors

Password Aliasing
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

21

Ideas
To modernize, standardize, simplify

Terminology
API for AuthenFcaFon Mechanism
API for IdenFty Store
API for Password Aliasing
API for Role/Permission Assignment
API for Security Context
API for AuthorizaFon Interceptors

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

22

Ideas - Terminology
EG discussions revealed inconsistency in security API terms
Dierent EE containers have dierent names for the same concepts
When something gets authenFcated, is that something a
A User? (e.g. HQpServletRequest.getUserPrincipal)
A Caller? (e.g. EJBContext.getCallerPrincipal)

What is a group?
A group of users?
A permission
Vs Role?
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

23

Ideas - Terminology
What is that something where idenFFes are stored?
security provider (WebLogic)
realm (Tomcat, some hints in Servlet spec)
(auth) repository
(auth) store
login module (JAAS)
idenFty manager (Undertow)
authenFcator (Resin, OmniSecurity, Seam Security)
authenFcaFon provider (Spring Security)
idenFty provider
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

24

Ideas
To modernize, standardize, simplify

Terminology
API for AuthenFcaFon Mechanism
API for IdenFty Store
API for Password Aliasing
API for Role/Permission Assignment
API for Security Context
API for AuthorizaFon Interceptors

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

25

Use Case
API for Authen7ca7on Mechanism

ApplicaFon manages its own users and groups


ApplicaFon needs to authenFcate users in order to assign Roles
ApplicaFon authenFcates based on applicaFon-domain models
ApplicaFon needs to use an authenFcaFon method not supported on the
server, like OpenID Connect
Developer wants to use portable EE AuthenFcaFon standard

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

26

Current SoluFons
API for Authen7ca7on Mechanism

Proprietary server support

3rd party security frameworks provide authenFcaFon


JASPIC: Java AuthenFcaFon Service Provider Interface for Containers

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

27

JASPIC
Java AuthenFcaFon Service Provider Interface for Containers
JSR 196, Maintenance Release 1.1, in 2013
Standardized, portable, thin, low-level authenFcaFon framework
Extensible from within an applicaFon
Integrates with the container to build an authenFcated Subject
Implement most authenFcaFon methods

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

28

JASPIC Server Auth Module


public interface ServerAuthModule {

public void initialize(MessagePolicy requestPolicy,
MessagePolicy responsePolicy, CallbackHandler handler,
Map options) throws AuthException;

public AuthStatus validateRequest(MessageInfo messageInfo,
Subject clientSubject, Subject serviceSubject);

public Class<?>[] getSupportedMessageTypes();

public AuthStatus secureResponse(MessageInfo messageInfo,
Subject serviceSubject);

public void cleanSubject(MessageInfo messageInfo, Subject subject);
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

29

JASPIC Per-ApplicaFon InstallaFon


ServletContextListener
AuthCongFactory
AuthCongProvider
ServerAuthCong
ServerAuthContext
ServerAuthModule
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

30

Ideas Simple ServerAuthModule InstallaFon


ServletContextListener
AuthCongFactory
AuthCongProvider

ServletContextListener

ServerAuthCong
ServerAuthContext
ServerAuthModule
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

31

Ideas Simple ServerAuthModule InstallaFon


@WebListener
public class SamRegistrationListener implements ServletContextListener {

@Override
public void contextInitialized(ServletContextEvent sce) {
Jaspic.registerServerAuthModule(new TokenAuthModule(),
sce.getServletContext());
}

@Override
public void contextDestroyed(ServletContextEvent sce) {
}
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

32

Ideas Simple ServerAuthModule InstallaFon


@Authenticator("org.acme.TokenAuthModule")
@WebServlet("/SimpleServlet")
@ServletSecurity(@HttpConstraint(rolesAllowed = {"manager"}))
public class SimpleServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().print("my GET");
}
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

33

Ideas Prole Specic Helper Classes


public class BasicServerAuthModule implements ServerAuthModule {

public void initialize() throws AuthException { }

public Class<?>[] getSupportedMessageTypes() { }

public AuthStatus secureResponse(MessageInfo messageInfo,
Subject serviceSubject) throws AuthException { }

public void cleanSubject(MessageInfo messageInfo, Subject subject)
throws AuthException { }

public AuthStatus validateRequest(MessageInfo messageInfo,
Subject clientSubject, Subject serviceSubject) throws AuthException {
final HttpServletRequest request =
(HttpServletRequest) messageInfo.getRequestMessage();
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

34

Ideas Prole Specic Helper Classes


public class BasicServerAuthModule extends HttpServerAuthModule {

public AuthStatus validateHttpRequest(HttpServletRequest request,
HttpServletResponse response, HttpMessageContext httpMessageContext)
throws AuthException {

}
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

35

Ideas Prole Specic Helper Classes


public class BasicServerAuthModule extends HttpServerAuthModule {

public AuthStatus validateHttpRequest(HttpServletRequest request,
HttpServletResponse response, HttpMessageContext httpMessageContext)
throws AuthException {

final String header = request.getHeader("Authorization");
final String[] credentials = parseCredentials(header);
final String username = credentials[0];
final String password = credentials[1];
if (!"snoopy".equals(username) || !"woodst0ck".equals(password)) {
return FAILURE;
} // No callbacks required!!!
return httpMessageContext.notifyContainerAboutLogin(
"snoopy",
// the groups/roles of the authenticated user
Arrays.asList("RedBaron", "JoeCool", "MansBestFriend"));
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

36

Ideas Standardized AuthenFcators


OpenID Connect ServerAuthModule
@Authenticator("javax.security.authenticator.OpenIDConnect")
@WebServlet("/SimpleServlet")
@ServletSecurity(@HttpConstraint(rolesAllowed = {"manager"}))
public class SimpleServlet extends HttpServlet {

@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.getWriter().print("my GET");
}
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

37

Ideas AuthenFcaFon Events


Throw standardized CDI events at important moments
PreAuthenFcate Event
PostAuthenFcate Event
PreLogout Event
PostLogout Event

Possible uses:
Tracking number of logged-in users
Tracking failed login aQempts per account
Side eects, like creaFng a new local user arer iniFal successful authenFcaFon via a
remote authenFcaFon provider
Loading applicaFon-specic user preferences
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

38

Ideas
To modernize, standardize, simplify

Terminology
API for AuthenFcaFon Mechanism
API for IdenFty Store
API for Password Aliasing
API for Role/Permission Assignment
API for Security Context
API for AuthorizaFon Interceptors

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

39

Use Case
API for Iden7ty Store

ApplicaFon manages its own users and groups


Need to access a repository of idenFFes, like users
Users may be stored in app-specied repository (e.g. LDAP)
Users are managed without access to server conguraFon

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

40

Survey Results

'

Should we simplify authorization by introducing an EL-enabled authorization


annotation?

API for Iden7ty Store

'

Should we standardize on requirements for simple security providers and their


configuration?

'
'
Approximately'58%'thought'we'should'add'support'for'password'aliases,'including'the'
ability'to'provision'credentials'along'with'the'application.'
'
70%'thought'that'we'should'standardize'group`to`role'mapping.'
'
53%'thought'we'should'simplify'JASPIC'authentication.'
'
67%'thought'that'we'should'simplify'authorization'and'make'it'more'flexible'by'
introducing'EL`based'authorization'annotations,'introducing'a'capability'more'general'
than'use'of'@RolesAllowed'and'simpler'than'use'of'interceptors'to'do'programmatic'
authorization.'
'
Copyright 2015, Oracle and/or its aliates. All rights reserved. |
65%'thought'we'should'standardize'on'requirements'for'simple'security'providers'and'

41

Current SoluFons
API for Iden7ty Store

No Java EE support
Only proprietary server support
3rd party security frameworks provide user/group APIs

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

42

Ideas IdenFty Store

Caller
CredenFals

IdenFtyStore

DB

File

Caller Name,
Groups

LDAP

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

43

Ideas IdenFty Store InteracFon


CredenFal

1) validate

IdenFtyStore

2) returns

CredenFalValidaFonResult
+ getStatus():Status
+ getCallerName():String
+ getCallerGroups():List<String>

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

44

Ideas IdenFty Store


@Inject
IdentityStore store;

CallerNamePasswordCredentials creds;
creds = new CallerNamePasswordCredentials("scott","password".toCharArray())

CredentialValidationResult result = store.validate(creds);

if (VALID.equals(result.getStatus()) {
// successful validation
String callerName = result.getCallerName();
List<String> groups = result.getCallerGroups();

// TODO: Apply to container using JASPIC callback handler
} else {
// invalid credential
}


Copyright 2015, Oracle and/or its aliates. All rights reserved. |

45

Ideas IdenFty Store CredenFals


CredenFal
+ clear():void
+ getCallerName():String
+ isCleared():boolean
+ isValid():boolean

extends
CallerNamePasswordCredenFal
+ getPassword():Password

TokenCredenFal
+ getToken():String

BasicAuthenFcaFonCredenFal
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

46

Ideas IdenFty Store Standard ImplementaFons


IdenFtyStore
+ validate(CredenFal):CredenFalValidaFonResult

Standard IdenFtyStore
implementaFons are annotated as
CDI AlternaFves.

implements

JsonFileIdenFtyStore

LdapIdenFtyStore

DatabaseIdenFtyStore

JaasIdenFtyStore

EmbeddedIdenFtyStore

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

47

Ideas IdenFty Store


@LdapIdentityStoreDefinition(
url="ldap://localhost:10389",
searchDn="uid=jsr375,dc=simple,dc=jsr375,dc=org"
searchCredential="secret"
)
public class SomeClass{}


@JsonIdentityStoreDefinition(
filePath="/idstore.json")
public class SomeClass{}



Copyright 2015, Oracle and/or its aliates. All rights reserved. |

48

Ideas IdenFty Store


@EmbeddedIdentityStoreDefinition({
@Credentials(callerName = "reza", password = "secret1", groups = { "foo", "bar" }),
@Credentials(callerName = "alex", password = "secret2", groups = { "foo", "kaz" }),
@Credentials(callerName = "arjan", password = "secret3", groups = { "foo" }) })
public class SomeClass{}


@DataBaseIdentityStoreDefinition(
dataSourceLookup="java:/app/myDS",
callerQuery="select password from caller where name = ?",
groupsQuery="select group from caller_groups where caller_name = ?",
hashAlgorithm="SHA-256",
hashEncoding="base64"
)
public class SomeClass{}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

49

Ideas IdenFty Store Standard ImplementaFons


JAAS
3) login
4) commit
7) logout

LoginModule

LoginContext

2) login

LoginModule
1) validate

JaasIdenFtyStore

6) logout

5) get caller, groups, roles from Subject

JaasSubjectPrincipalResolver

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

50

Ideas IdenFty Store OpFonal Interfaces


OpFonal Query Interfaces
IdenFtyStore

CallerStore

CallerRoleMap

GroupRoleMap

GroupStore

RoleStore

implements
IdenFtyStore ImplementaFon

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

51

Ideas IdenFty Store OpFonal Interfaces


@Inject
IdentityStore idStore;

List<String> callers = idStore.getCallers("smith");
List<String> groups = idStore.getGroups("*");
boolean inGroup = idStore.isCallerInGroup ("jsmith", "Manager");

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

52

Ideas
To modernize, standardize, simplify

Terminology
API for AuthenFcaFon Mechanism
API for IdenFty Store
API for Password Aliasing
API for Role/Permission Assignment
API for Security Context
API for AuthorizaFon Interceptors

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

53

Use Case
API for Password Aliasing

ApplicaFon uses passwords to access resources like LDAP and DB


Passwords stored in annotaFons, deployment descriptors
Best pracFces dictate that passwords are never stored in clear text
Need a portable way to protect stored passwords

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

54

Survey Results

names'of'loggers'used'by'the'application'server,'the'format'of'log'files,'and'the'access'to'
log'messages'by'applications.'
'
Of'the'small'fraction'of'participants'who'added'comments,'most'of'these'strongly'urged'
for'improvements'in'logging''either'by'the'revision'of'java.util.logging,'or'replacement'
of'its'use'by'either'slf4j,''slf4j'with'LogBack,'or'log4j.'
'
'
'

Security'
API for Password Aliasing
'

Most'of'the'suggested'improvements'in'the'security'area'received'strong'support.'
'

Should we add support for password aliases (including the ability to provision
credentials along with the application)?

'

Should we standardize group-to-role mapping?

Deferred from Java EE 7


Copyright 2015, Oracle and/or its aliates. All rights reserved. |

55

Current SoluFons
API for Password Aliasing

No Java EE support
Proprietary server support, e.g. GlassFish
3rd party security framework support for embedded password encrypFon,
not aliasing

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

56

Ideas Password Aliasing


For annotaFons
@DataSourceDefinition(
name="java:app/jdbc/test",
user="root",
password="${ALIAS=password}",)

For deployment descriptors


<data-source>
<name>java:app/env/testDS</name>
<user>APP</user>
<password>${ALIAS=password}</password>

</data-source>

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

57

Ideas Password Aliasing


Resolved
when used
${ALIAS=token}

Cleared
when done
"mysecret"

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

58

Ideas Password Aliasing

Password Alias
Archive

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

59

Ideas Password Aliasing


For conguraFon: AnnotaFons, Deployment Descriptors
Secure credenFals archive for bundling the alias and actual password
values with applicaFons
Plaporm consumes the credenFals archive upon deployment
Standard tooling for CRUD operaFons on the credenFal archive, e.g.
keytool

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

60

Ideas
To modernize, standardize, simplify

Terminology
API for AuthenFcaFon Mechanism
API for IdenFty Store
API for Password Aliasing
API for Role/Permission Assignment
API for Security Context
API for AuthorizaFon Interceptors

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

61

Use Case
API for Role/Permission Assignment

ApplicaFon manages its own users and groups


ApplicaFon needs to assign roles (i.e., authoriFes, permissions) to users
and groups, based on applicaFon-specic model
Users may be stored in app-specied repository (e.g. LDAP)
Users are managed without access to server conguraFon

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

62

'
'

Security'

Survey Results

'
Most'of'the'suggested'improvements'in'the'security'area'received'strong'support.'
'

Should we add support for password aliases (including the ability to provision
credentials along with the application)?

API for Role/Permission Assignment

'

Should we standardize group-to-role mapping?

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

63

Current SoluFons
API for Role/Permission Assignment

No Java EE support
Only proprietary server support
3rd party security frameworks provide role/authority/permission APIs

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

64

Ideas Standardized Role Mapping


Support in Deployment Descriptors, e.g. web.xml
<security-role-map>
<!-- Role name as set/returned by Authentication Module -->
<group>MANAGER</group>

<!-- Role name for mapping -->
<role-name>EDIT_ACCOUNTS</role-name>
</security-role-map>

<! One-to-one group to role mapping -->
<security-role-map groupToRoleMapping="false" />

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

65

Ideas Role Mapping AnnotaFon


@EmbeddedIdentityStoreDefinition({
@Credentials(callerName = "reza", password = "secret1", groups = { "foo", "bar" }),
@Credentials(callerName = "alex", password = "secret2", groups = { "foo", "kaz" }),
@Credentials(callerName = "arjan", password = "secret3", groups = { "foo" }) })
public class MyServlet {
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

66

Ideas Dynamic ApplicaFon-based Roles


2) Caller login
6) Return caller, groups

JASPIC
3) Validate creds

5) Return caller,
groups (i.e. roles)

1) App updates
caller roles

DB

4) Query
for caller

IdenFtyStore

Assuming 1:1 Group-Role Mapping


Copyright 2015, Oracle and/or its aliates. All rights reserved. |

67

Ideas
To modernize, standardize, simplify

Terminology
API for AuthenFcaFon Mechanism
API for IdenFty Store
API for Password Aliasing
API for Role/Permission Assignment
API for Security Context
API for AuthorizaFon Interceptors

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

68

Use Case
API for Security Context

ApplicaFon needs to access the security API


To get the authenFcated user
To check roles
To invoke runAs.
ApplicaFon needs the same API to access security context, regardless of
container

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

69

Current SoluFons
API for Security Context

No Java EE support
3rd party security frameworks provide a security context

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

70

Current SoluFons
@Singleton
public class MyEjb {
@Resource
private SessionContext sessionContext;

public String sayHello() {
if (sessionContext.isCallerInRole("admin")) {
return "Hello World!";
}
throw new SecurityException("User is unauthorized.");
}
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

71

Current SoluFons
public class MyServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse resp) throws ServletException, IOException {

if (request.isUserInRole("admin")) {
// do something
}
throw new ServletException("User is unauthorized.");
}
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

72

Current SoluFons
@RequestScoped
public class MyCdiBean {

// Oh snap! No SecurityContext class for CDI
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

73

Current SoluFons
public class MyJaxRsService {
@GET
@Produces("text/plain;charset=UTF-8")
@Path("/hello")
public String sayHello(@Context SecurityContext sc) {

if (sc.isUserInRole("admin")) {
return "Hello World!";
}
throw new SecurityException("User is unauthorized.");
}
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

74

Ideas Security Context


public interface SecurityContext {
String getUserPrincipal();
boolean isUserInRole(String role);
List<String> getAllUsersRoles();
boolean isAuthenticated();
boolean isUserInAnyRole(List<String> roles);
boolean isUserInAllRoles(List<String> roles);
void login(Object request, Object response);
void login(Map map);
void logout();
void runAs(String role);
boolean hasAccessToResource();
boolean hasAccessToBeanMethod();
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

75

Ideas Security Context


For all managed beans: CDI, Servlet, EJB, JAX-RS, etc
public class MyFutureCdiBean {
@Inject
private SecurityContext securityContext;
public String sayHello() {
if (securityContext.isUserInRole("admin")) {
return "Hello World!";
}
throw new SecurityException("User is unauthorized.");
}
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

76

Ideas
To modernize, standardize, simplify

Terminology
API for AuthenFcaFon Mechanism
API for IdenFty Store
API for Password Aliasing
API for Role/Permission Assignment
API for Security Context
API for AuthorizaFon Interceptors

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

77

Use Case
API for Authoriza7on Interceptors

ApplicaFon needs to restrict specic methods to authorized users


ApplicaFon-model rules are used to make access decisions
Role is insucient

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

78

Survey Results

'
Only'a'small'fraction'of'respondents'answered'the'open`ended'"If'so,'which?"'part'of'
this'last'question.''Thymeleaf,'Freemarker,'and'Velocity'were'the'most'frequently'
mentioned'here.'
'
'
'
'

CDI'

API for Authoriza7on Interceptors


'

The'next'four'questions'focused'on'continued'CDI'alignment.''This'was'one'of'the'focus'
areas'of'Java'EE'7.'
'

Should we consider adding Security Interceptors in Java EE 8?


Should we simplify JASPIC?

'

Should we simplify authorization by introducing an EL-enabled authorization


annotation?

'

Should we standardize on requirements for simple security providers and their


configuration?
Copyright 2015, Oracle and/or its aliates. All rights reserved. |

79

Current SoluFons
API for Authoriza7on Interceptors

EE authorizaFon has no rule based authorizaFon, only role based


3rd party security frameworks provide rule, role and permission based APIs

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

80

Ideas EL AuthorizaFon Rules


Expression Language rule would have access to managed beans for
SecurityContext and InvocaFonContext

@EvaluateSecured("security.hasRoles('MANAGER') && schedule.nowIsOfficeHrs")
void transferFunds() {..};

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

81

Ideas EL AuthorizaFon Rules


EL AuthorizaFon rules centrally managed in a repository
@LdapAuthorizationRules (
name="java:app/accountAuthRules",
ldapUrl="ldap://blah",
ldapUser="ElDap",
ldapPassword=mysecret)
public class MyBean {
@EvaluateSecured(ruleSourceName="java:app/accountAuthRules", rule="transferFunds")
void transferFunds() {..};

}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

82

Ideas AccessDecisionVoter
A user-dened class for making access decisions

@Secured(AccountAccessDecisionVoter.class)
void transferFunds() {..};

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

83

Ideas AccessDecisionVoter
public class AccountAccessDecisionVoter implements AccessDecisionVoter {

@Override
public SecurityViolation checkPermission(AccessDecisionVoterContext ctx) {

// Check for violations
Method method = ctx.<InvocationContext>getSource().getMethod();


return new SecurityViolation("Sorry, not allowed");
}
}

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

84

Program Agenda
1

MoFvaFons

A New JSR

Ideas

Get Involved

Q & A

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

85

Get Involved
Contribute to the JSR!

Project Page: The starFng point to all resources


hQps://java.net/projects/javaee-security-spec
Users List: Subscribe and contribute
users@javaee-security-spec.java.net
Github Playground: Fork and Play!
hQps://github.com/javaee-security-spec/javaee-security-proposals

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

86

Get Involved
ARend related sessions!

How Would You Improve the Java EE Security API? [BOF3666]


Tonight at 8 PM | HiltonPlaza Room A
Hosted by Ivar Grimstad and Alex Kosowski

The Java EE 8 Opportunity [CON6086]


Presented by David Blevins, Tomitribe
Wednesday, Oct 28, 4:30 PM | Parc 55Cyril Magnin II/III

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

87

Program Agenda
1

MoFvaFons

A New JSR

Ideas

Get Involved

Q & A

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

88

Q & A
JSR 375 EE Security API

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

89

Safe Harbor Statement


The preceding is intended to outline our general product direcFon. It is intended for
informaFon purposes only, and may not be incorporated into any contract. It is not a
commitment to deliver any material, code, or funcFonality, and should not be relied upon
in making purchasing decisions. The development, release, and Fming of any features or
funcFonality described for Oracles products remains at the sole discreFon of Oracle.

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

90

Copyright 2015, Oracle and/or its aliates. All rights reserved. |

91

Das könnte Ihnen auch gefallen