Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过oracle数据库中加载的java类获取主板序列号_Java_Oracle - Fatal编程技术网

通过oracle数据库中加载的java类获取主板序列号

通过oracle数据库中加载的java类获取主板序列号,java,oracle,Java,Oracle,您好,我试图通过Java类获得主板序列号,该类工作正常,但如果我在oracle db中加载同一个类,谁也帮不了我 /*这是我的密码*/ 公共类GetUID4Nubo{ public GetUID4Nubo() { getid(); } public static void main(String[] args) { new GetUID4Nubo(); } public static String getid(){ String result = ""; tr

您好,我试图通过Java类获得主板序列号,该类工作正常,但如果我在oracle db中加载同一个类,谁也帮不了我

/*这是我的密码*/

公共类GetUID4Nubo{

public GetUID4Nubo() {
    getid();
}

public static void main(String[] args) {
    new GetUID4Nubo();
}

public static String getid(){
    String result = "";
    try{
        //result = getMACID() + "@###@" + getSerialNumber("C") + "@###@" + getMotherboardSN();
        result = getSerialNumber("C") + "@###@" + getMotherboardSN();
        System.out.println(result);
        result = encrypt("nubo123", result);
        System.out.println(result);
    }catch(Exception e){
        e.printStackTrace();
    }
    return result;
}

public static String getone(){
    return "one";
}


    // 8-byte Salt
    static byte[] salt = { (byte) 0xA9, (byte) 0x9B, (byte) 0xC8, (byte) 0x32,
            (byte) 0x56, (byte) 0x35, (byte) 0xE3, (byte) 0x03 };
    // Iteration count
    static int iterationCount = 19;
    static Cipher ecipher;

public static String encrypt(String secretKey, String plainText)
        throws NoSuchAlgorithmException, InvalidKeySpecException,
        NoSuchPaddingException, InvalidKeyException,
        InvalidAlgorithmParameterException, UnsupportedEncodingException,
        IllegalBlockSizeException, BadPaddingException {
    // Key generation for enc and desc
    KeySpec keySpec = new PBEKeySpec(secretKey.toCharArray(), salt, iterationCount);
    SecretKey key = SecretKeyFactory.getInstance("PBEWithMD5AndDES")
            .generateSecret(keySpec);
    ///System.out.println("this is key : " + key);
    // Prepare the parameter to the ciphers
    AlgorithmParameterSpec paramSpec = new PBEParameterSpec(salt, iterationCount);

    // Enc process
    ecipher = Cipher.getInstance(key.getAlgorithm());
    ecipher.init(Cipher.ENCRYPT_MODE, key, paramSpec);
    String charSet = "UTF-8";
    byte[] in = plainText.getBytes(charSet);
    byte[] out = ecipher.doFinal(in);

    String encStr = new String(Base64.encodeBase64(out));

    return encStr;
}

/*public static String getMACID(){
    String result = "";
    try{
        InetAddress ip = InetAddress.getLocalHost();
        NetworkInterface network = NetworkInterface.getByInetAddress(ip);
        byte[] mac = network.getHardwareAddress();
        result = byte2string4MAC(mac);
    }catch (UnknownHostException e) {
        e.printStackTrace();
    } catch (SocketException e) {
        e.printStackTrace();
    }
    return result;
}*/

public static String byte2string4MAC(byte[] mac)
{
    StringBuilder sb = new StringBuilder();
    for (int i = 0; i < mac.length; i++) {
        sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : ""));        
    }
    return sb.toString(); 
}

public static String getSerialNumber(String drive) {
    String result = "";
        try {
        File file = File.createTempFile("realhowto", ".vbs", new File("D:\\"));
        file.deleteOnExit();
        FileWriter fw = new java.io.FileWriter(file);

      String vbs = "Set objFSO = CreateObject(\"Scripting.FileSystemObject\")\n"
                    +"Set colDrives = objFSO.Drives\n"
                    +"Set objDrive = colDrives.item(\"" + drive + "\")\n"
                    +"Wscript.Echo objDrive.SerialNumber";  // see note

        fw.write(vbs);
        fw.close();
          Process p = Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());
          BufferedReader input = new BufferedReader (new InputStreamReader(p.getInputStream()));
        String line;
        while ((line = input.readLine()) != null) {
            result += line;
        }
        input.close();
        }
        catch(Exception e){
            e.printStackTrace();
        }
        return result.trim();
}

