/*******************************************************************************
 * Copyright (c) 2011, 2016 Eurotech and/or its affiliates
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *      Eurotech - initial APInd implementation
 *******************************************************************************/
package org.eclipse.kapua.commons.model.id;

import java.math.BigInteger;
import java.security.SecureRandom;

import org.eclipse.kapua.commons.setting.system.SystemSetting;
import org.eclipse.kapua.commons.setting.system.SystemSettingKey;

/**
 * Generates random identifier
 *
 * @since 1.0
 * 
 */
public class IdGenerator
{
    private final static SecureRandom secureRandom = new SecureRandom();
    private static int                ID_SIZE      = SystemSetting.getInstance().getInt(SystemSettingKey.KAPUA_KEY_SIZE);

    /**
     * Generate a {@link BigInteger} random value.<br>
     * For more detail refer to: {@link SystemSettingKey#KAPUA_KEY_SIZE}
     * 
     * @return
     */
    public static BigInteger generate()
    {
        byte[] bytes = new byte[ID_SIZE];
        secureRandom.nextBytes(bytes);
        return new BigInteger(bytes);
    }

}

@@ -826,18 +826,17 @@
 e 1.0%0A *
- 
 %0A
+
  */%0Apubl
@@ -859,10 +859,11 @@
 ator
+ %7B
 %0A
-%7B
 %0A   
@@ -944,16 +944,22 @@
 private 
+final 
 static i
@@ -965,31 +965,16 @@
 int 
-               
 ID_SIZE 
     
@@ -969,21 +969,16 @@
 ID_SIZE 
-     
 = System
@@ -1183,17 +1183,16 @@
 %7D%0A     *
- 
 %0A     * 
@@ -1207,16 +1207,16 @@
      */%0A
+
     publ
@@ -1246,20 +1246,16 @@
 nerate()
-%0A   
  %7B%0A     

Apply code formatter and code style