You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airavata.apache.org by la...@apache.org on 2011/09/20 22:44:31 UTC
svn commit: r1173350 - in
/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api:
impl/ user/
Author: lahiru
Date: Tue Sep 20 20:44:30 2011
New Revision: 1173350
URL: http://svn.apache.org/viewvc?rev=1173350&view=rev
Log:
applying samindas patch for https://issues.apache.org/jira/browse/AIRAVATA-104.
Added:
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Authorizable.java
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/AuthorizableExistsException.java
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Group.java
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/User.java
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManager.java
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManagerFactory.java
Modified:
incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
Modified: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java?rev=1173350&r1=1173349&r2=1173350&view=diff
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java (original)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/impl/JCRRegistry.java Tue Sep 20 20:44:30 2011
@@ -40,6 +40,8 @@ import javax.jcr.SimpleCredentials;
import javax.jcr.Value;
import org.apache.airavata.registry.api.Axis2Registry;
+import org.apache.airavata.registry.api.user.UserManager;
+import org.apache.airavata.registry.api.user.UserManagerFactory;
import org.apache.airavata.commons.gfac.type.ApplicationDeploymentDescription;
import org.apache.airavata.commons.gfac.type.HostDescription;
import org.apache.airavata.commons.gfac.type.ServiceDescription;
@@ -60,7 +62,8 @@ public class JCRRegistry implements Axis
private Repository repository;
private Credentials credentials;
-
+ private UserManager userManager;
+
private static Log log = LogFactory.getLog(JCRRegistry.class);
public JCRRegistry(String className, String user, String pass,
@@ -78,7 +81,7 @@ public class JCRRegistry implements Axis
repository = repositoryFactory.getRepository(map);
credentials = new SimpleCredentials(user,
new String(pass).toCharArray());
-
+ userManager = UserManagerFactory.getUserManager(className);
} catch (ClassNotFoundException e) {
log.error("Error class path settting", e);
} catch (RepositoryException e) {
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Authorizable.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Authorizable.java?rev=1173350&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Authorizable.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Authorizable.java Tue Sep 20 20:44:30 2011
@@ -0,0 +1,168 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.airavata.registry.api.user;
+
+import java.security.Principal;
+import java.util.Iterator;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Value;
+
+/**
+ * The Authorizable is the common base interface for {@link User} and
+ * {@link Group}. It provides access to the <code>Principal</code>s associated
+ * with an <code>Authorizable</code> (see below) and allow to access and
+ * modify additional properties such as e.g. full name, e-mail or address.
+ * <p/>
+ * <p/>
+ * Please note the difference between <code>Authorizable</code> and
+ * {@link java.security.Principal Principal}:<br>
+ * An <code>Authorizable</code> is repository object that is neither associated
+ * with nor depending from a particular <code>Session</code> and thus independant
+ * of the login mechanisms creating <code>Session</code>s.<br>
+ * <p/>
+ * On the other hand <code>Principal</code>s are representations of user
+ * identities. In other words: each <code>Principal</code> within the set
+ * associated with the Session's Subject upon login represents an identity for
+ * that user. An the set of <code>Principal</code>s may differ between different
+ * login mechanisms.<br>
+ * <p/>
+ * Consequently an one-to-many relationship exists between Authorizable
+ * and Principal (see also {@link #getPrincipal()}.
+ * <p/>
+ * <p/>
+ * The interfaces derived from Authorizable are defined as follows:
+ * <ul>
+ * <li>{@link User}: defined to be an authorizable that can be authenticated
+ * (by using Credentials) and impersonated.</li>
+ * <li>{@link Group}: defined to be a collection of other
+ * <code>Authorizable</code>s.</li>
+ * </ul>
+ *
+ * @see User
+ * @see Group
+ */
+public interface Authorizable {
+
+ /**
+ * Return the implementation specific identifer for this
+ * <code>Authorizable</code>. It could e.g. be a UserID or simply the
+ * principal name.
+ *
+ * @return Name of this <code>Authorizable</code>.
+ * @throws RepositoryException if an error occurs.
+ */
+ String getID() throws RepositoryException;
+
+ /**
+ * @return if the current Authorizable is a {@link Group}
+ */
+ boolean isGroup();
+
+ /**
+ * @return a representation as Principal.
+ * @throws RepositoryException If an error occurs.
+ */
+ Principal getPrincipal() throws RepositoryException;
+
+ /**
+ * @return all {@link Group}s, this Authorizable is declared member of.
+ * @throws RepositoryException If an error occurs.
+ */
+ Iterator<Group> declaredMemberOf() throws RepositoryException;
+
+ /**
+ * @return all {@link Group}s, this Authorizable is member of included
+ * indirect group membership.
+ * @throws RepositoryException If an error occurs.
+ */
+ Iterator<Group> memberOf() throws RepositoryException;
+
+ /**
+ * Removes this <code>Authorizable</code>, if the session has sufficient
+ * permissions. Note, that removing an <code>Authorizable</code> even
+ * if it listed as member of a Group or if still has members (this is
+ * a Group itself).
+ *
+ * @throws RepositoryException If an error occured and the
+ * <code>Authorizable</code> could not be removed.
+ */
+ void remove() throws RepositoryException;
+
+ /**
+ * Returns the names of properties present with <code>this</code> Authorizable.
+ *
+ * @return names of properties.
+ * @throws RepositoryException If an error occurs.
+ * @see #getProperty(String)
+ * @see #hasProperty(String)
+ */
+ Iterator<String> getPropertyNames() throws RepositoryException;
+
+ public Iterator<String> getPropertyNames(String name) throws RepositoryException;
+
+ /**
+ * Tests if a the property with specified name exists.
+ *
+ * @param name The name of the property to be tested.
+ * @return <code>true</code> if a property with the given name exists.
+ * @throws RepositoryException If an error occurs.
+ * @see #getProperty(String)
+ */
+ boolean hasProperty(String name) throws RepositoryException;
+
+ /**
+ * Set an arbitrary property to this <code>Authorizable</code>.
+ *
+ * @param name The name of the property to be added or modified.
+ * @param value The desired value.
+ * @throws RepositoryException If the specified property could not be set.
+ */
+ void setProperty(String name, Value value)
+ throws RepositoryException;
+
+ /**
+ * Set an arbitrary property to this <code>Authorizable</code>.
+ *
+ * @param name The name of the property to be added or modified.
+ * @param value The desired property values.
+ * @throws RepositoryException If the specified property could not be set.
+ */
+ void setProperty(String name, Value[] value)
+ throws RepositoryException;
+
+ /**
+ * Returns the values for the properties with the specified name or
+ * <code>null</code>.
+ *
+ * @param name The name of the property to be retrieved.
+ * @return value of the property with the given name or <code>null</code>
+ * if no such property exists.
+ * @throws RepositoryException If an error occurs.
+ */
+ Value[] getProperty(String name) throws RepositoryException;
+
+ /**
+ * Removes the property with the given name.
+ *
+ * @param name The name of the property to be removed.
+ * @return true If the property with the specified name was successfully
+ * removed; false if no such property was present.
+ * @throws RepositoryException If an error occurs.
+ */
+ boolean removeProperty(String name) throws RepositoryException;
+}
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/AuthorizableExistsException.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/AuthorizableExistsException.java?rev=1173350&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/AuthorizableExistsException.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/AuthorizableExistsException.java Tue Sep 20 20:44:30 2011
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.airavata.registry.api.user;
+
+import javax.jcr.RepositoryException;
+
+/**
+ * AuthorizableExistsException
+ */
+public class AuthorizableExistsException extends RepositoryException {
+
+ /**
+ * Serial version UID.
+ */
+ private static final long serialVersionUID = 7875416346848889564L;
+
+ public AuthorizableExistsException(String msg) {
+ super(msg);
+ }
+
+}
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Group.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Group.java?rev=1173350&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Group.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/Group.java Tue Sep 20 20:44:30 2011
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.airavata.registry.api.user;
+
+import javax.jcr.RepositoryException;
+import java.util.Iterator;
+
+/**
+ * A Group is a collection of {@link #getMembers() Authorizable}s.
+ */
+public interface Group extends Authorizable {
+
+ /**
+ * @return Iterator of <code>Authorizable</code>s which are declared
+ * members of this Group.
+ * @throws RepositoryException If an error occurs.
+ */
+ Iterator<Authorizable> getDeclaredMembers()
+ throws RepositoryException;
+
+ /**
+ * @return Iterator of <code>Authorizable</code>s which are members of
+ * this Group. This includes both declared members and all authorizables
+ * that are indirect group members.
+ * @throws RepositoryException If an error occurs.
+ */
+ Iterator<Authorizable> getMembers() throws RepositoryException;
+
+ /**
+ * @param authorizable The <code>Authorizable</code> to test.
+ * @return true if the Authorizable to test is a direct or indirect member
+ * of this Group.
+ * @throws RepositoryException If an error occurs.
+ */
+ boolean isMember(Authorizable authorizable)
+ throws RepositoryException;
+
+ /**
+ * Add a member to this Group.
+ *
+ * @param authorizable The <code>Authorizable</code> to be added as
+ * member to this group.
+ * @return true if the <code>Authorizable</code> has successfully been added
+ * to this Group, false otherwise (e.g. unknown implemention
+ * or if it already is a member or if the passed authorizable is this
+ * group itself or for some implementation specific constraint).
+ * @throws RepositoryException If an error occurs.
+ */
+ boolean addMember(Authorizable authorizable)
+ throws RepositoryException;
+
+ /**
+ * Remove a member from this Group.
+ *
+ * @param authorizable The <code>Authorizable</code> to be removed from
+ * the list of group members.
+ * @return true if the Authorizable was successfully removed. False otherwise.
+ * @throws RepositoryException If an error occurs.
+ */
+ boolean removeMember(Authorizable authorizable)
+ throws RepositoryException;
+
+ public boolean isDeclaredMember(Authorizable authorizable) throws RepositoryException;
+}
+
+
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/User.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/User.java?rev=1173350&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/User.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/User.java Tue Sep 20 20:44:30 2011
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.airavata.registry.api.user;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Credentials;
+
+/**
+ * User is a special {@link Authorizable} that can be authenticated and
+ * impersonated.
+ *
+ * @see #getCredentials()
+ * @see #getImpersonation()
+ */
+public interface User extends Authorizable {
+
+ /**
+ * @return true if the current user represents the administrator.
+ */
+ boolean isAdmin();
+
+ /**
+ * Returns <code>Credentials</code> for this user.
+ *
+ * @return <code>Credentials</code> for this user.
+ * @throws javax.jcr.RepositoryException If an error occurs.
+ */
+ Credentials getCredentials() throws RepositoryException;
+
+// /**
+// * @return <code>Impersonation</code> for this <code>User</code>.
+// * @throws javax.jcr.RepositoryException If an error occurs.
+// */
+// Impersonation getImpersonation() throws RepositoryException;
+
+ /**
+ * Change the password of this user.
+ *
+ * @param password The new password.
+ * @throws RepositoryException If an error occurs.
+ */
+ void changePassword(String password) throws RepositoryException;
+}
\ No newline at end of file
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManager.java?rev=1173350&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManager.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManager.java Tue Sep 20 20:44:30 2011
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.airavata.registry.api.user;
+
+import javax.jcr.RepositoryException;
+import javax.jcr.Session;
+import javax.jcr.UnsupportedRepositoryOperationException;
+import java.security.Principal;
+import java.util.Iterator;
+
+
+public interface UserManager {
+
+ /**
+ * Filter flag indicating that only <code>User</code>s should be searched
+ * and returned.
+ */
+ int SEARCH_TYPE_USER = 1;
+
+ /**
+ * Filter flag indicating that only <code>Group</code>s should be searched
+ * and returned.
+ */
+ int SEARCH_TYPE_GROUP = 2;
+
+ /**
+ * Filter flag indicating that all <code>Authorizable</code>s should be
+ * searched.
+ */
+ int SEARCH_TYPE_AUTHORIZABLE = 3;
+
+ /**
+ * Get the Authorizable by its id.
+ *
+ * @param id The user or group id.
+ * @return Authorizable or <code>null</code>, if not present.
+ * @throws RepositoryException If an error occurs.
+ * @see Authorizable#getID()
+ */
+ Authorizable getAuthorizable(Session session, String id) throws RepositoryException;
+
+ /**
+ * Get the Authorizable by its main Principal.
+ *
+ * @param principal
+ * @return Authorizable or <code>null</code>, if not present.
+ * @throws RepositoryException If an error occurs.
+ */
+ Authorizable getAuthorizable(Session session, Principal principal)
+ throws RepositoryException;
+
+ /**
+ * Returns all <code>Authorizable</code>s that have
+ * {@link Authorizable#getProperty(String) property} with the given name and
+ * that Property equals the given value.
+ *
+ * @param propertyName
+ * @param value
+ * @return All <code>Authorizable</code>s that have a property with the given
+ * name exactly matching the given value.
+ * @throws RepositoryException If an error occurs.
+ * @see Authorizable#getProperty(String)
+ */
+ Iterator<Authorizable> findAuthorizables(Session session, String propertyName,
+ String value) throws RepositoryException;
+
+ /**
+ * Returns all <code>Authorizable</code>s that have
+ * {@link Authorizable#getProperty(String) property} with the given name and
+ * that Property equals the given value. In contrast to
+ * {@link #findAuthorizables(String, String)} the type of authorizable is
+ * respected while executing the search.
+ *
+ * @param propertyName
+ * @param value
+ * @param searchType Any of the following constants:
+ * <ul>
+ * <li>{@link #SEARCH_TYPE_AUTHORIZABLE}</li>
+ * <li>{@link #SEARCH_TYPE_GROUP}</li>
+ * <li>{@link #SEARCH_TYPE_USER}</li>
+ * </ul>
+ * @return An iterator of <code>Authorizable</code>.
+ * @throws RepositoryException If an error occurs.
+ */
+ Iterator<Authorizable> findAuthorizables(Session session, String propertyName,
+ String value, int searchType) throws RepositoryException;
+
+ /**
+ * Creates an User for the given userID / password pair; neither of the
+ * specified parameters can be <code>null</code>.<br>
+ * Same as {@link #createUser(String,String,Principal,String)} where
+ * the specified userID is equal to the principal name and the intermediate
+ * path is <code>null</code>.
+ *
+ * @param userID The id of the new user.
+ * @param password The initial password of this user.
+ * @return The new <code>User</code>.
+ * @throws AuthorizableExistsException in case the given userID is already
+ * in use or another Authorizable with the same principal name exists.
+ * @throws RepositoryException If another error occurs.
+ */
+ User createUser(Session session, String userID, String password)
+ throws AuthorizableExistsException, RepositoryException;
+
+ /**
+ * Creates an User for the given parameters. If the implementation is not
+ * able to deal with the <code>intermediatePath</code> that parameter should
+ * be ignored.
+ * Except for the <code>intermediatePath</code>, neither of the specified
+ * parameters can be <code>null</code>.
+ *
+ * @param userID
+ * @param password
+ * @param principal
+ * @param intermediatePath
+ * @return The new <code>User</code>.
+ * @throws AuthorizableExistsException in case the given userID is already
+ * in use or another Authorizable with the same principal name exists.
+ * @throws RepositoryException If the current Session is
+ * not allowed to create users or some another error occurs.
+ */
+ User createUser(Session session, String userID, String password,
+ Principal principal, String intermediatePath)
+ throws AuthorizableExistsException, RepositoryException;
+
+ /**
+ * Creates a new <code>Group</code> that is based on the given principal.
+ * Note that the group's ID is implementation specific. The implementation
+ * may take the principal name as ID hint but must in any case assert that
+ * it is unique among the IDs known to this manager.
+ *
+ * @param principal A non-null <code>Principal</code>
+ * @return The new <code>Group</code>.
+ * @throws AuthorizableExistsException in case the given principal is already
+ * in use with another Authorizable.
+ * @throws RepositoryException If another error occurs.
+ */
+ Group createGroup(Session session, Principal principal)
+ throws AuthorizableExistsException, RepositoryException;
+
+ /**
+ * Creates a new <code>Group</code> that is based on the given principal
+ * and the specified <code>itermediatePath</code> hint. If the implementation
+ * is not able to deal with the <code>itermediatePath</code> this parameter
+ * should be ignored.
+ *
+ * @param principal
+ * @param intermediatePath
+ * @return The new <code>Group</code>.
+ * @throws AuthorizableExistsException in case the given principal is already
+ * in use with another Authorizable.
+ * @throws RepositoryException If another error occurs.
+ */
+ Group createGroup(Session session, Principal principal, String intermediatePath)
+ throws AuthorizableExistsException, RepositoryException;
+
+ /**
+ * If any write operations executed through the User API are automatically
+ * persisted this method returns <code>true</code>. In this case there are
+ * no pending transient changes left and there is no need to explicitely call
+ * {@link javax.jcr.Session#save()}. If this method returns <code>false</code>
+ * any changes must be completed by an extra save call on the
+ * <code>Session</code> associated with this <code>UserManager</code>.
+ *
+ * @return <code>true</code> if changes are automatically persisted;
+ * <code>false</code> if changes made through this API (including method
+ * calls on {@link Authorizable} and subclasses are only transient and
+ * must be persisted using {@link javax.jcr.Session#save()}.
+ * @throws RepositoryException
+ * @see #autoSave(boolean)
+ */
+ boolean isAutoSave(Session session) throws RepositoryException;
+
+ /**
+ * Changes the auto save behavior of this <code>UserManager</code>.
+ * <p/>
+ * Note, that this shouldn't be allowed in cases where the associated session
+ * is different from the original session accessing the user manager.
+ *
+ * @param enable If <code>true</code> changes made through this API will
+ * be automatically saved; otherwise an explict call to
+ * {@link javax.jcr.Session#save()} is required in order to persist changes.
+ * @throws UnsupportedRepositoryOperationException If the implementation
+ * does not allow to change the auto save behavior.
+ * @throws RepositoryException If some other error occurs.
+ */
+ void autoSave(Session session, boolean enable)
+ throws UnsupportedRepositoryOperationException,
+ RepositoryException;
+}
\ No newline at end of file
Added: incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManagerFactory.java
URL: http://svn.apache.org/viewvc/incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManagerFactory.java?rev=1173350&view=auto
==============================================================================
--- incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManagerFactory.java (added)
+++ incubator/airavata/trunk/modules/commons/registry-api/src/main/java/org/apache/airavata/registry/api/user/UserManagerFactory.java Tue Sep 20 20:44:30 2011
@@ -0,0 +1,37 @@
+package org.apache.airavata.registry.api.user;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+public class UserManagerFactory {
+ private static Map<String,String> userManagers=new HashMap<String, String>();
+ private static Log log = LogFactory.getLog(UserManagerFactory.class);
+
+ public static UserManager getUserManager(String userManagerKey) throws Exception{
+ if (userManagers.containsKey(userManagerKey)){
+ String userManagerClass = userManagers.get(userManagerKey);
+ try {
+ return (UserManager)Class.forName(userManagerClass).newInstance();
+ } catch (Exception e) {
+ log.error("Error retrieving user manager for key "+userManagerKey,e);
+ throw e;
+ }
+ }
+ return null;
+ }
+
+ public static void registerUserManager(String userManagerKey, String userManagerClassName){
+ userManagers.put(userManagerKey, userManagerClassName);
+ }
+
+ public static void registerUserManager(String userManagerKey, Class<?> userManagerClass){
+ registerUserManager(userManagerKey,userManagerClass.getCanonicalName());
+ }
+
+ public static void registerUserManager(String userManagerKey, UserManager userManagerObj){
+ registerUserManager(userManagerKey, userManagerObj.getClass());
+ }
+}