/** * Protected constructor for factory-based construction * * @param n * the Namespace this identity will belong to * @param provider * the name of the algorithm to use. See {@link SecureRandom} * @param byteLength * the length of the target number (in bytes) */ protected GUID(Namespace n, String algo, String provider, int byteLength) throws IDCreateException { super(n, ""); //$NON-NLS-1$ // Get SecureRandom instance for class try { getRandom(algo, provider); } catch (Exception e) { throw new IDCreateException( "GUID creation failure: " + e.getMessage()); //$NON-NLS-1$ } // make sure we have reasonable byteLength if (byteLength <= 0) byteLength = 1; byte[] newBytes = new byte[byteLength]; // Fill up random bytes random.nextBytes(newBytes); // Set value value = Base64.encode(newBytes); }
/** * Protected constructor for factory-based construction * * @param n * the Namespace this identity will belong to * @param provider * the name of the algorithm to use. See {@link SecureRandom} * @param byteLength * the length of the target number (in bytes) */ protected GUID(Namespace n, String algo, String provider, int byteLength) throws IDCreateException { super(n, ""); //$NON-NLS-1$ // Get SecureRandom instance for class try { getRandom(algo, provider); } catch (Exception e) { throw new IDCreateException( "GUID creation failure: " + e.getMessage()); //$NON-NLS-1$ } // make sure we have reasonable byteLength if (byteLength <= 0) byteLength = 1; byte[] newBytes = new byte[byteLength]; // Fill up random bytes random.nextBytes(newBytes); // Set value value = Base64.encode(newBytes); }