GVKun编程网logo

Different types of keystore in Java Overview

1

对于DifferenttypesofkeystoreinJavaOverview感兴趣的读者,本文将提供您所需要的所有信息,并且为您提供关于@types/socket.io-redis编译失败,因为它

对于Different types of keystore in Java Overview感兴趣的读者,本文将提供您所需要的所有信息,并且为您提供关于@ types / socket.io-redis编译失败,因为它找不到由@ types / socket.io ...导出的适配器...、Abstract Types && Parameterized Types、Android Keystore 无法为 Keystore Key 创建密码、Difference between trustStore and keyStore in Java - SSL的宝贵知识。

本文目录一览:

Different types of keystore in Java Overview

Different types of keystore in Java Overview

原文链接:http://www.cnblogs.com/ZacharyHodgeZou/p/4612944.html

Different types of keystore in Java

JKS

DKS

JCEKS

PKCS12

PKCS11

http://www.pixelstech.net/article/1408345768-Different-types-of-keystore-in-Java----Overview

 

android keystore type

.keystore vs .jks in android

Difference between .keystore file and .jks file

AndroidKeyStore

https://developer.android.com/training/articles/keystore.html

转载于:https://www.cnblogs.com/ZacharyHodgeZou/p/4612944.html

@ types / socket.io-redis编译失败,因为它找不到由@ types / socket.io ...导出的适配器...

@ types / socket.io-redis编译失败,因为它找不到由@ types / socket.io ...导出的适配器...

如何解决@ types / socket.io-redis编译失败,因为它找不到由@ types / socket.io ...导出的适配器...

所以,我的推测是我的tsconfig或类似的东西出了问题。

npm run compile     

> engine@1.0.0 compile /Users/[...]/engine
> tsc

node_modules/@types/socket.io-redis/index.d.ts:76:45 - error TS2694: Namespace ''"/Users/[...]/node_modules/socket.io/dist/index"'' has no exported member ''Adapter''.

