Skip to content

Commit

Permalink
Bug 459781 - Customizable authentication & authorization:
Browse files Browse the repository at this point in the history
Removed warnings & added javadoc
  • Loading branch information
edgarmueller committed Feb 12, 2015
1 parent 9e9a8b6 commit e1f70fc
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 93 deletions.
53 changes: 27 additions & 26 deletions bundles/org.eclipse.emf.emfstore.server/build.properties
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
bin.includes = .,\
META-INF/,\
plugin.xml,\
schema/,\
lib/org.apache.ws.commons.util_1.0.1.v20100518-1140.jar,\
lib/xmlrpc-client-3.1.3.jar,\
lib/xmlrpc-common-3.1.3.jar,\
lib/xmlrpc-server-3.1.3.jar,\
src/org/eclipse/emf/emfstore/internal/server/es.properties,\
src/org/eclipse/emf/emfstore/internal/server/emfstoreServer.keystore,\
about.ini,\
about.html,\
about.mappings,\
about.properties,\
modeling32.png,\
src/org/eclipse/emf/emfstore/internal/server/core/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/conflictDetection/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/accesscontrol/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/accesscontrol/authentication/verifiers/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/startup/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/connection/xmlrpc/messages.properties
source.. = src/
output.. = bin/
src.includes = about.html

bin.includes = .,\
META-INF/,\
plugin.xml,\
schema/,\
lib/org.apache.ws.commons.util_1.0.1.v20100518-1140.jar,\
lib/xmlrpc-client-3.1.3.jar,\
lib/xmlrpc-common-3.1.3.jar,\
lib/xmlrpc-server-3.1.3.jar,\
src/org/eclipse/emf/emfstore/internal/server/es.properties,\
src/org/eclipse/emf/emfstore/internal/server/emfstoreServer.keystore,\
about.ini,\
about.html,\
about.mappings,\
about.properties,\
modeling32.png,\
src/org/eclipse/emf/emfstore/internal/server/core/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/conflictDetection/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/accesscontrol/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/accesscontrol/authentication/verifiers/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/startup/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/connection/xmlrpc/messages.properties,\
src/org/eclipse/emf/emfstore/internal/server/accesscontrol/authentication/messages.properties
source.. = src/
output.. = bin/
src.includes = about.html

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ private void checkLastActive() throws AccessControlException {
* Integer.parseInt(property)
*/) {
// OW: delete from map
throw new SessionTimedOutException("Usersession timed out.");
throw new SessionTimedOutException(Messages.ACUserContainer_Session_Timed_Out);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,36 +48,39 @@ public static ESUserVerifierFactory getInstance() {
}

/**
* Creates an {@link ESUserVerifier} based on the given {@link ESAuthenticationControlType}.
*
* {@inheritDoc}
*
* @see org.eclipse.emf.emfstore.internal.server.accesscontrol.authentication.ESUserVerifierFactory#createUserVerifier(org.eclipse.emf.emfstore.server.auth.ESAuthenticationControlType,
* org.eclipse.emf.emfstore.server.auth.ESUserProvider)
* @param authenticationControlType
* the requested type of {@link ESUserVerifier}
* @param orgUnitProvider
* provides access to users and groups if necessary
* @return the requested {@link ESUserVerifier}
* @throws FatalESException in case no fitting {@link ESUserVerifier} can be found or the initialization fails
*/
public ESUserVerifier createUserVerifier(
ESAuthenticationControlType authenticationControlType, ESOrgUnitProvider orgUnitProvider)
throws FatalESException {
throws FatalESException {

if (authenticationControlType.equals(ESAuthenticationControlType.ldap)) {
final UserVerifierChain chain = new UserVerifierChain(orgUnitProvider);
final Properties properties = ServerConfiguration.getProperties();
int count = 1;
while (count != -1) {

final String ldapUrl = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "."
final String ldapUrl = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "." //$NON-NLS-1$
+ count
+ "." + ServerConfiguration.AUTHENTICATION_LDAP_URL);
final String ldapBase = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "."
+ "." + ServerConfiguration.AUTHENTICATION_LDAP_URL); //$NON-NLS-1$
final String ldapBase = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "." //$NON-NLS-1$
+ count
+ "." + ServerConfiguration.AUTHENTICATION_LDAP_BASE);
final String searchDn = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "."
+ "." + ServerConfiguration.AUTHENTICATION_LDAP_BASE); //$NON-NLS-1$
final String searchDn = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "." //$NON-NLS-1$
+ count
+ "." + ServerConfiguration.AUTHENTICATION_LDAP_SEARCHDN);
final String authUser = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "."
+ "." + ServerConfiguration.AUTHENTICATION_LDAP_SEARCHDN); //$NON-NLS-1$
final String authUser = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "." //$NON-NLS-1$
+ count
+ "." + ServerConfiguration.AUTHENTICATION_LDAP_AUTHUSER);
final String authPassword = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "."
+ count + "." + ServerConfiguration.AUTHENTICATION_LDAP_AUTHPASS);
+ "." + ServerConfiguration.AUTHENTICATION_LDAP_AUTHUSER); //$NON-NLS-1$
final String authPassword = properties.getProperty(ServerConfiguration.AUTHENTICATION_LDAP_PREFIX + "." //$NON-NLS-1$
+ count + "." + ServerConfiguration.AUTHENTICATION_LDAP_AUTHPASS); //$NON-NLS-1$

