java applet qr code | Appendix B: Stateless Session EJB: Encryption Example in Java

Make QR Code in Java | Appendix B: Stateless Session EJB: Encryption Example

436 | Appendix B: Stateless Session EJB: Encryption Example
Create QR Code ISO/IEC18004 In Java
Using Barcode encoder for Java Control to generate, create QR Code image in Java applications.
www.OnBarcode.com
Decode QR In Java
Using Barcode reader for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
public String getCiphersPassphrase() { // Obtain current String passphrase = this.ciphersPassphrase; // If not set if (passphrase == null) { // Do a lookup via SessionContext passphrase = this.getEnvironmentEntryAsString(ENV_ENTRY_NAME_CIPHERS_ PASSPHRASE); // See if provided if (passphrase == null) { // Log a warning log.warn("No encryption passphrase has been supplied explicitly via " + "an env-entry, falling back on the default..."); // Set passphrase = DEFAULT_PASSPHRASE;
UCC - 12 Drawer In Java
Using Barcode encoder for Java Control to generate, create UCC - 12 image in Java applications.
www.OnBarcode.com
QR Code Maker In Java
Using Barcode generator for Java Control to generate, create QR Code JIS X 0510 image in Java applications.
www.OnBarcode.com
} again }
ECC200 Generator In Java
Using Barcode printer for Java Control to generate, create Data Matrix ECC200 image in Java applications.
www.OnBarcode.com
Creating Barcode In Java
Using Barcode maker for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
// Set the passphrase to be used so we don't have to do this lazy init this.ciphersPassphrase = passphrase;
Generate ANSI/AIM Code 39 In Java
Using Barcode creator for Java Control to generate, create ANSI/AIM Code 39 image in Java applications.
www.OnBarcode.com
Bookland EAN Generator In Java
Using Barcode creation for Java Control to generate, create ISBN - 10 image in Java applications.
www.OnBarcode.com
// In a secure system, we don't log this. ;) log.info("Using encryption passphrase for ciphers keys: " + passphrase); // Return return passphrase;
Print QR Code 2d Barcode In Objective-C
Using Barcode generator for iPad Control to generate, create Quick Response Code image in iPad applications.
www.OnBarcode.com
QR Code 2d Barcode Generation In None
Using Barcode printer for Microsoft Word Control to generate, create QR Code image in Office Word applications.
www.OnBarcode.com
}
Matrix 2D Barcode Creator In Visual Basic .NET
Using Barcode creation for .NET Control to generate, create Matrix 2D Barcode image in .NET framework applications.
www.OnBarcode.com
Code39 Drawer In Objective-C
Using Barcode encoder for iPhone Control to generate, create Code-39 image in iPhone applications.
www.OnBarcode.com
/** * Obtains the message digest algorithm as injected from the env-entry element * defined in ejb-jar.xml. If not specified, fall back onto the default, logging a warn * message * * @see org.jboss.ejb3.examples.ch05.encryption.EncryptionRemoteBusiness#get MessageDigestAlgorithm() */ @Override public String getMessageDigestAlgorithm() { // First see if this has been injected/set if (this.messageDigestAlgorithm == null) { // Log a warning log.warn("No message digest algorithm has been supplied explicitly via " + "an env-entry, falling back on the default...");
Generate USS-128 In VS .NET
Using Barcode creation for Reporting Service Control to generate, create GS1 128 image in Reporting Service applications.
www.OnBarcode.com
Barcode Encoder In None
Using Barcode maker for Office Excel Control to generate, create Barcode image in Microsoft Excel applications.
www.OnBarcode.com
}
Print European Article Number 13 In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create EAN13 image in ASP.NET applications.
www.OnBarcode.com
Paint Barcode In .NET
Using Barcode generation for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
// Set this.messageDigestAlgorithm = DEFAULT_ALGORITHM_MESSAGE_DIGEST;
Create Matrix Barcode In C#.NET
Using Barcode generation for Visual Studio .NET Control to generate, create Matrix Barcode image in VS .NET applications.
www.OnBarcode.com
Barcode Generation In None
Using Barcode encoder for Word Control to generate, create Barcode image in Microsoft Word applications.
www.OnBarcode.com
// Log log.info("Configured MessageDigest one-way hash algorithm is: " + this. messageDigestAlgorithm); // Return return this.messageDigestAlgorithm;
Linear Barcode Printer In .NET Framework
Using Barcode drawer for VS .NET Control to generate, create Linear Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
Make USS Code 128 In None
Using Barcode generation for Software Control to generate, create ANSI/AIM Code 128 image in Software applications.
www.OnBarcode.com
}
// ---------------------------------------------------------------------------|| // Internal Helper Methods ---------------------------------------------------|| // ---------------------------------------------------------------------------|| /** * Obtains the environment entry with the specified name, casting to a String, * and returning the result. If the entry is not assignable * to a String, an {@link IllegalStateException} will be raised. In the event that the * specified environment entry cannot be found, a warning message will be logged * and we'll return null. * * @param envEntryName * @return * @throws IllegalStateException */ private String getEnvironmentEntryAsString(final String envEntryName) throws IllegalStateException { // See if we have a SessionContext final SessionContext context = this.context; if (context == null) { log.warn("No SessionContext, bypassing request to obtain environment entry: " + envEntryName); return null; } // Lookup in the Private JNDI ENC via the injected SessionContext Object lookupValue = null; try { lookupValue = context.lookup(envEntryName); log.debug("Obtained environment entry \"" + envEntryName + "\": " + look upValue); } catch (final IllegalArgumentException iae) { // Not found defined within this EJB's Component Environment, // so return null and let the caller handle it log.warn("Could not find environment entry with name: " + envEntryName); return null;
438 | Appendix B: Stateless Session EJB: Encryption Example
} // Cast String returnValue = null; try { returnValue = String.class.cast(lookupValue); } catch (final ClassCastException cce) { throw new IllegalStateException("The specified environment entry, " + lookupValue + ", was not able to be represented as a " + String.class.getName(), cce); } // Return return returnValue;
}
/** * Returns a String representation of the specified byte array * using the charset from {@link EncryptionBeanBase#getCharset()}. Wraps * any {@link UnsupportedEncodingException} as a result of using an invalid * charset in a {@link RuntimeException}. * * @param bytes * @return * @throws RuntimeException If the charset was invalid, or some other unknown error occurred * @throws IllegalArgumentException If the byte array was not specified */ private String byteArrayToString(final byte[] bytes) throws RuntimeException, IllegalArgumentException { // Precondition check if (bytes == null) { throw new IllegalArgumentException("Byte array is required."); } // Represent as a String String result = null; final String charset = this.getCharset(); try { result = new String(bytes, charset); } catch (final UnsupportedEncodingException e) { throw new RuntimeException("Specified charset is invalid: " + charset, e); } // Return return result;
} /** * Returns a byte array representation of the specified String * using the charset from {@link EncryptionBeanBase#getCharset()}. Wraps * any {@link UnsupportedEncodingException} as a result of using an invalid * charset in a {@link RuntimeException}. * * @param input * @return * @throws RuntimeException If the charset was invalid, or some other unknown error occurred * @throws IllegalArgumentException If the input was not specified (null) */ private byte[] stringToByteArray(final String input) throws RuntimeException, IllegalArgumentException { // Precondition check if (input == null) { throw new IllegalArgumentException("Input is required."); } // Represent as a String byte[] result = null; final String charset = this.getCharset(); try { result = input.getBytes(charset); } catch (final UnsupportedEncodingException e) { throw new RuntimeException("Specified charset is invalid: " + charset, e); } // Return return result;
}
/** * Obtains the charset used in encoding/decoding Strings * to/from byte representation * * @return The charset */ private String getCharset() { return CHARSET; } }
Copyright © OnBarcode.com . All rights reserved.