14.01.2013 Views

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

Oracle JHeadstart Developer's Guide - Downloads - Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

10.1. Understanding and Choosing Security Options with <strong>JHeadstart</strong><br />

10.1.1. JAAS and JAZN<br />

Generally speaking, there are two popular ways to implement authentication (“who is<br />

the current user”) and authorization (“is the current user allowed to do this”) in Java EE<br />

web applications:<br />

• Container-managed security using JAAS (Java Authentication and Authorization<br />

Service)<br />

• Custom security<br />

<strong>JHeadstart</strong> supports both types of security, and even allows you to combine both<br />

approaches by using custom roles and/or permissions in addition to JAAS-based<br />

security. This paragraph discusses the security options in more detail, which should<br />

help you in configuring the <strong>JHeadstart</strong> security settings in your Application Definition<br />

(at Service level).<br />

Within the JEE platform, Java Authentication and Authorization Services (JAAS) is the<br />

standard for implementing security. By using JAAS the web container used to run the<br />

web application enforces proper authentication and authorization (“container-managed<br />

security”). Each web container provides its own implementation of the JAAS standard.<br />

JAAS allows web developers to develop the security in their application independent of<br />

the chosen JAAS implementation, by using a simple API that can be invoked to answer<br />

security related questions such as “who is the currently logged in user” and “does this<br />

user belong to a specific ‘role’”.<br />

To get the name of the currently logged in user in a JSF application, the following<br />

statement can be used:<br />

FacesContext.getInstance().getExternalContext().getUserPrincipal().getName()<br />

To determine whether a user is in a specific role, the following boolean statement can be<br />

used:<br />

FacesContext.getInstance().getExternalContext().isUserInRole("roleName");<br />

10 - 2 Application Security <strong>JHeadstart</strong> Developer’s <strong>Guide</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!