76     interface RedisAdapter extends SocketIO.Adapter {

但是,在检查socket.io/dist/index时,看来适配器接口确实是在行835上作为SocketIO名称空间的一部分导出的。

我以前没有在TS中使用过这些@types包,但是我的项目是一个非常标准的gts设置:

{
  "extends": "./node_modules/gts/tsconfig-google.json","compilerOptions": {
    "rootDir": ".","outDir": "build"
  },"include": [
    "src/**/*.ts","test/**/*.ts"
  ]
}

可以有人指出我要去哪里了吗?

解决方法

我通过卸载@ types / socket.io-redis软件包来解决此问题。

Abstract Types && Parameterized Types

Abstract Types && Parameterized Types

Abstract Types && Parameterized Types


Abstract Types(抽象类型) 

Scala 的抽象类型成员 (Abstract Type Members) 没有和 Java 等同的。 

两个语言中,类,接口 (Java), 特质 (Scala) 都可以有方法和字段作为成员。

Scala 的类 (class) 或特质 (trait) 可以有类型成员,下面例子是抽象类型成员:

object app_main extends App {
  // 通过给出这两个成员的具体定义来对这个类型进行实例化
  val abs = new AbsCell {
    override type T = Int
    override val init: T = 12
    override var me: S = "liyanxin"
  }

  println(abs.getMe)
  println(abs.getInit)

}

trait Cell {
  // 抽象类型成员S
  type S
  var me: S

  def getMe: S = me

  def setMe(x: S): Unit = {
    me = x
  }
}


/**
 * AbsCell 类既没有类型参数也没有值参数,
 * 而是定义了一个抽象类型成员 T 和一个抽象值成员 init。
 */
abstract class AbsCell extends Cell {

  //在子类内部具体化抽象类型成员S
  override type S = String
  // 抽象类型成员 T
  type T
  val init: T
  private var value: T = init

  def getInit: T = value

  def setInit(x: T): Unit = {
    value = x
  }
}

运行并输出:

liyanxin
0

参考:http://alanwu.iteye.com/blog/483959

https://github.com/wecite/papers/blob/master/An-Overview-of-the-Scala-Programming-Language/5.Abstraction.md

关于下面两者的区别:

abstract class Buffer {
  type T
  val element: T
}

rather that generics, for example,

abstract class Buffer[T{
  val element: T
}

请见:http://stackoverflow.com/questions/1154571/scala-abstract-types-vs-generics


Parameterized Types(参数化类型)

Scala supports parameterized types, which are very similar to generics in Java. (We could use the two terms interchangeably(可交换的), 

but it’s more common to use “parameterized types” in the Scala community and “generics” in the Java community.)  The most obvious difference is in the

syntax, where Scala uses square brackets ([...] ), while Java uses angle brackets (<...>).

用类型参数化类

For example, a list of strings would be declared as follows:

class GenCell[T](init: T) {
  private var value: T = init

  def get: T = value

  //Unit相当于返回void
  def set(x: T): Unit = {

    value = x
  }
}

在上面的定义中,“T” 是一个类型参数,可被用在 GenCell 类和它的子类中。类参数可以是任意 (arbitrary) 的名字。用 [] 来包围,而不是用 () 来包围,用以和值参数进行区别。


用类型参数化函数

如下代码示例

class GenCell[T](init: T) {
  private var value: T = init

  def get: T = value

  //Unit相当于返回void
  def set(x: T): Unit = {

    value = x
  }
}


object app_main extends App {

  //用T参数化函数
  def swap[T](x: GenCell[T], y: GenCell[T]): Unit = {
    val t = x.get;
    x.set(y.get);
    y.set(t)
  }

  val x: GenCell[Int] = new GenCell[Int](1)
  val y: GenCell[Int] = new GenCell[Int](2)
  swap[Int](x, y)

  println(x.get)
  println(y.get)
}

参考:https://github.com/wecite/papers/blob/master/An-Overview-of-the-Scala-Programming-Language/5.Abstraction.md

==============END==============

Android Keystore 无法为 Keystore Key 创建密码

Android Keystore 无法为 Keystore Key 创建密码

如何解决Android Keystore 无法为 Keystore Key 创建密码

我无法在任何手机上重现此内容,只有来自用户的日志。他们有一部华为手机,看起来他们的 Keystore 代码已被修改,因为没有任何行号与 googlesource 一致。尝试从密钥创建密码对象时会发生这种情况。 Cipher.init。用户拥有华为(Nova 3i)。我看到了华为的其他一些问题:Huawei p8 or p8 Lite has problem with Keystore Encryption

java.security.InvalidKeyException:密钥库操作失败 在 android.security.KeyStore.getInvalidKeyException(KeyStore.java:924) 在 android.security.KeyStore.getInvalidKeyException(KeyStore.java:949) 在 android.security.keystore.KeyStoreCryptoOperationUtils.getInvalidKeyExceptionForInit(KeyStoreCryptoOperationUtils.java:54) 在 android.security.keystore.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:89) 在 android.security.keystore.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:265) 在 android.security.keystore.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:148) 在 javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2980) 在 javax.crypto.Cipher.tryCombinations(Cipher.java:2891) 在 javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2796) 在 javax.crypto.Cipher.chooseProvider(Cipher.java:773) 在 javax.crypto.Cipher.init(Cipher.java:1288) 在 javax.crypto.Cipher.init(Cipher.java:1223)

引起:android.security.KeyStoreException:设备被锁定 在 android.security.KeyStore.getKeyStoreException(KeyStore.java:862)

有没有人在华为手机或其他手机上遇到过这种情况?看起来密钥可以在某个时候使用,但不能再次使用。密钥生成示例

  1. val keyStore = KeyStore.getInstance(ANDROID_KEYSTORE)
  2. keyStore.load(null)
  3. val keyGenerator = KeyGenerator.getInstance(
  4. KeyProperties.KEY_ALGORITHM_AES,ANDROID_KEYSTORE)
  5. val builder = KeyGenParameterSpec.Builder(
  6. keyName,KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT)
  7. .setBlockModes(KeyProperties.BLOCK_MODE_GCM)
  8. .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
  9. keyGenerator.init(builder.build())
  10. val key = keyGenerator.generateKey()

Difference between trustStore and keyStore in Java - SSL

