
public.javadoc.org.spincast.plugins.crypto.SpincastCryptoUtilsDefault.html Maven / Gradle / Ivy
Show all versions of spincast-website Show documentation
SpincastCryptoUtilsDefault (org.spincast:spincast-framework 1.7.1 API)
org.spincast.plugins.crypto
Class SpincastCryptoUtilsDefault
- java.lang.Object
-
- org.spincast.plugins.crypto.SpincastCryptoUtilsDefault
-
- All Implemented Interfaces:
- SpincastCryptoUtils
public class SpincastCryptoUtilsDefault
extends Object
implements SpincastCryptoUtils
-
-
Field Summary
Fields
Modifier and Type
Field and Description
protected static org.slf4j.Logger
logger
-
Constructor Summary
Constructors
Constructor and Description
SpincastCryptoUtilsDefault(SpincastCryptoConfig spincastCryptoConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods
Modifier and Type
Method and Description
protected byte[]
buildKey(String original)
String
decrypt(String encrypted,
String secretKey)
Decrypts a string that was encrypted using
SpincastCryptoUtils.encrypt(String, String)
.
String
encrypt(String toEncrypt,
String secretKey)
Encrypts a string, using the given secret key and the
AES
algorithm.
String
generateNewHashSecureSalt()
Will generate a new secure salt that can
be used with
SpincastCryptoUtils.hashSecure(String, String)
.
protected SpincastCryptoConfig
getSpincastCryptoConfig()
String
hashSecure(String toHash,
String salt)
Will hash a string using BCrypt
.
protected void
init()
boolean
isRestrictedCryptographyJavaVersion()
Is the current Java version cryptography restricted?
void
removeCryptographyRestrictions()
From https://stackoverflow.com/a/22492582/843699
-
-
Constructor Detail
-
SpincastCryptoUtilsDefault
@Inject
public SpincastCryptoUtilsDefault(SpincastCryptoConfig spincastCryptoConfig)
-
Method Detail
-
getSpincastCryptoConfig
protected SpincastCryptoConfig getSpincastCryptoConfig()
-
init
@Inject
protected void init()
-
encrypt
public String encrypt(String toEncrypt,
String secretKey)
Description copied from interface: SpincastCryptoUtils
Encrypts a string, using the given secret key and the
AES
algorithm.
The generated encrypted payload
is a string which is also base64 encoded so it can be
used in urls, emails, etc.
You must use the associated SpincastCryptoUtils.decrypt(String, String)
method to decrypt
the resultind payload.
IMPORTANT!: For this method to work,
JCE policy files may be installed first, security must
be configured properly, or security policy must be
disabled using the SpincastCryptoConfig.removeJavaCryptoRestrictionsOnInit()
configuration.
- Specified by:
encrypt
in interface SpincastCryptoUtils
-
decrypt
public String decrypt(String encrypted,
String secretKey)
Description copied from interface: SpincastCryptoUtils
Decrypts a string that was encrypted using
SpincastCryptoUtils.encrypt(String, String)
.
IMPORTANT!: For this method to work,
JCE policy files may be installed first, security must
be configured properly, or security policy must be
disabled using the SpincastCryptoConfig.removeJavaCryptoRestrictionsOnInit()
configuration.
- Specified by:
decrypt
in interface SpincastCryptoUtils
-
buildKey
protected byte[] buildKey(String original)
-
hashSecure
public String hashSecure(String toHash,
String salt)
Description copied from interface: SpincastCryptoUtils
Will hash a string using BCrypt
. This is currently
a good way to hash passwords so they can be stored in a database.
You can use SpincastCryptoUtils.generateNewHashSecureSalt()
to generate a
new salt.
- Specified by:
hashSecure
in interface SpincastCryptoUtils
-
generateNewHashSecureSalt
public String generateNewHashSecureSalt()
Description copied from interface: SpincastCryptoUtils
Will generate a new secure salt that can
be used with
SpincastCryptoUtils.hashSecure(String, String)
.
- Specified by:
generateNewHashSecureSalt
in interface SpincastCryptoUtils
-
removeCryptographyRestrictions
public void removeCryptographyRestrictions()
From https://stackoverflow.com/a/22492582/843699
- Specified by:
removeCryptographyRestrictions
in interface SpincastCryptoUtils
- See Also:
https://stackoverflow.com/a/22492582/843699
-
isRestrictedCryptographyJavaVersion
public boolean isRestrictedCryptographyJavaVersion()
Description copied from interface: SpincastCryptoUtils
Is the current Java version cryptography restricted?
- Specified by:
isRestrictedCryptographyJavaVersion
in interface SpincastCryptoUtils
Copyright © 2019. All rights reserved.