|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xwiki.crypto.passwd.internal.DefaultPasswordCryptoService
@Component public class DefaultPasswordCryptoService
This class allows the user to encrypt and decrypt text and data using a password. Base 64 encrypted ciphertext might look as follows:
-----BEGIN PASSWORD CIPHERTEXT----- rO0ABXNyADhvcmcueHdpa2kuY3J5cHRvLnBhc3N3ZC5pbnRlcm5hbC5DQVNUNVBh c3N3b3JkQ2lwaGVydGV4dGBjanGyQ5IzAgAAeHIAO29yZy54d2lraS5jcnlwdG8u cGFzc3dkLmludGVybmFsLkFic3RyYWN0UGFzc3dvcmRDaXBoZXJ0ZXh0wxB+AJ0R Z6ACAAJbAApjaXBoZXJ0ZXh0dAACW0JMAAtrZXlGdW5jdGlvbnQAL0xvcmcveHdp a2kvY3J5cHRvL3Bhc3N3ZC9LZXlEZXJpdmF0aW9uRnVuY3Rpb247eHB1cgACW0Ks 8xf4BghU4AIAAHhwAAABGPyIkxLgotOse8w/uihvcuHCV9XdFdKzQ7KQDtr0N6Tx /cG7npgtTF6+9FAtONY7lg== -----END PASSWORD CIPHERTEXT-----Users can also protect a password or other secret information so that it can be verified but not recovered. The output is a string of base-64 text without any header or footer as with encrypt.
| Constructor Summary | |
|---|---|
DefaultPasswordCryptoService()
|
|
| Method Summary | |
|---|---|
byte[] |
decryptBytes(byte[] rawCiphertext,
java.lang.String password)
Decrypt raw ciphertext created with PasswordCryptoService.encryptBytes(byte[], String). |
java.lang.String |
decryptText(java.lang.String base64Ciphertext,
java.lang.String password)
Decrypt a piece of text encrypted with encryptText. |
byte[] |
encryptBytes(byte[] message,
java.lang.String password)
Encipher the given byte array with the password. |
java.lang.String |
encryptText(java.lang.String plaintext,
java.lang.String password)
Encipher the given text with the password. |
boolean |
isPasswordCorrect(java.lang.String password,
java.lang.String protectedPassword)
Check the validity of a password. |
java.lang.String |
protectPassword(java.lang.String password)
Hash a password with a hash function specifically designed to make password guessing attacks difficult. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public DefaultPasswordCryptoService()
| Method Detail |
|---|
public java.lang.String encryptText(java.lang.String plaintext,
java.lang.String password)
throws java.security.GeneralSecurityException
encryptText in interface PasswordCryptoServiceplaintext - the text to encrypt.password - which will be needed to decrypt the text.
java.security.GeneralSecurityException - if something goes wrong.PasswordCryptoService.encryptText(java.lang.String, java.lang.String)
public java.lang.String decryptText(java.lang.String base64Ciphertext,
java.lang.String password)
throws java.security.GeneralSecurityException
decryptText in interface PasswordCryptoServicebase64Ciphertext - Base64 encoded ciphertext to decrypt.password - which was used to encrypt the text.
java.security.GeneralSecurityException - if something goes wrong.org.xwiki.crypto.passwd.PasswdCryptoService#decryptText(String, String)
public byte[] encryptBytes(byte[] message,
java.lang.String password)
throws java.security.GeneralSecurityException
encryptBytes in interface PasswordCryptoServicemessage - the message to encrypt.password - which will be needed to decrypt the text.
PasswordCryptoService.decryptBytes(byte[], String)
java.security.GeneralSecurityException - if something goes wrong.PasswordCryptoService.encryptBytes(byte[], java.lang.String)
public byte[] decryptBytes(byte[] rawCiphertext,
java.lang.String password)
throws java.security.GeneralSecurityException
PasswordCryptoService.encryptBytes(byte[], String).
Most of the time the response is null if the password is incorrect, 1 out of 250 times the output is
unintelligable garbage.
decryptBytes in interface PasswordCryptoServicerawCiphertext - the ciphertext to decrypt.password - which was used to encrypt the text.
java.security.GeneralSecurityException - if something goes wrong.PasswordCryptoService.decryptBytes(byte[], java.lang.String)
public java.lang.String protectPassword(java.lang.String password)
throws java.security.GeneralSecurityException
protectPassword in interface PasswordCryptoServicepassword - the plain text user supplied password.
java.security.GeneralSecurityException - on errorsorg.xwiki.crypto.passwd.PasswdCryptoService#protectPassword(String)
public boolean isPasswordCorrect(java.lang.String password,
java.lang.String protectedPassword)
throws java.security.GeneralSecurityException
isPasswordCorrect in interface PasswordCryptoServicepassword - the plain text user supplied password.protectedPassword - the result from calling protectPassword.
java.security.GeneralSecurityException - on errorsorg.xwiki.crypto.passwd.PasswdCryptoService#isPasswordCorrect(String, String)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||