Maven Dependency:
<dependency>
<groupId>com.adobe.granite</groupId>
<artifactId>com.adobe.granite.crypto</artifactId>
<version>0.0.18</version>
<scope>provided</scope>
</dependency>
Service to encrypt/decrypt the message:
<groupId>com.adobe.granite</groupId>
<artifactId>com.adobe.granite.crypto</artifactId>
<version>0.0.18</version>
<scope>provided</scope>
</dependency>
Service to encrypt/decrypt the message:
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import com.adobe.granite.crypto.CryptoException;
import com.adobe.granite.crypto.CryptoSupport;
@Component(immediate = true, metatype = true)
@Service(value = EncrypionService.class)
public class EncrypionService {
@Reference
private CryptoSupport cryptoSupport;
public String encrypt(String plainText) throws Exception
{
try {
return cryptoSupport.protect(plainText);
} catch (CryptoException e) {
throw e;
}
}
public String decrypt(String encryptedText) throws Exception
{
try {
return cryptoSupport.unprotect(encryptedText);
} catch (CryptoException e) {
throw e;
}
}
}
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.Service;
import com.adobe.granite.crypto.CryptoException;
import com.adobe.granite.crypto.CryptoSupport;
@Component(immediate = true, metatype = true)
@Service(value = EncrypionService.class)
public class EncrypionService {
@Reference
private CryptoSupport cryptoSupport;
public String encrypt(String plainText) throws Exception
{
try {
return cryptoSupport.protect(plainText);
} catch (CryptoException e) {
throw e;
}
}
public String decrypt(String encryptedText) throws Exception
{
try {
return cryptoSupport.unprotect(encryptedText);
} catch (CryptoException e) {
throw e;
}
}
}
No comments:
Post a Comment
If you have any doubts or questions, please let us know.