if (ldapUrl != null && ldapBase != null && searchDn != null) {
final LDAPUserVerifier ldapVerifier = new LDAPUserVerifier(orgUnitProvider,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Edgar Mueller - initial API and implementation
******************************************************************************/
package org.eclipse.emf.emfstore.internal.server.accesscontrol.authentication;

import org.eclipse.osgi.util.NLS;

/**
* @author emueller
* @generated
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.emf.emfstore.internal.server.accesscontrol.authentication.messages"; //$NON-NLS-1$
public static String ACUserContainer_Session_Timed_Out;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}

private Messages() {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ACUserContainer_Session_Timed_Out=Usersession timed out.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011-2013 EclipseSource Muenchen GmbH and others.
* Copyright (c) 2011-2015 EclipseSource Muenchen GmbH and others.
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
Expand All @@ -22,8 +22,14 @@
*/
public class EMFModelUserVerifier extends UserVerifier {

public EMFModelUserVerifier(ESOrgUnitProvider userProvider) {
super(userProvider);
/**
* Constructor.
*
* @param orgUnitProvider
* provides access to users and groups
*/
public EMFModelUserVerifier(ESOrgUnitProvider orgUnitProvider) {
super(orgUnitProvider);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
import org.eclipse.emf.emfstore.internal.common.model.util.ModelUtil;
import org.eclipse.emf.emfstore.internal.server.connection.ServerKeyStoreManager;
import org.eclipse.emf.emfstore.internal.server.exceptions.AccessControlException;
import org.eclipse.emf.emfstore.server.auth.ESUserVerifier;
import org.eclipse.emf.emfstore.server.model.ESClientVersionInfo;
import org.eclipse.emf.emfstore.server.model.ESOrgUnitProvider;

/**
Expand All @@ -48,7 +46,10 @@ public class LDAPUserVerifier extends UserVerifier {
/**
* Default constructor.
*
* @param ldapUrl url, if url starts with ldaps:// SSL is used.
* @param orgUnitProvider
* provides access to users and groups
* @param ldapUrl
* URL, if URLstarts with ldaps:// SSL is used.
* @param ldapBase base
* @param searchDn dn
* @param authUser user to allow access to server
Expand All @@ -72,8 +73,8 @@ public LDAPUserVerifier(ESOrgUnitProvider orgUnitProvider,

/**
* This method must be implemented by subclasses in order to verify a pair of username and password.
* When using authentication you should use {@link ESUserVerifier#logIn(String, String, ESClientVersionInfo)} in
* order to gain a session id.
* When using authentication you should use {@link org.eclipse.emf.emfstore.server.auth.ESUserVerifier
* ESUserVerifier#verifyUser(String, String, ESClientVersionInfo)} in order to gain a session id.
*
* @param username
* the user name as entered by the client; may differ from the user name of the {@code resolvedUser}
Expand All @@ -83,7 +84,6 @@ public LDAPUserVerifier(ESOrgUnitProvider orgUnitProvider,
* @throws AccessControlException
* if an exception occurs during the verification process
*/
// TODO: introduce common interface verifying passwords
@Override
public boolean verifyPassword(String username, String password) throws AccessControlException {
DirContext dirContext = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
import java.util.Properties;

import org.eclipse.emf.emfstore.internal.common.model.util.ModelUtil;
import org.eclipse.emf.emfstore.internal.server.accesscontrol.authentication.verifiers.SimplePropertyFileUserVerifier.Hash;
import org.eclipse.emf.emfstore.internal.server.exceptions.AccessControlException;
import org.eclipse.emf.emfstore.internal.server.exceptions.FatalESException;
import org.eclipse.emf.emfstore.server.model.ESOrgUnitProvider;
import org.eclipse.emf.emfstore.server.model.ESSessionId;
import org.eclipse.emf.emfstore.server.model.ESUser;

/**
* This verifier can be used to store user and passwords in a property file. Entries in the property file look should
Expand Down Expand Up @@ -55,32 +52,38 @@ public enum Hash {
/**
* Default constructor. No hash will be used for passwords
*
* @see #SimplePropertyFileUserVerifier(String, Hash)
* @param filePath path to password file
* @param orgUnitProvider
* provides access to users and groups
* @param propertyFilePath
* path to file
* @throws FatalESException in case of failure
*/
public SimplePropertyFileUserVerifier(ESOrgUnitProvider orgUnitProvider, String filePath) throws FatalESException {
this(orgUnitProvider, filePath, Hash.NONE);
public SimplePropertyFileUserVerifier(ESOrgUnitProvider orgUnitProvider, String propertyFilePath) throws FatalESException {
this(orgUnitProvider, propertyFilePath, Hash.NONE);
}

/**
* Constructor with ability to select hash algorithm for password.
*
* @param filePath path to file
* @param hash selected hash
* @param orgUnitProvider
* provides access to users and groups
* @param propertyFilePath
* path to file
* @param hash
* selected hash
* @throws FatalESException if hash is null
*/
public SimplePropertyFileUserVerifier(ESOrgUnitProvider orgUnitProvider, String filePath, Hash hash)
public SimplePropertyFileUserVerifier(ESOrgUnitProvider orgUnitProvider, String propertyFilePath, Hash hash)
throws FatalESException {
super(orgUnitProvider);
this.filePath = filePath;
filePath = propertyFilePath;
if (hash == null) {
throw new FatalESException(Messages.SimplePropertyFileVerifier_HashMayNotBeNull);
}
this.hash = hash;

passwordFile = new Properties();
loadPasswordFile(filePath);
loadPasswordFile(propertyFilePath);
}

private void loadPasswordFile(String filePath) {
Expand Down Expand Up @@ -148,34 +151,4 @@ private String hashPassword(String password) {

return null;
}

/**
* {@inheritDoc}
*
* @see org.eclipse.emf.emfstore.server.auth.ESUserVerifier#resolve(org.eclipse.emf.emfstore.server.model.ESSessionId)
*/
public ESUser resolve(ESSessionId api) {
// TODO Auto-generated method stub
return null;
}

/**
* {@inheritDoc}
*
* @see org.eclipse.emf.emfstore.server.auth.ESUserVerifier#isValid(org.eclipse.emf.emfstore.server.model.ESSessionId)
*/
public boolean isValid(ESSessionId sessionId) {
// TODO Auto-generated method stub
return false;
}

/**
* {@inheritDoc}
*
* @see org.eclipse.emf.emfstore.server.auth.ESUserVerifier#getUser(org.eclipse.emf.emfstore.server.model.ESSessionId)
*/
public ESUser getUser(ESSessionId sessionId) {
// TODO Auto-generated method stub
return null;
}
}

0 comments on commit e1f70fc

Please sign in to comment.