Class DefaultCipherService

    • Field Detail

      • CHARACTER_ENCODING

        protected static final java.lang.String CHARACTER_ENCODING
        See Also:
        Constant Field Values
    • Constructor Detail

      • DefaultCipherService

        public DefaultCipherService()
    • Method Detail

      • encrypt

        public java.lang.String encrypt​(java.lang.String userId,
                                        PunchOutSession punchoutSession)
        Description copied from interface: CipherService
        Create a hash for a given user to be used in punchout login.
        Specified by:
        encrypt in interface CipherService
        Parameters:
        userId - The human readable id of the user that will get an associated hash.
        punchoutSession - The session of the current punchout user.
        Returns:
        The encrypted value.
      • retrieveUserId

        public java.lang.String retrieveUserId​(java.lang.String encryptedText,
                                               PunchOutSession punchoutSession)
                                        throws PunchOutCipherException,
                                               java.lang.IllegalArgumentException
        Description copied from interface: CipherService
        Retrieves the userId for a given encrypted text.
        Specified by:
        retrieveUserId in interface CipherService
        Parameters:
        encryptedText - The text to be decrypted.
        punchoutSession - The session of the current punchout user.
        Returns:
        The userId, if the information contained in the encryptedText passes the security verification (null otherwise).
        Throws:
        PunchOutCipherException - If Cipher has issues decrypting the text.
        java.lang.IllegalArgumentException - If some of the required arguments is missing or empty.
      • verifyPunchOutSession

        protected void verifyPunchOutSession​(PunchOutSession punchoutSession)
                                      throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • encode

        protected static java.lang.String encode​(java.lang.String notEncoded)
        Used to grant correct character encoding through web.
        Parameters:
        notEncoded -
        Returns:
        The String encoded with CHARACTER_ENCODING.
      • verify

        protected boolean verify​(java.lang.String hash,
                                 java.lang.String userId,
                                 PunchOutSession punchoutSession)
                          throws java.lang.IllegalArgumentException
        Generates a hash given the session data and verifies if it matches the hash provided.
        Parameters:
        hash - The hash that should be validated.
        userId - The user that was used to create the hash.
        punchoutSession - The current punchout session.
        Returns:
        True if the hash passes the verification.
        Throws:
        java.lang.IllegalArgumentException - If arguments are null or empty.
      • getUnsecureText

        protected java.lang.String getUnsecureText​(java.lang.String userId,
                                                   PunchOutSession punchoutSession)
        Gets text used for asymmetric encryption.
        Parameters:
        userId -
        punchoutSession -
        Returns:
        The composed text that should be hashed.
      • setConfigurationService

        public void setConfigurationService​(ConfigurationService configurationService)