Class AcquireHoKTokenByUserCredentialSample


  • public class AcquireHoKTokenByUserCredentialSample
    extends java.lang.Object
    This sample illustrates acquiring a Holder-Of-Key token from SSO server by passing the username and password of the user along with using the user's private key and certificate
      Usage:
     To use a pre-generated key/certificate pair use:
       run.bat com.vmware.sso.client.samples.AcquireHoKTokenByUserCredentialSample [sso url] [username] [password]
     ****OR*****
     To load the key/certificate pair from individual files use:
       run.bat com.vmware.sso.client.samples.AcquireHoKTokenByUserCredentialSample [sso url] [username] [password] [path to key file] [path to certificate file]
     ****OR*****
     To load the key/certificate pair from a keystore use:
       run.bat com.vmware.sso.client.samples.AcquireHoKTokenByUserCredentialSample [sso url] [username] [password] [path to keystore file] [keystore password] [alias used in keystore]
     
    Users can generate their own pair of private key and certificate using the keytool utility shipped with the jdk. Sample usage of the keytool to generate a pair would be as follows:
     
      > keytool -genkey -keyalg RSA -alias sample -keystore sampleKeystore.jks -storepass sample
      What is your first and last name?
        [Unknown]:  *.vmware.com
      What is the name of your organizational unit?
        [Unknown]:  Ecosystem Engineering
      What is the name of your organization?
        [Unknown]:  VMware, Inc.
      What is the name of your City or Locality?
        [Unknown]:  Palo Alto
      What is the name of your State or Province?
        [Unknown]:  California
      What is the two-letter country code for this unit?
        [Unknown]:  US
      Is CN=*.vmware.com, OU=Ecosystem Engineering, O="VMware, Inc.", L=Palo Alto, ST=
      California, C=US correct?
        [no]:  yes
    
      Enter key password for <sample>
              (RETURN if same as keystore password):
     
     
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.w3c.dom.Element getToken​(java.lang.String[] args, java.security.PrivateKey privateKey, java.security.cert.X509Certificate userCert)  
      static void main​(java.lang.String[] args)  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AcquireHoKTokenByUserCredentialSample

        public AcquireHoKTokenByUserCredentialSample()
    • Method Detail

      • getToken

        public static org.w3c.dom.Element getToken​(java.lang.String[] args,
                                                   java.security.PrivateKey privateKey,
                                                   java.security.cert.X509Certificate userCert)
                                            throws javax.xml.datatype.DatatypeConfigurationException
        Parameters:
        args - String array containing the following values in the below order:
        • SSO server url
        • username
        • password
        privateKey - PrivateKey of the user
        userCert - X509Certificate certificate of the user
        Returns:
        A Holder-Of-Key token
        Throws:
        javax.xml.datatype.DatatypeConfigurationException
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        Throws:
        java.lang.Exception