moved to smartgears 4
This commit is contained in:
parent
ac57e449e3
commit
68c11e3717
|
@ -0,0 +1,7 @@
|
|||
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
# Changelog for Common Encryption
|
||||
|
||||
## [v2.0.0-SNAPSHOT]
|
||||
|
||||
- removed old Providers
|
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE xml>
|
||||
<ReleaseNotes>
|
||||
<Changeset component="org.gcube.core.common-encryption.1-2-1" date="${buildDate}">
|
||||
<Change>Fixed distro files and pom according to new release procedure</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.core.common-encryption.1-2-0" date="2019-11-08">
|
||||
<Change>Fixed pom according to new release procedure</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.core.common-encryption.1-1-0" date="2019-05-27">
|
||||
<Change>SymmetricKey is now a public class</Change>
|
||||
<Change>Fixed StringEncrypted decrypt/encrypt signatures. Deprecated olds ones</Change>
|
||||
<Change>Added the facility to store a key in a file in KeySerialization class</Change>
|
||||
<Change>SymmetricKey is now a public class</Change>
|
||||
<Change>Made public the fuctions used to crreates keys in KeyFactory class</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.core.common-encryption.1-0-1" date="2012-05-04">
|
||||
<Change>Compliancy with the new Maven-based release procedure</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.core.common-encryption.1-0-0" date="2012-02-14">
|
||||
<Change>First Release</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
10
pom.xml
10
pom.xml
|
@ -9,7 +9,7 @@
|
|||
</parent>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
<version>1.2.1</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<name>Common Encryption Library</name>
|
||||
<description>Common Encryption Library is collection of encryption utilities</description>
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-bom</artifactId>
|
||||
<version>1.4.0</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -37,6 +37,10 @@
|
|||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>common-security</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-scope</artifactId>
|
||||
|
@ -54,7 +58,7 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
@ -13,9 +13,10 @@ import java.util.Map;
|
|||
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.scope.impl.ScopeBean.Type;
|
||||
import org.gcube.common.security.ContextBean;
|
||||
import org.gcube.common.security.ContextBean.Type;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -42,9 +43,11 @@ public final class SymmetricKey {
|
|||
* @throws InvalidKeyException if the key is not available or is invalid
|
||||
*/
|
||||
public synchronized static Key getKey() throws InvalidKeyException {
|
||||
if(!keyContextMap.containsKey(ScopeProvider.instance.get()))
|
||||
load(ScopeProvider.instance.get());
|
||||
return keyContextMap.get(ScopeProvider.instance.get());
|
||||
Secret secret = SecretManagerProvider.instance.get();
|
||||
String context = secret.getContext();
|
||||
if(!keyContextMap.containsKey(context))
|
||||
load(context);
|
||||
return keyContextMap.get(context);
|
||||
}
|
||||
|
||||
public static Key loadKeyFromFile(File keyFile, String keyAlgorithm) throws InvalidKeyException {
|
||||
|
@ -97,7 +100,7 @@ public final class SymmetricKey {
|
|||
protected static String getKeyFileName(String context) throws InvalidKeyException {
|
||||
String keyFile = null;
|
||||
if(context != null) {
|
||||
ScopeBean bean = new ScopeBean(context);
|
||||
ContextBean bean = new ContextBean(context);
|
||||
if(bean.is(Type.VRE))
|
||||
bean = bean.enclosingScope();
|
||||
String name = bean.name();
|
||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.common.encryption;
|
|||
|
||||
import java.security.InvalidKeyException;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -10,12 +10,13 @@ public class LocalKeyTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
ScopeProvider.instance.set("/gcube/devsec");
|
||||
SecretManagerProvider.instance.set(new TestSecret("/gcube/devsec"));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws InvalidKeyException {
|
||||
String key=SymmetricKey.getKeyFileName(ScopeProvider.instance.get());
|
||||
String key=SymmetricKey.getKeyFileName(SecretManagerProvider.instance.get().getContext());
|
||||
System.out.println("file key found: "+key);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,8 @@
|
|||
package org.gcube.common.encryption;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.gcube.common.encryption.StringEncrypter;
|
||||
import org.gcube.common.encryption.SymmetricKey;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -20,7 +18,7 @@ public class StringEncrypterTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
ScopeProvider.instance.set("/gcube/devsec");
|
||||
SecretManagerProvider.instance.set(new TestSecret("/gcube/devsec"));
|
||||
key = SymmetricKey.getKey();
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import static org.junit.Assert.fail;
|
|||
import java.security.InvalidKeyException;
|
||||
import java.security.Key;
|
||||
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
@ -17,7 +17,7 @@ public class SymmetricKeyTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
ScopeProvider.instance.set("/gcube/devsec");
|
||||
SecretManagerProvider.instance.set(new TestSecret("/gcube/devsec"));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package org.gcube.common.encryption;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.gcube.common.security.Owner;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
|
||||
public class TestSecret extends Secret {
|
||||
|
||||
private String context;
|
||||
|
||||
public TestSecret(String context){
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Owner getOwner() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getContext() {
|
||||
return this.context;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getHTTPAuthorizationHeaders() {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExpired() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRefreshable() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,8 @@ package org.gcube.common.encryption.encrypter;
|
|||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.gcube.common.encryption.SymmetricKey;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.common.encryption.TestSecret;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Assert;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -17,7 +18,7 @@ public class StringEncrypterTest {
|
|||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
ScopeProvider.instance.set("/gcube/devsec");
|
||||
SecretManagerProvider.instance.set(new TestSecret("/gcube/devsec"));
|
||||
key = SymmetricKey.getKey();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue