com.h3c.api.security

## Class SecurityContext

- java.lang.Object
- - com.h3c.api.security.SecurityContext

-     public class SecurityContext
      extends Object

  Encapsulates TLS based security parameters, identifying the keystore and truststore (and their passwords) to be used in setting up secure connections.

  The keystore and truststore files may be generated using the JAVA `keytool` command. The root CA and reply certificates can be imported into keystore file or can create different truststore file.

  Example key and certificate management:

  - Generate Key pair

         keytool -genkey -alias server -keyalg RSA -keysize 2048 \
           -keystore controller.jks \
           -dname "CN=controller,OU=H3CN, O=H3C, L=Roseville, ST=CA, C=US"

  - Generate CSR(Certificate Signing Request) from key pair

         keytool -certreq -alias server -file controller.csr \
           -keystore controller.jks

  - Submit CSR to CA (Certification Authority) for signing. The CA will authenticate and then will return a certificate signed by them, authenticating submitted Public Key. The CA may return a chain of certificates also. (The CA will return root CA and certificate reply)

  - Import the root certificate for the CA.

         keytool -importcert -trustcacerts -keystore controller.jks \
           -file root.pem -alias theCARoot -keypass skyline -storepass skyline

  - Import the certificate reply from the CA.

          keytool -importcert -trustcacerts -keystore controller.jks \
            -file controller.pem -alias server -keypass skyline -storepass skyline

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `SecurityContext()` Constructs a null security context; that is all four parameters are empty strings.
    `SecurityContext(String keyStoreName, String keyStorePass, String trustStoreName, String trustStorePass)` Constructs a security context with the specified arguments.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object o)`
    `int` | `hashCode()`
    `String` | `keyStoreName()` Returns the pathname of the keystore.
    `String` | `keyStorePass()` Returns the keystore password.
    `String` | `toString()`
    `String` | `trustStoreName()` Returns the pathname of the truststore.
    `String` | `trustStorePass()` Returns the truststore password.

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### SecurityContext

          public SecurityContext(String keyStoreName,
                         String keyStorePass,
                         String trustStoreName,
                         String trustStorePass)

      Constructs a security context with the specified arguments. Any `null` arguments are quietly replaced with an empty string.
      Parameters:
        `keyStoreName` - the pathname of the keystore
        `keyStorePass` - the keystore password
        `trustStoreName` - the pathname of the truststore
        `trustStorePass` - the truststore password

    - #### SecurityContext

          public SecurityContext()

      Constructs a null security context; that is all four parameters are empty strings.

  - ### Method Detail

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### keyStoreName

          public String keyStoreName()

      Returns the pathname of the keystore.
      Returns:
        the pathname of the keystore

    - #### keyStorePass

          public String keyStorePass()

      Returns the keystore password.
      Returns:
        the keystore password

    - #### trustStoreName

          public String trustStoreName()

      Returns the pathname of the truststore.
      Returns:
        the pathname of the truststore

    - #### trustStorePass

          public String trustStorePass()

      Returns the truststore password.
      Returns:
        the truststore password

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

Copyright © 2014. All Rights Reserved.