2 * Copyright (c) 2016, 2017 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.aaa.encrypt.impl;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotEquals;
13 import org.junit.Before;
14 import org.junit.Test;
15 import org.opendaylight.yang.gen.v1.config.aaa.authn.encrypt.service.config.rev160915.AaaEncryptServiceConfigBuilder;
18 * @author - Sharon Aicler (saichler@gmail.com)
21 public class AAAEncryptServiceImplTest {
22 private AAAEncryptionServiceImpl impl;
26 impl = new AAAEncryptionServiceImpl(new EncryptServiceConfigImpl(
27 OSGiEncryptionServiceConfigurator.generateConfig(new AaaEncryptServiceConfigBuilder()
28 .setCipherTransforms("AES/CBC/PKCS5Padding")
29 .setEncryptIterationCount(32768)
31 .setEncryptKeyLength(128)
32 .setEncryptMethod("PBKDF2WithHmacSHA1")
34 .setEncryptType("AES")
35 .setPasswordLength(12)
40 public void testShortString() {
41 String before = "shortone";
42 String encrypt = impl.encrypt(before);
43 assertNotEquals(before, encrypt);
44 String after = impl.decrypt(encrypt);
45 assertEquals(before, after);
49 public void testLongString() {
50 String before = "This is a very long string to encrypt for testing 1...2...3";
51 String encrypt = impl.encrypt(before);
52 assertNotEquals(before, encrypt);
53 String after = impl.decrypt(encrypt);
54 assertEquals(before, after);