Tabnine Logo
InvalidKeyException.toString
Code IndexAdd Tabnine to your IDE (free)

How to use
toString
method
in
java.security.InvalidKeyException

Best Java code snippets using java.security.InvalidKeyException.toString (Showing top 15 results out of 315)

origin: com.aliyun/aliyun-java-sdk-core

@Override
public String signString(String stringToSign, String accessKeySecret) {
  try {
    Mac mac = Mac.getInstance(ALGORITHM_NAME);
    mac.init(new SecretKeySpec(accessKeySecret.getBytes(ENCODING), ALGORITHM_NAME));
    byte[] signData = mac.doFinal(stringToSign.getBytes(ENCODING));
    return DatatypeConverter.printBase64Binary(signData);
  } catch (NoSuchAlgorithmException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (UnsupportedEncodingException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (InvalidKeyException e) {
    throw new IllegalArgumentException(e.toString());
  }
}
origin: com.alibaba.edas.acm/acm-sdk

@Override
public String signString(String stringToSign, String accessKeySecret) {
  try {
    Mac mac = Mac.getInstance(ALGORITHM_NAME);
    mac.init(new SecretKeySpec(
      accessKeySecret.getBytes(ENCODING),
      ALGORITHM_NAME
    ));
    byte[] signData = mac.doFinal(stringToSign.getBytes(ENCODING));
    return DatatypeConverter.printBase64Binary(signData);
  } catch (NoSuchAlgorithmException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (UnsupportedEncodingException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (InvalidKeyException e) {
    throw new IllegalArgumentException(e.toString());
  }
}
origin: tencentyun/cos-java-sdk-v4

/**
 * 计算数据的Hmac值
 * 
 * @param binaryData 二进制数据
 * @param key 秘钥
 * @return 加密后的hmacsha1值
 */
public static byte[] HmacSha1(byte[] binaryData, String key) throws Exception {
  try {
    Mac mac = Mac.getInstance(HMAC_SHA1);
    SecretKeySpec secretKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1);
    mac.init(secretKey);
    byte[] HmacSha1Digest = mac.doFinal(binaryData);
    return HmacSha1Digest;
  } catch (NoSuchAlgorithmException e) {
    LOG.error("mac not find algorithm {}", HMAC_SHA1);
    throw e;
  } catch (InvalidKeyException e) {
    LOG.error("mac init key {} occur a error {}", key, e.toString());
    throw e;
  } catch (IllegalStateException e) {
    LOG.error("mac.doFinal occur a error {}", e.toString());
    throw e;
  }
}
origin: com.aliyun/aliyun-java-sdk-core

@Override
public String signString(String stringToSign, String accessKeySecret) {
  try {
    Signature rsaSign = Signature.getInstance("SHA256withRSA");
    KeyFactory kf = KeyFactory.getInstance("RSA");
    byte[] keySpec = DatatypeConverter.parseBase64Binary(accessKeySecret);
    PrivateKey privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(keySpec));
    rsaSign.initSign(privateKey);
    rsaSign.update(stringToSign.getBytes(ENCODING));
    byte[] sign = rsaSign.sign();
    String signature = new String(DatatypeConverter.printBase64Binary(sign));
    return signature;
  } catch (NoSuchAlgorithmException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (InvalidKeySpecException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (InvalidKeyException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (SignatureException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (UnsupportedEncodingException e) {
    throw new IllegalArgumentException(e.toString());
  }
}
origin: org.xlightweb/xlightweb

/**
 * computes a  HMAC-SHA1 Signature
 * 
 * @param data  the data
 * @param key   the key 
 * @return the signature
 * @throws IOException if an error occurs
 */
public static byte[] computeRFC2104HMAC(byte[] data, byte[] key) throws IOException {
  
  try {
    SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA1");

    Mac mac = Mac.getInstance("HmacSHA1");
    mac.init(signingKey);

    byte[] rawHmac = mac.doFinal(data);

    return encodeBase64(rawHmac);
    
  } catch (NoSuchAlgorithmException nsae) {
    throw new IOException("required algorithm HmacSHA1 is not supported by environment: " + nsae.toString());
    
  } catch (InvalidKeyException ke) {
    throw new IOException("error occured by initializing mac: " + ke.toString());
  }
}
origin: com.alibaba.edas.acm/acm-sdk

@Override
public String signString(String stringToSign, String accessKeySecret) {
  try {
    Signature rsaSign = Signature.getInstance("SHA256withRSA");
    KeyFactory kf = KeyFactory.getInstance("RSA");
    byte[] keySpec = DatatypeConverter.parseBase64Binary(accessKeySecret);
    PrivateKey privateKey = kf.generatePrivate(new PKCS8EncodedKeySpec(keySpec));
    rsaSign.initSign(privateKey);
    rsaSign.update(stringToSign.getBytes(ENCODING));
    byte[] sign = rsaSign.sign();
    String signature = new String(DatatypeConverter.printBase64Binary(sign));
    return signature;
  } catch (NoSuchAlgorithmException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (InvalidKeySpecException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (InvalidKeyException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (SignatureException e) {
    throw new IllegalArgumentException(e.toString());
  } catch (UnsupportedEncodingException e) {
    throw new IllegalArgumentException(e.toString());
  }
}
origin: org.gnu/gnu-crypto

  private IMode getMode(byte[] key, byte[] iv, int state) {
   IBlockCipher cipher = CipherFactory.getInstance(properties.get("cipher"));
   if (cipher == null) {
     throw new IllegalArgumentException("no such cipher: " + properties.get("cipher"));
   }
   int blockSize = cipher.defaultBlockSize();
   if (properties.containsKey("block-size")) {
     try {
      blockSize = Integer.parseInt(properties.get("block-size"));
     } catch (NumberFormatException nfe) {
      throw new IllegalArgumentException("bad block size: " + nfe.getMessage());
     }
   }
   IMode mode = ModeFactory.getInstance(properties.get("mode"), cipher, blockSize);
   if (mode == null) {
     throw new IllegalArgumentException("no such mode: " + properties.get("mode"));
   }

   HashMap modeAttr = new HashMap();
   modeAttr.put(IMode.KEY_MATERIAL, key);
   modeAttr.put(IMode.STATE, new Integer(state));
   modeAttr.put(IMode.IV, iv);
   try {
     mode.init(modeAttr);
   } catch (InvalidKeyException ike) {
     throw new IllegalArgumentException(ike.toString());
   }
   return mode;
  }
}
origin: gradle.plugin.io.github.astinchoi/Akamai-AuthToken-Java

  throw new AuthTokenException(e.toString());
} catch (InvalidKeyException e) {
  throw new AuthTokenException(e.toString());
origin: gradle.plugin.com.akamai.open/Akamai-AuthToken-Java

  throw new AuthTokenException(e.toString());
} catch (InvalidKeyException e) {
  throw new AuthTokenException(e.toString());
origin: org.gnu/gnu-crypto

  mode.init(modeAttr);
} catch (InvalidKeyException ike) {
  throw new IllegalArgumentException(ike.toString());
origin: org.gnu/gnu-crypto

  mac.init(macAttr);
} catch (InvalidKeyException shouldNotHappen) {
  throw new Error(shouldNotHappen.toString());
origin: com.madgag.spongycastle/prov

throw new IOException(e.toString());
origin: org.bouncycastle/bcprov-debug-jdk15on

throw new IOException(e.toString());
origin: com.pubnub/pubnub

public String encrypt(String input) throws PubNubException {
  try {
    initCiphers();
    AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
    SecretKeySpec newKey = new SecretKeySpec(keyBytes, "AES");
    Cipher cipher = null;
    cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    cipher.init(Cipher.ENCRYPT_MODE, newKey, ivSpec);
    return new String(Base64.encode(cipher.doFinal(input.getBytes("UTF-8")), 0), Charset.forName("UTF-8"));
  } catch (NoSuchAlgorithmException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (NoSuchPaddingException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (InvalidKeyException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (InvalidAlgorithmParameterException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (UnsupportedEncodingException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (IllegalBlockSizeException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (BadPaddingException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  }
}
origin: com.pubnub/pubnub-gson

public String encrypt(String input) throws PubNubException {
  try {
    initCiphers();
    AlgorithmParameterSpec ivSpec = new IvParameterSpec(ivBytes);
    SecretKeySpec newKey = new SecretKeySpec(keyBytes, "AES");
    Cipher cipher = null;
    cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
    cipher.init(Cipher.ENCRYPT_MODE, newKey, ivSpec);
    return new String(Base64.encode(cipher.doFinal(input.getBytes("UTF-8")), 0), Charset.forName("UTF-8"));
  } catch (NoSuchAlgorithmException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (NoSuchPaddingException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (InvalidKeyException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (InvalidAlgorithmParameterException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (UnsupportedEncodingException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (IllegalBlockSizeException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  } catch (BadPaddingException e) {
    throw PubNubException.builder().errormsg(e.toString()).build();
  }
}
java.securityInvalidKeyExceptiontoString

Popular methods of InvalidKeyException

  • <init>
    Constructs a new instance of InvalidKeyException with the cause.
  • getMessage
  • printStackTrace
  • getLocalizedMessage
  • initCause
  • getStackTrace
  • setStackTrace
  • getCause
  • addSuppressed
  • fillInStackTrace

Popular in Java

  • Making http post requests using okhttp
  • runOnUiThread (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • onRequestPermissionsResult (Fragment)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • BlockingQueue (java.util.concurrent)
    A java.util.Queue that additionally supports operations that wait for the queue to become non-empty
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Top plugins for Android Studio
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now