All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dyadicsec.cryptoki.CKR_Exception Maven / Gradle / Ivy

Go to download

This is a collection of JAVA libraries that implement Unbound cryptographic classes for JAVA provider, PKCS11 wrapper, cryptoki, and advapi

There is a newer version: 42761
Show newest version
package com.dyadicsec.cryptoki;

public class CKR_Exception extends java.lang.Exception
{
    public int errorCode;
    public String functionName;

    public String getMessage()
    {
      if (functionName==null) return "Library errorCode=0x" + Integer.toHexString(errorCode);
      return "Library." + functionName + " failed, errorCode=0x" + Integer.toHexString(errorCode);
    }

    CKR_Exception(int errorCode, java.lang.Exception src) {
        super(src);
        this.errorCode = errorCode;
    }

    CKR_Exception(int errorCode) {
        this.errorCode = errorCode;
    }

    CKR_Exception(int errorCode, String functionName) {
        this.errorCode = errorCode;
    }

    static void check(long rv) throws CKR_Exception
    {
        int errorCode = (int)(rv>>32);
        if (errorCode!=0) throw new CKR_Exception(errorCode);
    }

    static void check(long rv, String function) throws CKR_Exception
    {
        int errorCode = (int)(rv>>32);
        if (errorCode!=0) throw new CKR_Exception(errorCode, function);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy