|
From: <go...@us...> - 2013-03-28 16:41:36
|
Revision: 16184
http://unicore.svn.sourceforge.net/unicore/?rev=16184&view=rev
Author: golbi
Date: 2013-03-28 16:41:27 +0000 (Thu, 28 Mar 2013)
Log Message:
-----------
Authn fixes and configuration from file
Modified Paths:
--------------
unity/trunk/core/src/main/java/pl/edu/icm/unity/server/endpoint/BindingAuthn.java
unity/trunk/core/src/main/java/pl/edu/icm/unity/server/registries/AuthenticatorsRegistry.java
unity/trunk/core/src/main/java/pl/edu/icm/unity/server/utils/UnityServerConfiguration.java
unity/trunk/distribution/src/test/resources/unityServer.conf
unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/authn/AuthenticatorImpl.java
unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/internal/EngineHelper.java
unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/internal/EngineInitialization.java
unity/trunk/engine/src/test/java/pl/edu/icm/unity/engine/TestAuthentication.java
unity/trunk/engine/src/test/java/pl/edu/icm/unity/engine/mock/MockPasswordRetrieval.java
unity/trunk/pom.xml
unity/trunk/types/src/main/java/pl/edu/icm/unity/types/authn/AuthenticatorTypeDescription.java
unity/trunk/web-common/pom.xml
unity/trunk/web-common/src/main/java/pl/edu/icm/unity/webui/authn/extensions/PasswordRetrievalFactory.java
unity/trunk/web-common/src/main/resources/META-INF/components.xml
Added Paths:
-----------
unity/trunk/distribution/src/test/resources/empty.json
unity/trunk/distribution/src/test/resources/passwordDef.json
unity/trunk/web-common/src/main/java/pl/edu/icm/unity/webui/authn/extensions/PasswordRetrieval.java
Modified: unity/trunk/core/src/main/java/pl/edu/icm/unity/server/endpoint/BindingAuthn.java
===================================================================
--- unity/trunk/core/src/main/java/pl/edu/icm/unity/server/endpoint/BindingAuthn.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/core/src/main/java/pl/edu/icm/unity/server/endpoint/BindingAuthn.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -13,5 +13,4 @@
public interface BindingAuthn
{
public String getBindingName();
- public String getBindingDescription();
}
Modified: unity/trunk/core/src/main/java/pl/edu/icm/unity/server/registries/AuthenticatorsRegistry.java
===================================================================
--- unity/trunk/core/src/main/java/pl/edu/icm/unity/server/registries/AuthenticatorsRegistry.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/core/src/main/java/pl/edu/icm/unity/server/registries/AuthenticatorsRegistry.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -11,6 +11,7 @@
import java.util.Map;
import java.util.Set;
+import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@@ -18,6 +19,7 @@
import pl.edu.icm.unity.server.authn.CredentialVerificator;
import pl.edu.icm.unity.server.authn.CredentialVerificatorFactory;
import pl.edu.icm.unity.server.authn.LocalCredentialVerificatorFactory;
+import pl.edu.icm.unity.server.utils.Log;
import pl.edu.icm.unity.types.authn.AuthenticatorInstance;
import pl.edu.icm.unity.types.authn.AuthenticatorTypeDescription;
import pl.edu.icm.unity.types.authn.CredentialType;
@@ -30,6 +32,8 @@
@Component
public class AuthenticatorsRegistry
{
+ private static final Logger log = Log.getLogger(Log.U_SERVER, AuthenticatorsRegistry.class);
+
private Map<String, CredentialRetrievalFactory> credentialRetrievalFactories;
private Map<String, CredentialVerificatorFactory> credentialVerificatorFactories;
@@ -59,7 +63,7 @@
}
-
+ log.debug("The following authenticator types are available:");
for (int j=0; j<verificatorFactories.size(); j++)
{
CredentialVerificatorFactory vf = verificatorFactories.get(j);
@@ -85,6 +89,7 @@
authenticatorsByBinding.put(rf.getSupportedBinding(), existing);
}
existing.add(desc);
+ log.debug(" - " + desc);
authenticatorsById.put(desc.getId(), desc);
}
}
Modified: unity/trunk/core/src/main/java/pl/edu/icm/unity/server/utils/UnityServerConfiguration.java
===================================================================
--- unity/trunk/core/src/main/java/pl/edu/icm/unity/server/utils/UnityServerConfiguration.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/core/src/main/java/pl/edu/icm/unity/server/utils/UnityServerConfiguration.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -52,12 +52,28 @@
public static final String THREAD_POOL_SIZE = "threadPoolSize";
public static final String RECREATE_ENDPOINTS_ON_STARTUP = "recreateEndpointsOnStartup";
public static final String ENDPOINTS = "endpoints.";
- public static final String ENDPOINT_DESCRIPTION = "description";
- public static final String ENDPOINT_TYPE = "type";
- public static final String ENDPOINT_CONFIGURATION = "configurationFile";
+ public static final String ENDPOINT_DESCRIPTION = "endpointDescription";
+ public static final String ENDPOINT_TYPE = "endpointType";
+ public static final String ENDPOINT_CONFIGURATION = "endpointConfigurationFile";
public static final String ENDPOINT_ADDRESS = "contextPath";
- public static final String ENDPOINT_NAME = "name";
+ public static final String ENDPOINT_NAME = "endpointName";
+ public static final String ENDPOINT_AUTHENTICATORS = "endpointAuthenticators";
+ public static final String AUTHENTICATORS = "authenticators.";
+ public static final String AUTHENTICATOR_NAME = "authenticatorName";
+ public static final String AUTHENTICATOR_TYPE = "authenticatorType";
+ public static final String AUTHENTICATOR_CREDENTIAL = "localCredential";
+ public static final String AUTHENTICATOR_VERIFICATOR_CONFIG = "verificatorConfigurationFile";
+ public static final String AUTHENTICATOR_RETRIEVAL_CONFIG = "retrievalConfigurationFile";
+
+ public static final String CREDENTIALS = "credentials.";
+ public static final String CREDENTIAL_NAME = "credentialName";
+ public static final String CREDENTIAL_TYPE = "credentialType";
+ public static final String CREDENTIAL_DESCRIPTION = "credentialDescription";
+ public static final String CREDENTIAL_CONFIGURATION = "credentialConfigurationFile";
+
+
+
@DocumentationReferenceMeta
public final static Map<String, PropertyMD> defaults=new HashMap<String, PropertyMD>();
@@ -77,14 +93,41 @@
setDescription("List of initially enabled endpoints"));
defaults.put(ENDPOINT_TYPE, new PropertyMD().setStructuredListEntry(ENDPOINTS).setMandatory().setCategory(mainCat).
setDescription("Endpoint type"));
- defaults.put(ENDPOINT_CONFIGURATION, new PropertyMD().setStructuredListEntry(ENDPOINTS).setPath().setCategory(mainCat).
+ defaults.put(ENDPOINT_CONFIGURATION, new PropertyMD().setStructuredListEntry(ENDPOINTS).setPath().setMandatory().setCategory(mainCat).
setDescription("Path of the file with JSON configuration of the endpoint"));
defaults.put(ENDPOINT_DESCRIPTION, new PropertyMD("").setStructuredListEntry(ENDPOINTS).setCategory(mainCat).
setDescription("Description of the endpoint"));
- defaults.put(ENDPOINT_ADDRESS, new PropertyMD().setStructuredListEntry(ENDPOINTS).setCategory(mainCat).
+ defaults.put(ENDPOINT_ADDRESS, new PropertyMD().setStructuredListEntry(ENDPOINTS).setMandatory().setCategory(mainCat).
setDescription("Context path of the endpoint"));
- defaults.put(ENDPOINT_NAME, new PropertyMD().setStructuredListEntry(ENDPOINTS).setCategory(mainCat).
+ defaults.put(ENDPOINT_NAME, new PropertyMD().setStructuredListEntry(ENDPOINTS).setMandatory().setCategory(mainCat).
setDescription("Endpoint name"));
+ defaults.put(ENDPOINT_AUTHENTICATORS, new PropertyMD().setStructuredListEntry(ENDPOINTS).setMandatory().setCategory(mainCat).
+ setDescription("Endpoint authenticator names: each set is separated with ';' and particular authenticators in each set with ','."));
+
+ defaults.put(AUTHENTICATORS, new PropertyMD().setStructuredList(true).setCategory(mainCat).
+ setDescription("List of initially enabled authenticators"));
+ defaults.put(AUTHENTICATOR_NAME, new PropertyMD().setStructuredListEntry(AUTHENTICATORS).setMandatory().setCategory(mainCat).
+ setDescription("Authenticator name"));
+ defaults.put(AUTHENTICATOR_TYPE, new PropertyMD().setStructuredListEntry(AUTHENTICATORS).setMandatory().setCategory(mainCat).
+ setDescription("Authenticator type"));
+ defaults.put(AUTHENTICATOR_CREDENTIAL, new PropertyMD().setStructuredListEntry(AUTHENTICATORS).setCategory(mainCat).
+ setDescription("For local authenticator the name of the local credential associated with it."));
+ defaults.put(AUTHENTICATOR_VERIFICATOR_CONFIG, new PropertyMD().setStructuredListEntry(AUTHENTICATORS).setCategory(mainCat).
+ setDescription("Authenticator configuration file of the verificator"));
+ defaults.put(AUTHENTICATOR_RETRIEVAL_CONFIG, new PropertyMD().setStructuredListEntry(AUTHENTICATORS).setMandatory().setCategory(mainCat).
+ setDescription("Authenticator configuration file of the retrieval"));
+
+ defaults.put(CREDENTIALS, new PropertyMD().setStructuredList(true).setCategory(mainCat).
+ setDescription("List of initially defined credentials"));
+ defaults.put(CREDENTIAL_NAME, new PropertyMD().setStructuredListEntry(CREDENTIALS).setMandatory().setCategory(mainCat).
+ setDescription("Credential name"));
+ defaults.put(CREDENTIAL_TYPE, new PropertyMD().setStructuredListEntry(CREDENTIALS).setMandatory().setCategory(mainCat).
+ setDescription("Credential type"));
+ defaults.put(CREDENTIAL_DESCRIPTION, new PropertyMD("").setStructuredListEntry(CREDENTIALS).setCategory(mainCat).
+ setDescription("Credential description"));
+ defaults.put(CREDENTIAL_CONFIGURATION, new PropertyMD().setStructuredListEntry(CREDENTIALS).setMandatory().setCategory(mainCat).
+ setDescription("Credential configuration file"));
+
defaults.put(TruststoreProperties.DEFAULT_PREFIX, new PropertyMD().setCanHaveSubkeys().setCategory(otherCat).
setDescription("Properties starting with this prefix are used to configure server's trust settings and certificate validation. See separate documentation for details."));
Added: unity/trunk/distribution/src/test/resources/empty.json
===================================================================
Added: unity/trunk/distribution/src/test/resources/passwordDef.json
===================================================================
--- unity/trunk/distribution/src/test/resources/passwordDef.json (rev 0)
+++ unity/trunk/distribution/src/test/resources/passwordDef.json 2013-03-28 16:41:27 UTC (rev 16184)
@@ -0,0 +1,7 @@
+{
+ "minLength": 8,
+ "historySize": 5,
+ "minClassesNum": 3,
+ "denySequences": true,
+ "maxAge": 30758400
+}
\ No newline at end of file
Modified: unity/trunk/distribution/src/test/resources/unityServer.conf
===================================================================
--- unity/trunk/distribution/src/test/resources/unityServer.conf 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/distribution/src/test/resources/unityServer.conf 2013-03-28 16:41:27 UTC (rev 16184)
@@ -23,10 +23,32 @@
#######################################
+# Credential definitions
+#######################################
+
+unityServer.core.credentials.1.credentialName=secured password
+unityServer.core.credentials.1.credentialType=password
+unityServer.core.credentials.1.credentialDescription=Highly secure password
+unityServer.core.credentials.1.credentialConfigurationFile=src/test/resources/passwordDef.json
+
+
+#######################################
+# Authenticators
+#######################################
+
+unityServer.core.authenticators.1.authenticatorName=password web authenticator
+unityServer.core.authenticators.1.authenticatorType=password with web-password
+unityServer.core.authenticators.1.localCredential=secured password
+#unityServer.core.authenticators.1.verificatorConfigurationFile=src/test/resources/empty.json
+unityServer.core.authenticators.1.retrievalConfigurationFile=src/test/resources/empty.json
+
+
+#######################################
# Endpoints
#######################################
-unityServer.core.endpoints.1.type=WebAdminUI
-unityServer.core.endpoints.1.configurationFile=src/test/resources/webadmin.json
+unityServer.core.endpoints.1.endpointType=WebAdminUI
+unityServer.core.endpoints.1.endpointConfigurationFile=src/test/resources/webadmin.json
unityServer.core.endpoints.1.contextPath=/admin
-unityServer.core.endpoints.1.name=Admin UI 1
+unityServer.core.endpoints.1.endpointName=Admin UI 1
+unityServer.core.endpoints.1.endpointAuthenticators=password web authenticator
Modified: unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/authn/AuthenticatorImpl.java
===================================================================
--- unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/authn/AuthenticatorImpl.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/authn/AuthenticatorImpl.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -40,7 +40,7 @@
private IdentityResolver identitiesResolver;
/**
- * For initial object creation
+ * For initial object creation. Verificator configuration is only required for remote verificators.
* @param reg
* @param typeId
* @param configuration
@@ -75,7 +75,8 @@
authDesc.getVerificationMethod());
verificator = verificatorFact.newInstance();
verificator.setIdentityResolver(identitiesResolver);
- verificator.setSerializedConfiguration(vConfiguration);
+ if (vConfiguration != null)
+ verificator.setSerializedConfiguration(vConfiguration);
retrieval = retrievalFact.newInstance();
retrieval.setSerializedConfiguration(rConfiguration);
retrieval.setCredentialExchange(verificator);
@@ -88,9 +89,8 @@
public void setConfiguration(String rConfiguration, String vConfiguration)
{
retrieval.setSerializedConfiguration(rConfiguration);
- verificator.setSerializedConfiguration(vConfiguration);
instanceDescription.setRetrievalJsonConfiguration(rConfiguration);
- instanceDescription.setVerificatorJsonConfiguration(vConfiguration);
+ setVerificatorConfiguration(vConfiguration);
}
public void setCredentialName(String credential)
@@ -102,6 +102,18 @@
}
}
+ /**
+ * Local verificators has configuration provided by a credential definition, the
+ * configuration for the authenticator is ignored. It must be set via this method
+ * @param configuration
+ */
+ public void setVerificatorConfiguration(String vConfiguration)
+ {
+ verificator.setSerializedConfiguration(vConfiguration);
+ instanceDescription.setVerificatorJsonConfiguration(vConfiguration);
+ }
+
+
@Override
public String getSerializedConfiguration()
{
Modified: unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/internal/EngineHelper.java
===================================================================
--- unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/internal/EngineHelper.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/internal/EngineHelper.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -183,7 +183,8 @@
AuthenticationManagementImpl.AUTHENTICATOR_OBJECT_TYPE, sql);
if (raw == null)
throw new pl.edu.icm.unity.exceptions.IllegalArgumentException("The authenticator " + id + " is not known");
- return getAuthenticatorNoCheck(raw, sql);
+ AuthenticatorImpl ret = getAuthenticatorNoCheck(raw, sql);
+ return ret;
}
public AuthenticatorImpl getAuthenticatorNoCheck(GenericObjectBean raw, SqlSession sql)
@@ -191,6 +192,19 @@
AuthenticatorImpl authenticator = new AuthenticatorImpl(identityResolver, authReg, raw.getName());
String contents = new String(raw.getContents(), Constants.UTF);
authenticator.setSerializedConfiguration(contents);
+ String localCredential = authenticator.getAuthenticatorInstance().getLocalCredentialName();
+ if (localCredential != null)
+ {
+ GenericObjectBean rawC = dbGeneric.getObjectByNameType(localCredential,
+ AuthenticationManagementImpl.CREDENTIAL_OBJECT_TYPE, sql);
+ if (rawC == null)
+ throw new pl.edu.icm.unity.exceptions.IllegalArgumentException("The authenticator's " +
+ authenticator.getAuthenticatorInstance().getId() +
+ " credential is not known: " + localCredential);
+ CredentialHolder credential = resolveCredentialBean(rawC, sql);
+ authenticator.setVerificatorConfiguration(credential.getCredentialDefinition().
+ getJsonConfiguration());
+ }
return authenticator;
}
Modified: unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/internal/EngineInitialization.java
===================================================================
--- unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/internal/EngineInitialization.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/engine/src/main/java/pl/edu/icm/unity/engine/internal/EngineInitialization.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -9,8 +9,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
@@ -40,6 +42,7 @@
import pl.edu.icm.unity.stdext.credential.PasswordVerificatorFactory;
import pl.edu.icm.unity.stdext.identity.UsernameIdentity;
import pl.edu.icm.unity.sysattrs.SystemAttributeTypes;
+import pl.edu.icm.unity.types.authn.AuthenticatorInstance;
import pl.edu.icm.unity.types.authn.AuthenticatorSet;
import pl.edu.icm.unity.types.authn.CredentialDefinition;
import pl.edu.icm.unity.types.authn.CredentialRequirements;
@@ -159,6 +162,8 @@
initializeIdentityTypes();
initializeAttributeTypes();
initializeAdminUser();
+ initializeCredentials();
+ initializeAuthenticators();
initializeEndpoints();
}
@@ -237,6 +242,11 @@
"default credential settings");
CredentialDefinition credDef = new CredentialDefinition(PasswordVerificatorFactory.NAME,
DEFAULT_CREDENTIAL, "Default password credential with typical security settings.");
+ credDef.setJsonConfiguration("{\"minLength\": 4," +
+ "\"historySize\": 1," +
+ "\"minClassesNum\": 1," +
+ "\"denySequences\": false," +
+ "\"maxAge\": 3075840000}");
authnManagement.addCredentialDefinition(credDef);
CredentialRequirements crDef = new CredentialRequirements(DEFAULT_CREDENTIAL_REQUIREMENT,
@@ -291,7 +301,6 @@
{
if (endpointManager.getEndpoints().size() == 0)
{
- log.info("Loading all configured endpoints");
loadEndpointsFromConfiguration();
}
} catch (Exception e)
@@ -318,9 +327,9 @@
}
}
-
private void loadEndpointsFromConfiguration() throws IOException, EngineException
{
+ log.info("Loading all configured endpoints");
Set<String> endpointsList = config.getStructuredListKeys(UnityServerConfiguration.ENDPOINTS);
for (String endpointKey: endpointsList)
{
@@ -329,16 +338,109 @@
File configFile = config.getFileValue(endpointKey+UnityServerConfiguration.ENDPOINT_CONFIGURATION, false);
String address = config.getValue(endpointKey+UnityServerConfiguration.ENDPOINT_ADDRESS);
String name = config.getValue(endpointKey+UnityServerConfiguration.ENDPOINT_NAME);
+ String authenticatorsSpec = config.getValue(endpointKey+UnityServerConfiguration.ENDPOINT_AUTHENTICATORS);
+ String[] authenticatorSets = authenticatorsSpec.split(";");
+ List<AuthenticatorSet> endpointAuthn = new ArrayList<AuthenticatorSet>();
+ for (String authenticatorSet: authenticatorSets)
+ {
+ Set<String> endpointAuthnSet = new HashSet<String>();
+ String[] authenticators = authenticatorSet.split(",");
+ for (String a: authenticators)
+ endpointAuthnSet.add(a.trim());
+ endpointAuthn.add(new AuthenticatorSet(endpointAuthnSet));
+ }
+
String jsonConfiguration = FileUtils.readFileToString(configFile);
-
- //TODO authn settings
- List<AuthenticatorSet> todo = new ArrayList<AuthenticatorSet>();
- endpointManager.deploy(type, name, address, description, todo, jsonConfiguration);
+
+ endpointManager.deploy(type, name, address, description, endpointAuthn, jsonConfiguration);
log.info(" - " + name + ": " + type + " " + description);
}
}
+
+ private void initializeAuthenticators()
+ {
+ try
+ {
+ loadAuthenticatorsFromConfiguration();
+ } catch(Exception e)
+ {
+ log.fatal("Can't load authenticators which are configured", e);
+ throw new RuntimeEngineException("Can't load authenticators which are configured", e);
+ }
+ }
+ private void loadAuthenticatorsFromConfiguration() throws IOException, EngineException
+ {
+ log.info("Loading all configured authenticators");
+ Collection<AuthenticatorInstance> authenticators = authnManagement.getAuthenticators(null);
+ Map<String, AuthenticatorInstance> existing = new HashMap<String, AuthenticatorInstance>();
+ for (AuthenticatorInstance ai: authenticators)
+ existing.put(ai.getId(), ai);
+
+ Set<String> authenticatorsList = config.getStructuredListKeys(UnityServerConfiguration.AUTHENTICATORS);
+ for (String authenticatorKey: authenticatorsList)
+ {
+ String name = config.getValue(authenticatorKey+UnityServerConfiguration.AUTHENTICATOR_NAME);
+ String type = config.getValue(authenticatorKey+UnityServerConfiguration.AUTHENTICATOR_TYPE);
+ File vConfigFile = config.getFileValue(authenticatorKey+
+ UnityServerConfiguration.AUTHENTICATOR_VERIFICATOR_CONFIG, false);
+ File rConfigFile = config.getFileValue(authenticatorKey+
+ UnityServerConfiguration.AUTHENTICATOR_RETRIEVAL_CONFIG, false);
+ String credential = config.getValue(authenticatorKey+UnityServerConfiguration.AUTHENTICATOR_CREDENTIAL);
+
+
+ String vJsonConfiguration = vConfigFile == null ? null : FileUtils.readFileToString(vConfigFile);
+ String rJsonConfiguration = FileUtils.readFileToString(rConfigFile);
+
+ if (!existing.containsKey(name))
+ {
+ authnManagement.createAuthenticator(name, type, vJsonConfiguration,
+ rJsonConfiguration, credential);
+ log.info(" - " + name + " [" + type + "]");
+ }
+ }
+ }
+
+ private void initializeCredentials()
+ {
+ try
+ {
+ loadCredentialsFromConfiguration();
+ } catch(Exception e)
+ {
+ log.fatal("Can't load credentials which are configured", e);
+ throw new RuntimeEngineException("Can't load credentials which are configured", e);
+ }
+ }
+
+ private void loadCredentialsFromConfiguration() throws IOException, EngineException
+ {
+ log.info("Loading all configured credentials");
+ Collection<CredentialDefinition> definitions = authnManagement.getCredentialDefinitions();
+ Map<String, CredentialDefinition> existing = new HashMap<String, CredentialDefinition>();
+ for (CredentialDefinition cd: definitions)
+ existing.put(cd.getName(), cd);
+
+ Set<String> credentialsList = config.getStructuredListKeys(UnityServerConfiguration.CREDENTIALS);
+ for (String credentialKey: credentialsList)
+ {
+ String name = config.getValue(credentialKey+UnityServerConfiguration.CREDENTIAL_NAME);
+ String typeId = config.getValue(credentialKey+UnityServerConfiguration.CREDENTIAL_TYPE);
+ String description = config.getValue(credentialKey+UnityServerConfiguration.CREDENTIAL_DESCRIPTION);
+ File configFile = config.getFileValue(credentialKey+UnityServerConfiguration.CREDENTIAL_CONFIGURATION, false);
+
+ String jsonConfiguration = FileUtils.readFileToString(configFile);
+ CredentialDefinition credentialDefinition = new CredentialDefinition(typeId, name, description);
+ credentialDefinition.setJsonConfiguration(jsonConfiguration);
+
+ if (!existing.containsKey(name))
+ {
+ authnManagement.addCredentialDefinition(credentialDefinition);
+ log.info(" - " + name + " [" + typeId + "]");
+ }
+ }
+ }
}
Modified: unity/trunk/engine/src/test/java/pl/edu/icm/unity/engine/TestAuthentication.java
===================================================================
--- unity/trunk/engine/src/test/java/pl/edu/icm/unity/engine/TestAuthentication.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/engine/src/test/java/pl/edu/icm/unity/engine/TestAuthentication.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -91,7 +91,7 @@
//create authenticator
AuthenticatorInstance authInstance = authnMan.createAuthenticator(
- "auth1", authType.getId(), "6", "bbb", "credential1");
+ "auth1", authType.getId(), null, "bbb", "credential1");
//get authenticators
Collection<AuthenticatorInstance> auths = authnMan.getAuthenticators("web");
@@ -99,7 +99,7 @@
AuthenticatorInstance authInstanceR = auths.iterator().next();
assertEquals("auth1", authInstanceR.getId());
assertEquals("bbb", authInstanceR.getRetrievalJsonConfiguration());
- assertEquals("6", authInstanceR.getVerificatorJsonConfiguration());
+ assertEquals("8", authInstanceR.getVerificatorJsonConfiguration());
//update authenticator
authnMan.updateAuthenticator("auth1", "8", "b");
Modified: unity/trunk/engine/src/test/java/pl/edu/icm/unity/engine/mock/MockPasswordRetrieval.java
===================================================================
--- unity/trunk/engine/src/test/java/pl/edu/icm/unity/engine/mock/MockPasswordRetrieval.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/engine/src/test/java/pl/edu/icm/unity/engine/mock/MockPasswordRetrieval.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -19,12 +19,6 @@
}
@Override
- public String getBindingDescription()
- {
- return "web binding";
- }
-
- @Override
public void setCredentialExchange(CredentialExchange e)
{
if (!(e instanceof MockExchange))
Modified: unity/trunk/pom.xml
===================================================================
--- unity/trunk/pom.xml 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/pom.xml 2013-03-28 16:41:27 UTC (rev 16184)
@@ -160,6 +160,12 @@
<groupId>edu.vt.middleware</groupId>
<artifactId>vt-password</artifactId>
<version>3.1.1</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
</dependencies>
</dependencyManagement>
Modified: unity/trunk/types/src/main/java/pl/edu/icm/unity/types/authn/AuthenticatorTypeDescription.java
===================================================================
--- unity/trunk/types/src/main/java/pl/edu/icm/unity/types/authn/AuthenticatorTypeDescription.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/types/src/main/java/pl/edu/icm/unity/types/authn/AuthenticatorTypeDescription.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -77,4 +77,15 @@
{
this.retrievalMethodDescription = retrievalMethodDescription;
}
+ @Override
+ public String toString()
+ {
+ return "id=" + id + ", supportedBinding="
+ + supportedBinding + ", verificationMethod=" + verificationMethod
+ + ", verificationMethodDescription="
+ + verificationMethodDescription + ", retrievalMethod="
+ + retrievalMethod + ", retrievalMethodDescription="
+ + retrievalMethodDescription + ", local=" + local;
+ }
+
}
Modified: unity/trunk/web-common/pom.xml
===================================================================
--- unity/trunk/web-common/pom.xml 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/web-common/pom.xml 2013-03-28 16:41:27 UTC (rev 16184)
@@ -42,6 +42,11 @@
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>pl.edu.icm.unity</groupId>
+ <artifactId>unity-std-extensions</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
Added: unity/trunk/web-common/src/main/java/pl/edu/icm/unity/webui/authn/extensions/PasswordRetrieval.java
===================================================================
--- unity/trunk/web-common/src/main/java/pl/edu/icm/unity/webui/authn/extensions/PasswordRetrieval.java (rev 0)
+++ unity/trunk/web-common/src/main/java/pl/edu/icm/unity/webui/authn/extensions/PasswordRetrieval.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2013 ICM Uniwersytet Warszawski All rights reserved.
+ * See LICENCE.txt file for licensing information.
+ */
+package pl.edu.icm.unity.webui.authn.extensions;
+
+import pl.edu.icm.unity.server.authn.CredentialExchange;
+import pl.edu.icm.unity.server.authn.CredentialRetrieval;
+import pl.edu.icm.unity.webui.authn.VaadinAuthentication;
+
+/**
+ * Retrieves passwords using a Vaadin widget.
+ *
+ * @author K. Benedyczak
+ */
+public class PasswordRetrieval implements CredentialRetrieval, VaadinAuthentication
+{
+ @Override
+ public String getBindingName()
+ {
+ return VaadinAuthentication.NAME;
+ }
+
+ @Override
+ public String getSerializedConfiguration()
+ {
+ return "";
+ }
+
+ @Override
+ public void setSerializedConfiguration(String json)
+ {
+ }
+
+ @Override
+ public void setCredentialExchange(CredentialExchange e)
+ {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Modified: unity/trunk/web-common/src/main/java/pl/edu/icm/unity/webui/authn/extensions/PasswordRetrievalFactory.java
===================================================================
--- unity/trunk/web-common/src/main/java/pl/edu/icm/unity/webui/authn/extensions/PasswordRetrievalFactory.java 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/web-common/src/main/java/pl/edu/icm/unity/webui/authn/extensions/PasswordRetrievalFactory.java 2013-03-28 16:41:27 UTC (rev 16184)
@@ -9,6 +9,7 @@
import pl.edu.icm.unity.server.authn.CredentialExchange;
import pl.edu.icm.unity.server.authn.CredentialRetrieval;
import pl.edu.icm.unity.server.authn.CredentialRetrievalFactory;
+import pl.edu.icm.unity.stdext.credential.PasswordExchange;
import pl.edu.icm.unity.webui.authn.VaadinAuthentication;
/**
@@ -35,8 +36,7 @@
@Override
public CredentialRetrieval newInstance()
{
- //TODO
- return null;
+ return new PasswordRetrieval();
}
@Override
@@ -48,8 +48,7 @@
@Override
public boolean isCredentialExchangeSupported(CredentialExchange e)
{
- // TODO Auto-generated method stub
- return false;
+ return e instanceof PasswordExchange;
}
}
Modified: unity/trunk/web-common/src/main/resources/META-INF/components.xml
===================================================================
--- unity/trunk/web-common/src/main/resources/META-INF/components.xml 2013-03-28 15:51:45 UTC (rev 16183)
+++ unity/trunk/web-common/src/main/resources/META-INF/components.xml 2013-03-28 16:41:27 UTC (rev 16184)
@@ -6,7 +6,7 @@
<context:annotation-config/>
- <bean class="pl.edu.icm.unity.webui.authn.PasswordRetrievalFactory"/>
+ <bean class="pl.edu.icm.unity.webui.authn.extensions.PasswordRetrievalFactory"/>
<!-- Vaadin components - must have the prototype scope. The UI objects must also have the id set to the
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|