O'Reilly logo

Enterprise JavaBeans 3.1, 6th Edition by Bill Burke, Andrew Lee Rubinger

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix B. Stateless Session EJB: Encryption Example

Description

The stateless session bean is a fantastic implementation choice for business processes which require no server-side state to be retained in between client invocations. If all information needed to process a request can be found in the request itself, the SLSB may be used as a highly efficient endpoint. In this example we build an encryption service capable of performing both one-way hashing and encryption/decryption operations.

Additionally, we show here that SLSBs may indeed have their own internal state, so long as that it’s not leaked out to the client during requests. Finally, we introduce the use of XML via environment entries to externalize configurable elements of the service.

Source Listing

Following is a full listing of all source code used in this runnable example.

Implementation Resources

EncryptionBean.java

package org.jboss.ejb3.examples.ch05.encryption; import java.io.UnsupportedEncodingException; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.spec.AlgorithmParameterSpec; import java.security.spec.KeySpec; import javax.annotation.PostConstruct; import javax.annotation.Resource; import javax.crypto.Cipher; import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required