Difference between trustStore and keyStore in Java - SSL

Difference between trustStore and keyStore in Java - SSL

 
trustStore vs keyStore in Java
trustStore and keyStore are used in context of setting up SSL connection in Java application between client and server. TrustStore and keyStore are very much similar in terms of construct and structure as both are managed by  keytoolcommand and represented by KeyStore programatically but they often confused Java programmer both beginners and intermediate alike. Only  difference between trustStore and keyStore is what they store and there purpose. In SSL handshake purpose of  trustStore is to verify credentials and purpose of  keyStore is to provide credential. keyStore in Java stores private key and certificates corresponding to there public keys and require if you are SSL Server or SSL requires client authentication. TrustStore stores certificates from third party, your Java application communicate or certificates signed by CA(certificate authorities like Verisign, Thawte, Geotrust or GoDaddy) which can be used to identify third party. This is second article on setting up SSL on Java program, In last post we have seen  How to import SSL certificates into trustStore and keyStore and In this Java article we will some differences between keystore and truststore in Java, which will help to understand this concept better.
 
 

Difference between trustStore and keyStore in Java

Here is the list of most  common difference between keyStore and trustStore. I have already mentioned key difference in first paragraph which is related to purpose of keyStore and trustStore, which we will see here is little more detail.

 

1)First and major difference between trustStore and keyStore is that trustStore is used by TrustManager and keyStore is used by KeyManager  class in Java. KeyManager and TrustManager performs different job in Java, TrustManager determines whether remote connection should be trusted or not i.e. whether remote party is who it claims to and KeyManager decides which  authentication credentials should be sent to the remote host for authentication during SSL handshake. if you are an SSL Server you will use private key during key exchange algorithm and send certificates corresponding to your public keys to client, this certificate is acquired from keyStore. On SSL client side, if its written in Java, it will use certificates stored in trustStore to verify identity of Server. SSL certificates are most commonly comes as .cer file which is added into keyStore or trustStore by using any key management utility e.g.  keytool. See my post  How to add certificates into trustStore for step by step guide on adding certificates into keyStore or trustStore in Java.
 
2) Another difference between trustStore and keyStore in rather simple terms is that keyStore contains private keys and required only if you are running a Server in SSL connection or you have enabled  client authentication on server side. On the other hand trustStore stores public key or certificates from CA (Certificate Authorities) which is used to trust remote party or SSL connection.
 
3)One more difference between trustStore vs KeyStore is that we use -Djavax.net.ssl.keyStore to specify  path for keyStore and -Djavax.net.ssl.trustStore to specify path for trustStore in Java.
 
4) Another difference between trustStore and keyStore is that, If you store your personal certificate along with signer certificate in trustStore,  you can use same file as both trustStore and keyStore. By the way its good idea to separate personal certificate and signer certificates in keyStore and trustStore for better management.
 
5) One more API level difference between keyStore and trustStore is that  password of keyStore is provided using -Djavax.net.ssl.keyStorePassword and password of trustStore is provided using -Djavax.net.ssl.trustStorePassword.
 
That’s all on difference between trustStore and keyStore in Java. You can still use same file as trustStore and keyStore in Java to avoid maintaining two separate files, but its good idea to segregate public keys and private keys in two different files, its more verbose and self explanatory that which one holds CA certificates to trust server and which contains client''s private keys.
 
总之,keyStore是用于存放自己keytool产生的key(public/private) (浏览器是否相信server, public key经过CA签名用于商业SSL), truststore用于存放第三方提供的经过CA认证的public key(用于server是否相信第三方连接)



Read more: https://javarevisited.blogspot.com/2012/09/difference-between-truststore-vs-keyStore-Java-SSL.html#ixzz5i1OTp1X1

我们今天的关于Different types of keystore in Java Overview的分享已经告一段落,感谢您的关注,如果您想了解更多关于@ types / socket.io-redis编译失败,因为它找不到由@ types / socket.io ...导出的适配器...、Abstract Types && Parameterized Types、Android Keystore 无法为 Keystore Key 创建密码、Difference between trustStore and keyStore in Java - SSL的相关信息,请在本站查询。

本文标签: