Class DefaultPlexusCipher
- java.lang.Object
-
- org.sonatype.plexus.components.cipher.DefaultPlexusCipher
-
- All Implemented Interfaces:
PlexusCipher
@Singleton @Named("default") @Typed(PlexusCipher.class) public class DefaultPlexusCipher extends java.lang.Object implements PlexusCipherDefault implementation ofPlexusCipher. This class is thread safe.- Author:
- Oleg Gusakov
-
-
Field Summary
-
Fields inherited from interface org.sonatype.plexus.components.cipher.PlexusCipher
ENCRYPTED_STRING_DECORATION_START, ENCRYPTED_STRING_DECORATION_STOP
-
-
Constructor Summary
Constructors Constructor Description DefaultPlexusCipher()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringdecorate(java.lang.String str)decorated given string with { and }java.lang.Stringdecrypt(java.lang.String str, java.lang.String passPhrase)decrypt given base64 encrypted stringjava.lang.StringdecryptDecorated(java.lang.String str, java.lang.String passPhrase)decrypt given base64 encoded encrypted string.java.lang.Stringencrypt(java.lang.String str, java.lang.String passPhrase)encrypt given string with the given passPhrase and encode it into base64java.lang.StringencryptAndDecorate(java.lang.String str, java.lang.String passPhrase)encrypt given string with the given passPhrase, encode it into base64 and return result, wrapped into { } decorationsstatic java.lang.String[]getCryptoImpls(java.lang.String serviceType)This method returns the available implementations for a service typestatic java.lang.String[]getServiceTypes()Exploratory part.booleanisEncryptedString(java.lang.String str)check if given string is decoratedstatic voidmain(java.lang.String[] args)java.lang.StringunDecorate(java.lang.String str)return string inside decorations
-
-
-
Method Detail
-
encrypt
public java.lang.String encrypt(java.lang.String str, java.lang.String passPhrase) throws PlexusCipherExceptionDescription copied from interface:PlexusCipherencrypt given string with the given passPhrase and encode it into base64- Specified by:
encryptin interfacePlexusCipher- Parameters:
str- string to encryptpassPhrase- pass phrase- Returns:
- encrypted str
- Throws:
PlexusCipherException- if encryption fails
-
encryptAndDecorate
public java.lang.String encryptAndDecorate(java.lang.String str, java.lang.String passPhrase) throws PlexusCipherExceptionDescription copied from interface:PlexusCipherencrypt given string with the given passPhrase, encode it into base64 and return result, wrapped into { } decorations- Specified by:
encryptAndDecoratein interfacePlexusCipher- Parameters:
str- string to encryptpassPhrase- pass phrase- Returns:
- encrypted and decorated str
- Throws:
PlexusCipherException- if encryption fails
-
decrypt
public java.lang.String decrypt(java.lang.String str, java.lang.String passPhrase) throws PlexusCipherExceptionDescription copied from interface:PlexusCipherdecrypt given base64 encrypted string- Specified by:
decryptin interfacePlexusCipher- Parameters:
str- base64 encoded stringpassPhrase- pass phrase- Returns:
- decrypted str
- Throws:
PlexusCipherException- if decryption fails
-
decryptDecorated
public java.lang.String decryptDecorated(java.lang.String str, java.lang.String passPhrase) throws PlexusCipherExceptionDescription copied from interface:PlexusCipherdecrypt given base64 encoded encrypted string. If string is decorated, decrypt base64 encoded string inside decorations- Specified by:
decryptDecoratedin interfacePlexusCipher- Parameters:
str- base64 encoded stringpassPhrase- pass phrase- Returns:
- decrypted decorated str
- Throws:
PlexusCipherException- if decryption fails
-
isEncryptedString
public boolean isEncryptedString(java.lang.String str)
Description copied from interface:PlexusCiphercheck if given string is decorated- Specified by:
isEncryptedStringin interfacePlexusCipher- Parameters:
str- string to check- Returns:
- true if string is encrypted
-
unDecorate
public java.lang.String unDecorate(java.lang.String str) throws PlexusCipherExceptionDescription copied from interface:PlexusCipherreturn string inside decorations- Specified by:
unDecoratein interfacePlexusCipher- Parameters:
str- decorated string- Returns:
- undecorated str
- Throws:
PlexusCipherException- if decryption fails
-
decorate
public java.lang.String decorate(java.lang.String str)
Description copied from interface:PlexusCipherdecorated given string with { and }- Specified by:
decoratein interfacePlexusCipher- Parameters:
str- string to decorate- Returns:
- decorated str
-
getServiceTypes
public static java.lang.String[] getServiceTypes()
Exploratory part. This method returns all available services types
-
getCryptoImpls
public static java.lang.String[] getCryptoImpls(java.lang.String serviceType)
This method returns the available implementations for a service type
-
main
public static void main(java.lang.String[] args)
-
-