Class DefaultCipherService
- java.lang.Object
-
- de.hybris.platform.b2b.punchout.services.impl.DefaultCipherService
-
- All Implemented Interfaces:
CipherService
public class DefaultCipherService extends java.lang.Object implements CipherService
Default implementation ofCipherService.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringCHARACTER_ENCODING
-
Constructor Summary
Constructors Constructor Description DefaultCipherService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static java.lang.Stringencode(java.lang.String notEncoded)Used to grant correct character encoding through web.java.lang.Stringencrypt(java.lang.String userId, PunchOutSession punchoutSession)Create a hash for a given user to be used in punchout login.ConfigurationServicegetConfigurationService()protected java.lang.StringgetUnsecureText(java.lang.String userId, PunchOutSession punchoutSession)Gets text used for asymmetric encryption.java.lang.StringretrieveUserId(java.lang.String encryptedText, PunchOutSession punchoutSession)Retrieves the userId for a given encrypted text.voidsetConfigurationService(ConfigurationService configurationService)protected booleanverify(java.lang.String hash, java.lang.String userId, PunchOutSession punchoutSession)Generates a hash given the session data and verifies if it matches the hash provided.protected voidverifyPunchOutSession(PunchOutSession punchoutSession)
-
-
-
Field Detail
-
CHARACTER_ENCODING
protected static final java.lang.String CHARACTER_ENCODING
- See Also:
- Constant Field Values
-
-
Method Detail
-
encrypt
public java.lang.String encrypt(java.lang.String userId, PunchOutSession punchoutSession)Description copied from interface:CipherServiceCreate a hash for a given user to be used in punchout login.- Specified by:
encryptin interfaceCipherService- 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.IllegalArgumentExceptionDescription copied from interface:CipherServiceRetrieves the userId for a given encrypted text.- Specified by:
retrieveUserIdin interfaceCipherService- 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.IllegalArgumentExceptionGenerates 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.
-
getConfigurationService
public ConfigurationService getConfigurationService()
-
setConfigurationService
public void setConfigurationService(ConfigurationService configurationService)
-
-