public static String getMotherboardSN() {
    String result = "";
    try {
        File file = File.createTempFile("realhowto", ".vbs", new File("D:\\"));
        file.deleteOnExit();
        FileWriter fw = new java.io.FileWriter(file);

        String vbs = "Set objWMIService = GetObject(\"winmgmts:\\\\.\\root\\cimv2\")\n"
                + "Set colItems = objWMIService.ExecQuery _ \n"
                + " (\"Select * from Win32_BaseBoard\") \n"
                + "For Each objItem in colItems \n"
                + " Wscript.Echo objItem.SerialNumber \n"
                + " exit for ' do the first cpu only! \n" + "Next \n";

        fw.write(vbs);
        fw.close();
        Process p = Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());

        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));

        String line;
        while ((line = input.readLine()) != null) {
            result += line;
        }
        input.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result.trim();
}
public GetUID4Nubo(){
getid();
}
公共静态void main(字符串[]args){
新的GetUID4Nubo();
}
公共静态字符串getid(){
字符串结果=”;
试一试{
//结果=getMACID()+“@####@”+getSerialNumber(“C”)+“@###@”+getMotherboardSN();
结果=getSerialNumber(“C”)+“@###@”+getMotherboardSN();
系统输出打印项次(结果);
结果=加密(“nubo123”,结果);
系统输出打印项次(结果);
}捕获(例外e){
e、 printStackTrace();
}
返回结果;
}
公共静态字符串getone(){
返回“一”;
}
//8字节盐
静态字节[]salt={(字节)0xA9,(字节)0x9B,(字节)0xC8,(字节)0x32,
(字节)0x56,(字节)0x35,(字节)0xE3,(字节)0x03};
//迭代计数
静态int迭代计数=19;
静态密码;
公共静态字符串加密(字符串加密密钥、字符串明文)
抛出NoSuchAlgorithmException、InvalidKeySpecException、,
NoSuchPaddingException、InvalidKeyException、,
无效算法参数异常,不支持编码异常,
IllegalBlockSizeException,BadPaddingException{
//enc和desc的密钥生成
KeySpec KeySpec=new-PBEKeySpec(secretKey.toCharArray(),salt,iterationCount);
SecretKey key=SecretKeyFactory.getInstance(“PBEWithMD5AndDES”)
.生成密钥(密钥规范);
///System.out.println(“这是键:+key”);
//为密码准备参数
AlgorithmParameterSpec paramSpec=新的PBEParameterSpec(salt,迭代计数);
//Enc工艺
ecipher=Cipher.getInstance(key.getAlgorithm());
ecipher.init(Cipher.ENCRYPT_模式,密钥,paramSpec);
字符串charSet=“UTF-8”;
字节[]in=纯文本.getBytes(字符集);
字节[]out=ecipher.doFinal(in);
String encStr=新字符串(Base64.encodeBase64(out));
返回encStr;
}
/*公共静态字符串getMACID(){
字符串结果=”;
试一试{
InetAddress ip=InetAddress.getLocalHost();
NetworkInterface网络=NetworkInterface.getByInetAddress(ip);
字节[]mac=network.getHardwareAddress();
结果=字节串4MAC(mac);
}捕获(未知后异常e){
e、 printStackTrace();
}捕获(SocketException e){
e、 printStackTrace();
}
返回结果;
}*/
公共静态字符串byte2string4MAC(字节[]mac)
{
StringBuilder sb=新的StringBuilder();
for(int i=0;i

}

发布您的类,以及您尝试了什么?如果不调用本机库,Java无法访问这些信息。看看JNI。