10.12.2012 Views

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

The Java EE 5 Tutorial (PDF) - Oracle Software Downloads

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

[exec] Bel Canto<br />

[exec] Kafka on the Shore<br />

[exec] Caught a BookException: "Gravity’s Rainbow" not in cart.<br />

If the username and password are not authenticated, the client displays the following error:<br />

run:<br />

[echo] Running appclient for Cart.<br />

appclient-command-common:<br />

[exec] Caught an unexpected exception!<br />

[exec] javax.ejb.EJBException: nested exception is: java.rmi.AccessException:<br />

CORBA NO_PERMISSION 9998 Maybe; nested exception is:<br />

[exec] org.omg.CORBA.NO_PERMISSION:<br />

----------BEGIN server-side stack trace----------<br />

[exec] org.omg.CORBA.NO_PERMISSION: vmcid: 0x2000 minor code: 1806<br />

If you see this response, verify the user name and password of the user that you entered in the<br />

login dialog, make sure that user is assigned to the group user, and rerun the client application.<br />

Example: Using the isCallerInRole and<br />

getCallerPrincipal Methods<br />

Enterprise Bean Example Applications<br />

This example demonstrates how to use the getCallerPrincipal() and<br />

isCallerInRole(String role) methods with an enterprise bean. This example starts with a<br />

very simple EJB application, converter, and modifies the methods of the ConverterBean so<br />

that currency conversion will only occur when the requester is in the role of BeanUser.<br />

For this tutorial, you will add the security elements to an enterprise bean; add the security<br />

elements to the deployment descriptor; build, package, and deploy the application; and then<br />

build and run the client application. <strong>The</strong> completed version of this example can be found at<br />

tut-install/javaeetutorial5/examples/ejb/converter-secure. This example was developed<br />

by starting with the unsecured enterprise bean application, converter, which is discussed in<br />

Chapter 21, “Getting Started with Enterprise Beans,” and is found in the directory<br />

tut-install/javaeetutorial5/examples/ejb/converter/. This section builds on this example<br />

by adding the necessary elements to secure the application using the getCallerPrincipal()<br />

and isCallerInRole(String role) methods, which are discussed in more detail in “Accessing<br />

an Enterprise Bean Caller’s Security Context” on page 797.<br />

Chapter 29 • Securing <strong>Java</strong> <strong>EE</strong> Applications 823

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

Saved successfully!

Ooh no, something went wrong!