Today's Question:  What does your personal desk look like?        GIVE A SHOUT

 JAVA


  Permutation implementation in Java

Permutation is a very basic and important mathematic concept we learned in school. It has very practical applications in real world. For example, in football.In simple, permutation describes all possible ways of doing something. For example, there are six permutations of the set {1,2,3}, namely: (1,2,3), (1,3,2), (2,1,3), (2,3,1), (3,1,2), and (3,2,1). In general, for n items, there are n! number of permutations to arrange these items. How can we implement this algorithm in programming programming language such as Java? Below is a simple code snippet which uses the recursive method. It's quite...

7,689 4       JAVA PERMUTATION IMPLEMENTATION SAMPLE


  How does JGSS read Windows native TGT credential?

MS LSA is a protected subsystem that authenticates and logs users onto the local system. The user credential is stored at the native credential cache of LSA on Windows. This kind of credential is often used to authenticate the user to the server, one of the authentication methods is Kerberos. JGSS has provided a native interface which can read the native TGT credential and use it to get the TGS of a service. But how does JGSS read the native TGT credential?Here is a sample code for reading native credential using JGSS:import sun.security.krb5.Credentials;import sun.security.krb5.internal.Ticke...

7,702 0       KERBEROS JGSS MS LSA NATIVE CREDENTIAL TGT SESSION KEY TYPE


  Different types of keystore in Java -- DKS

Domain KeyStore(DKS) is a keystore of keystore. It abstracts a collection of keystores that are presented as a single logical keystore. Itself is actually not a keystore. This new keystore type is introduced in Java 8. There is a new class DomainLoadStoreParameter which closely relates to DKS.To load different keystores into the single logical keystore, some configuration is needed. Here is the format of the configuration for grouping different keystores.domain [ ...] { keystore [ ...] ; ...};Below is one sample configuration for domain domain.domain app1 { keystore app1-...

12,768 0       JAVA TUTORIAL KEYSTORE DKS


  Memory related exception analysis in Java

Java Virtual Machine Specification divides the memory of JVM into several areas : Heap, Stack, The Program Counter register and Method area etc. In HotSpot JVM, heap is composed of Young, Tenured and Perm. There are different OutOfMemory error can happen in different memory area. Next is an overview of some of these OOM errors.StackOverflowErrorThe JVM will allow only a specified number of stacks created nested. An JVM option -Xss can be set to determine the maximum stack size. If the number of stacks created is more than the maximum allowed, a java.lang.StackOverflowError will be thrown....

3,999 0       JAVA MEMORY MODEL MEMORY EXCEPTION OOM


  Different types of keystore in Java -- PKCS11

PKCS11 keystore is designed for hardware storage modules(HSM). It's an interface to talk to the HSMs. It doesn't actually store any keys but provide a set of classes to communicate with the underlying HSM. The actual keys and certificates are stored on the HSMs.The reason for storing the keys and materials is to ensure security and efficiency. Since the keys are on the HSMs, they are safe to be stolen. All encryption/decryption operations are performed on the HSMs as well, this increase the processing speed. They are frequently used in applications requiring high speed and extra sec...

23,961 2       JAVA KEYSTORE PKCS11 HSM


  What does super.clone() do?

Object class has a protected clone() method declared to make it possible for all classes make a clone of itself when needed. The clone() is often used when a new instance of the class is needed while at the same time to maintain the same state as the original object. Any class which wants to have clone enabled has to implement the marker interface Cloneable.If a class which implements Cloneable doesn't override the Object.clone() method, the Object.clone() method will be called to just make a binary copy of the original, which amounts to a shallow clone, with all the referenced objects staying...

28,451 0       JAVA CLONEABLE SUPER.CLONE() CLONE


  Different types of keystore in Java -- JCEKS

JCEKS stands for Java Cryptography Extension KeyStore and it is an alternative keystore format for the Java platform. Storing keys in a KeyStore can be a measure to prevent your encryption keys from being exposed. Java KeyStores securely contain individual certificates and keys that can be referenced by an alias for use in a Java program.The process of storing and loading different entries in JCEKS is similar to what JKS does. So please refer to the article Different types of keystore in Java -- JKS. Change the keystore type from JKS to JCEKS accordingly when calling KeyStore.getInstance().In ...

52,965 1       JAVA TUTORIAL KEYSTORE JCEKS


  Different types of keystore in Java -- PKCS12

PKCS12 is an active file format for storing cryptography objects as a single file. It can be used to store secret key, private key and certificate.It is a standardized format published by RSA Laboratories which means it can be used not only in Java but also in other libraries in C, C++ or C# etc. This file format is frequently used to import and export entries from or to other keystore types.Next we will explain the operations which can be performed on PKCS12 keystore.Create PKCS12 keystoreBefore storing an entry into a PKCS12 keystore, the keystore has to be loaded first. This means we have t...

77,414 10       JAVA PKCS12 KEYSTORE TUTORIAL