Code examples for Key

Codota analyzed 7,668,838 open source code samples to find the most common, credible and clear examples.
You can now enable Codota on your own code to easily search and navigate your Java codebase.
80:	if (!"EC".equals(key.getAlgorithm())) { 
-
88:	final byte[] encoded = key.getEncoded(); 
89:	if (!"X.509".equals(key.getFormat()) || encoded == null) { 
-
99:	final byte[] encoded = key.getEncoded(); 
100:	if (!"PKCS#8".equals(key.getFormat()) || encoded == null) { 
-
108:	final byte[] encoded = key.getEncoded(); 
109:	if (!"PKCS#8".equals(key.getFormat())) { 
-
111:	+ key.getFormat()); 
-
117:	final byte[] encoded = key.getEncoded(); 
118:	if (!"X.509".equals(key.getFormat())) { 
-
120:	+ key.getFormat()); 
-
127:	+ key.getClass().getName() + ", keySpec=" + keySpec.getName()); 
Full Snippet Info
7
CodeRank
384:	byte[]      enc = key.getEncoded(); 
-
399:	dOut.writeUTF(key.getFormat()); 
400:	dOut.writeUTF(key.getAlgorithm()); 
Full Snippet Info
7
CodeRank
82:	if (!"RSA".equals(key.getAlgorithm())) { 
-
90:	final byte[] encoded = key.getEncoded(); 
91:	if (!"X.509".equals(key.getFormat()) || encoded == null) { 
-
114:	final byte[] encoded = key.getEncoded(); 
115:	if (!"PKCS#8".equals(key.getFormat()) || encoded == null) { 
-
130:	final byte[] encoded = key.getEncoded(); 
131:	if (!"PKCS#8".equals(key.getFormat()) || encoded == null) { 
-
139:	final byte[] encoded = key.getEncoded(); 
140:	if (!"PKCS#8".equals(key.getFormat())) { 
-
142:	+ key.getFormat()); 
-
148:	final byte[] encoded = key.getEncoded(); 
149:	if (!"X.509".equals(key.getFormat())) { 
-
151:	+ key.getFormat()); 
-
158:	+ key.getClass().getName() + ", keySpec=" + keySpec.getName()); 
Full Snippet Info
7
CodeRank
80:	if (!"EC".equals(key.getAlgorithm())) { 
-
88:	final byte[] encoded = key.getEncoded(); 
89:	if (!"X.509".equals(key.getFormat()) || encoded == null) { 
-
99:	final byte[] encoded = key.getEncoded(); 
100:	if (!"PKCS#8".equals(key.getFormat()) || encoded == null) { 
-
108:	final byte[] encoded = key.getEncoded(); 
109:	if (!"PKCS#8".equals(key.getFormat())) { 
-
111:	+ key.getFormat()); 
-
117:	final byte[] encoded = key.getEncoded(); 
118:	if (!"X.509".equals(key.getFormat())) { 
-
120:	+ key.getFormat()); 
-
127:	+ key.getClass().getName() + ", keySpec=" + keySpec.getName()); 
Full Snippet Info
7
CodeRank
106:	return key.getEncoded().length; 
Full Snippet Info
7
CodeRank
190:	Assert.assertTrue(Arrays.equals(originalKey.getEncoded(), keyFromDisk.getEncoded())); 
191:	Assert.assertEquals(originalKey.getAlgorithm(), keyFromDisk.getAlgorithm()); 
192:	Assert.assertEquals(originalKey.getFormat(), keyFromDisk.getFormat()); 
Full Snippet Info
6
CodeRank
79:	if (!"DSA".equals(key.getAlgorithm())) { 
-
89:	final byte[] encoded = key.getEncoded(); 
90:	if (!"X.509".equals(key.getFormat()) || encoded == null) { 
-
105:	final byte[] encoded = key.getEncoded(); 
106:	if (!"PKCS#8".equals(key.getFormat()) || encoded == null) { 
-
116:	final byte[] encoded = key.getEncoded(); 
117:	if (!"PKCS#8".equals(key.getFormat())) { 
-
119:	+ key.getFormat()); 
-
125:	final byte[] encoded = key.getEncoded(); 
126:	if (!"X.509".equals(key.getFormat())) { 
-
128:	+ key.getFormat()); 
-
135:	+ key.getClass().getName() + ", keySpec=" + keySpec.getName()); 
Full Snippet Info
7
CodeRank
384:	byte[]      enc = key.getEncoded(); 
-
399:	dOut.writeUTF(key.getFormat()); 
400:	dOut.writeUTF(key.getAlgorithm()); 
Full Snippet Info
6
CodeRank
103:	return (T) new X509EncodedKeySpec(key.getEncoded()); 
Full Snippet Info
6
CodeRank
66:	if (spec.isAssignableFrom(PKCS8EncodedKeySpec.class) && key.getFormat().equals("PKCS#8")) 
-
68:	return new PKCS8EncodedKeySpec(key.getEncoded()); 
-
70:	else if (spec.isAssignableFrom(X509EncodedKeySpec.class) && key.getFormat().equals("X.509")) 
-
72:	return new X509EncodedKeySpec(key.getEncoded()); 
Full Snippet Info
6
CodeRank
190:	Assert.assertTrue(Arrays.equals(originalKey.getEncoded(), keyFromDisk.getEncoded())); 
191:	Assert.assertEquals(originalKey.getAlgorithm(), keyFromDisk.getAlgorithm()); 
192:	Assert.assertEquals(originalKey.getFormat(), keyFromDisk.getFormat()); 
Full Snippet Info
6
CodeRank
82:	if (!"RSA".equals(key.getAlgorithm())) { 
-
90:	final byte[] encoded = key.getEncoded(); 
91:	if (!"X.509".equals(key.getFormat()) || encoded == null) { 
-
114:	final byte[] encoded = key.getEncoded(); 
115:	if (!"PKCS#8".equals(key.getFormat()) || encoded == null) { 
-
130:	final byte[] encoded = key.getEncoded(); 
131:	if (!"PKCS#8".equals(key.getFormat()) || encoded == null) { 
-
139:	final byte[] encoded = key.getEncoded(); 
140:	if (!"PKCS#8".equals(key.getFormat())) { 
-
142:	+ key.getFormat()); 
-
148:	final byte[] encoded = key.getEncoded(); 
149:	if (!"X.509".equals(key.getFormat())) { 
-
151:	+ key.getFormat()); 
-
158:	+ key.getClass().getName() + ", keySpec=" + keySpec.getName()); 
Full Snippet Info
6
CodeRank
78:	if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class) && key.getFormat().equals("PKCS#8")) 
-
80:	return new PKCS8EncodedKeySpec(key.getEncoded()); 
-
82:	else if (keySpec.isAssignableFrom(X509EncodedKeySpec.class) && key.getFormat().equals("X.509")) 
-
84:	return new X509EncodedKeySpec(key.getEncoded()); 
Full Snippet Info
6
CodeRank
75:	return key.getEncoded(); 
Full Snippet Info
6
CodeRank
66:	{ 
-
68:	 
-
70:	{ 
-
72:	} 
Full Snippet Info
6
CodeRank
44:	checkEncodedData(key.getFormat().getBytes(), decrypted.getFormat().getBytes()); 
45:	checkEncodedData(key.getEncoded(), decrypted.getEncoded()); 
Full Snippet Info
6
CodeRank
66:	 
-
68:	KeySpec keySpec) 
-
70:	{ 
-
72:	{ 
Full Snippet Info
6
CodeRank
74:	if (spec.isAssignableFrom(PKCS8EncodedKeySpec.class) && key.getFormat().equals("PKCS#8")) 
-
76:	return new PKCS8EncodedKeySpec(key.getEncoded()); 
-
78:	else if (spec.isAssignableFrom(X509EncodedKeySpec.class) && key.getFormat().equals("X.509")) 
-
80:	return new X509EncodedKeySpec(key.getEncoded()); 
Full Snippet Info
6
CodeRank
60:	return decrypt(text, key, key.getAlgorithm()); 
-
76:	LOGGER.trace("initialized decryption with key of type {}", key.getClass()); 
Full Snippet Info
6
CodeRank
66:	{ 
-
68:	if (k.getParams() != null) 
-
70:	return new org.bouncycastle.jce.spec.ECPublicKeySpec(EC5Util.convertPoint(k.getParams(), k.getW(), false), EC5Util.convertSpec(k.getParams(), false)); 
-
72:	else 
Full Snippet Info
6
CodeRank