You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by sb...@apache.org on 2012/07/24 03:32:29 UTC

[18/20] git commit: Initial prototype

Initial prototype


Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/8ac4f62d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/8ac4f62d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/8ac4f62d

Branch: refs/heads/master
Commit: 8ac4f62d6ad5a5aeeb80ee186dc5f5fc5bad6d3d
Parents: c32050e
Author: Boleslaw Dawidowicz <bo...@gmail.com>
Authored: Mon Apr 23 22:41:21 2012 +0200
Committer: Shane Bryzak <sb...@gmail.com>
Committed: Tue Jul 24 09:56:36 2012 +1000

----------------------------------------------------------------------
 .../apache/deltaspike/security/api/idm/Group.java  |  166 ++++++++++++
 .../deltaspike/security/api/idm/GroupQuery.java    |   79 ++++++
 .../security/api/idm/IdentityManager.java          |  102 ++++++++
 .../security/api/idm/IdentityObject.java           |   27 ++
 .../deltaspike/security/api/idm/Membership.java    |   34 +++
 .../security/api/idm/MembershipQuery.java          |   64 +++++
 .../apache/deltaspike/security/api/idm/Range.java  |   63 +++++
 .../apache/deltaspike/security/api/idm/Role.java   |  106 ++++++++
 .../deltaspike/security/api/idm/RoleQuery.java     |   69 +++++
 .../apache/deltaspike/security/api/idm/User.java   |  162 ++++++++++++
 .../deltaspike/security/api/idm/UserQuery.java     |   97 +++++++
 .../deltaspike/security/spi/idm/IdentityStore.java |  203 +++++++++++++++
 12 files changed, 1172 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Group.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Group.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Group.java
new file mode 100644
index 0000000..574cfed
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Group.java
@@ -0,0 +1,166 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * Group representation
+ */
+public interface Group extends IdentityObject
+{
+    //TODO: Javadocs
+    //TODO: Exceptions
+
+    //TODO: getId() -> getPath()? Should it stick to natural Id(path) or have non meaningful one
+
+    // Self related
+
+    /**
+     * Groups are stored in tree hierarchy and therefore ID represents a path. ID string always
+     * begins with "/" element that represents root of the tree
+     * <p/>
+     * Example: Valid IDs are "/acme/departments/marketing", "/security/administrator" or "/administrator".
+     * Where "acme", "departments", "marketing", "security" and "administrator" are group names.
+     *
+     * @return Group Id in String representation.
+     */
+    String getId();
+
+    /**
+     * @return group name
+     */
+    String getName();
+
+
+    // Sub groups
+
+    /**
+     * @return parent group or null if it refers to root ("/") in a group tree.
+     */
+    Group getParentGroup();
+
+    /**
+     * Creates a new child group.
+     *
+     * @param name
+     */
+    void createChildGroup(String name);
+
+    /**
+     * Removes child group
+     *
+     * @param group
+     */
+    void removeChildGroup(Group group);
+
+
+    /**
+     * Removes child group
+     *
+     * @param name
+     */
+    void removeChildGroup(String name);
+
+    /**
+     * @return child group. Only groups that exist one level below in the tree will be returned.
+     */
+    Collection<Group> getChildGroups();
+
+
+    // Roles
+
+
+    void addRole(Role role, User user);
+
+    void addRole(String role, String user);
+
+    void removeRole(Role role, User user);
+
+    void removeRole(String role, String user);
+
+    Collection<Role> getRoles(User user);
+
+    Collection<Role> getRoles(String user);
+
+    Collection<User> getUsers(User user);
+
+    Collection<User> getUsers(String user);
+
+    Collection<User> getUsersWithRole(Role role);
+
+    Collection<User> getUsersWithRole(String role);
+
+    Map<Role, Set<User>> getMembershipsMap();
+
+    Collection<Membership> getMemberships();
+
+    boolean hasRole(Role role, User user);
+
+    boolean hasRole(String role, String user);
+
+
+    // Attributes
+
+    /**
+     * Set attribute with given name and value. Operation will overwrite any previous value.
+     * Null value will remove attribute.
+     *
+     * @param name  of attribute
+     * @param value to be set
+     */
+    void setAttribute(String name, String value);
+
+    /**
+     * Set attribute with given name and values. Operation will overwrite any previous values.
+     * Null value or empty array will remove attribute.
+     *
+     * @param name   of attribute
+     * @param values to be set
+     */
+    void setAttribute(String name, String[] values);
+
+    /**
+     * Remove attribute with given name
+     *
+     * @param name of attribute
+     */
+    void removeAttribute(String name);
+
+    /**
+     * @param name of attribute
+     * @return attribute values or null if attribute with given name doesn't exist. If given attribute has many values
+     *         method will return first one
+     */
+    String getAttribute(String name);
+
+    /**
+     * @param name of attribute
+     * @return attribute values or null if attribute with given name doesn't exist
+     */
+    String[] getAttributeValues(String name);
+
+    /**
+     * @return map of attribute names and their values
+     */
+    Map<String, String[]> getAttributes();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/GroupQuery.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/GroupQuery.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/GroupQuery.java
new file mode 100644
index 0000000..e39fdc0
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/GroupQuery.java
@@ -0,0 +1,79 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * GroupQuery. All applied conditions will be resolved with logical AND.
+ */
+public interface GroupQuery
+{
+    //TODO: Javadocs
+    //TODO: Exceptions
+
+    // Operations
+
+    GroupQuery reset();
+
+    GroupQuery immutable();
+
+    List<Group> executeQuery(GroupQuery query);
+
+
+    // Conditions
+
+    GroupQuery setName(String name);
+
+    String getName();
+
+    GroupQuery setId(String id);
+
+    String getId();
+
+    GroupQuery setParentGroup(Group group);
+
+    GroupQuery setParentGroup(String groupId);
+
+    Group getParentGroup();
+
+    GroupQuery setRole(Role role);
+
+    GroupQuery setRole(String role);
+
+    Role getRole();
+
+    GroupQuery setRelatedUser(User user);
+
+    GroupQuery setRelatedUser(String user);
+
+    User getRelatedUser();
+
+    GroupQuery addAttributeFilter(String name, String[] values);
+
+    Map<String, String[]> getAttributeFilters();
+
+    GroupQuery sort(boolean ascending);
+
+    void setRange(Range range);
+
+    Range getRange();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/IdentityManager.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/IdentityManager.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/IdentityManager.java
new file mode 100644
index 0000000..1eda004
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/IdentityManager.java
@@ -0,0 +1,102 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+import java.util.Collection;
+
+/**
+ * IdentityManager
+ */
+public interface IdentityManager
+{
+    //TODO: Javadocs
+
+    //TODO: Exceptions
+
+    //TODO: control hooks & events
+
+    //TODO: linking identities
+
+
+    // User
+
+    User createUser(String name);
+
+    void removeUser(User user);
+
+    void removeUser(String name);
+
+    User getUser(String name);
+
+    Collection<User> getAllUsers();
+
+
+    // Group
+
+    Group createGroup(String id);
+
+    Group createGroup(String id, Group parent);
+
+    Group createGroup(String id, String parent);
+
+    void removeGroup(Group group);
+
+    void removeGroup(String groupId);
+
+    Group getGroup(String groupId);
+
+    Group getGroup(String groupId, Group parent);
+
+    Collection<Group> getAllGroups();
+
+
+    // Roles
+
+    Role createRole(String name);
+
+    void removeRole(Role role);
+
+    void removeRole(String name);
+
+    Role getRole(String name);
+
+    Collection<Role> getAllRoles();
+
+    Collection<Role> getRoles(User user, Group group);
+
+    Collection<Role> getRoles(String user, String groupId);
+
+    boolean hasRole(Role role, User user, Group group);
+
+    boolean hasRole(String role, String user, String groupId);
+
+
+
+
+    // Queries
+
+    UserQuery createUserQuery();
+
+    GroupQuery createGroupQuery();
+
+    RoleQuery createRoleQuery();
+
+    MembershipQuery createMembershipQuery();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/IdentityObject.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/IdentityObject.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/IdentityObject.java
new file mode 100644
index 0000000..c6528ba
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/IdentityObject.java
@@ -0,0 +1,27 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+/**
+ * IdentityObject
+ *
+ */
+public interface IdentityObject
+{
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Membership.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Membership.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Membership.java
new file mode 100644
index 0000000..f3bfb77
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Membership.java
@@ -0,0 +1,34 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+/**
+ * Membership links User, Group and Role.
+ */
+public interface Membership
+{
+    //TODO: Javadocs
+    //TODO: Exceptions
+
+    User getUser();
+
+    Group getGroup();
+
+    Role getRole();
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/MembershipQuery.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/MembershipQuery.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/MembershipQuery.java
new file mode 100644
index 0000000..7516d2a
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/MembershipQuery.java
@@ -0,0 +1,64 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+import java.util.List;
+
+/**
+ * MembershipQuery. All applied conditions will be resolved with logical AND.
+ */
+public interface MembershipQuery
+{
+    //TODO: Javadocs
+    //TODO: Exceptions
+
+    // Operations
+
+    MembershipQuery reset();
+
+    MembershipQuery immutable();
+
+    List<Membership> executeQuery(MembershipQuery query);
+
+
+    // Conditions
+
+    MembershipQuery setUser(User user);
+
+    MembershipQuery setUser(String user);
+
+    User getUser();
+
+    MembershipQuery setGroup(Group group);
+
+    MembershipQuery setGroup(String groupId);
+
+    Group getGroup();
+
+    MembershipQuery setRole(Role role);
+
+    MembershipQuery setRole(String role);
+
+    Role getRole();
+
+    void setRange(Range range);
+
+    Range getRange();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Range.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Range.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Range.java
new file mode 100644
index 0000000..282f8ae
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Range.java
@@ -0,0 +1,63 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+/**
+ * Represent range in paginated query
+ */
+public class Range
+{
+    //TODO: Just a quick impl
+
+    private int offset;
+
+    private int limit = -1;
+
+    private Range() {
+    }
+
+    private Range(int offset, int limit) {
+        this.offset = offset;
+        this.limit = limit;
+    }
+
+    int getPage() {
+        //TODO: Calculate based on limit/offset.
+        //TODO: Should it start from 0 or 1? Rather 1....
+        return 1;
+    }
+
+    public int getOffset() {
+        return offset;
+    }
+
+    public int getLimit() {
+        return limit;
+    }
+
+    public Range of(int offset, int limit) {
+        return new Range(offset, limit);
+    }
+
+    public Range next() {
+        offset += limit;
+        return this;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Role.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Role.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Role.java
new file mode 100644
index 0000000..cce9caa
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/Role.java
@@ -0,0 +1,106 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+import java.util.Collection;
+import java.util.Map;
+
+/**
+ * Role representation
+ */
+public interface Role extends IdentityObject
+{
+    //TODO: Javadocs
+    //TODO: Exceptions
+    //TODO: User related methods
+    //TODO: Group related methods
+
+    // Self
+
+    String getName();
+
+    boolean exists(User user, Group group);
+
+    boolean exists(String user, String groupId);
+
+
+    void add(User user, Group group);
+
+    void add(String user, String groupId);
+
+
+    // Users
+
+    Collection<User> getUsers(Group group);
+
+    Collection<User> getUsers(String groupId);
+
+
+    // Groups
+
+    Collection<Group> getGroups(User user);
+
+    Collection<Group> getGroups(String user);
+
+
+    // Attributes
+
+    /**
+     * Set attribute with given name and value. Operation will overwrite any previous value.
+     * Null value will remove attribute.
+     *
+     * @param name  of attribute
+     * @param value to be set
+     */
+    void setAttribute(String name, String value);
+
+    /**
+     * Set attribute with given name and values. Operation will overwrite any previous values.
+     * Null value or empty array will remove attribute.
+     *
+     * @param name   of attribute
+     * @param values to be set
+     */
+    void setAttribute(String name, String[] values);
+
+    /**
+     * Remove attribute with given name
+     *
+     * @param name of attribute
+     */
+    void removeAttribute(String name);
+
+    /**
+     * @param name of attribute
+     * @return attribute values or null if attribute with given name doesn't exist. If given attribute has many values
+     *         method will return first one
+     */
+    String getAttribute(String name);
+
+    /**
+     * @param name of attribute
+     * @return attribute values or null if attribute with given name doesn't exist
+     */
+    String[] getAttributeValues(String name);
+
+    /**
+     * @return map of attribute names and their values
+     */
+    Map<String, String[]> getAttributes();
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/RoleQuery.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/RoleQuery.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/RoleQuery.java
new file mode 100644
index 0000000..3e665ad
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/RoleQuery.java
@@ -0,0 +1,69 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * RoleQuery. All applied conditions will be resolved with logical AND.
+ */
+public interface RoleQuery
+{
+    //TODO: Javadocs
+    //TODO: Exceptions
+
+    // Operations
+
+    RoleQuery reset();
+
+    RoleQuery getImmutable();
+
+    List<Role> executeQuery(RoleQuery query);
+
+
+    // Conditions
+
+    RoleQuery setName(String name);
+
+    String getName();
+
+    RoleQuery setUser(User user);
+
+    RoleQuery setUser(String user);
+
+    User getUser();
+
+    RoleQuery setGroup(Group group);
+
+    RoleQuery setGroup(String groupId);
+
+    Group getGroup();
+
+    RoleQuery setAttributeFilter(String name, String[] values);
+
+    Map<String, String[]> getAttributeFilters();
+
+    RoleQuery sort(boolean ascending);
+
+    void setRange(Range range);
+
+    Range getRange();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/User.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/User.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/User.java
new file mode 100644
index 0000000..49f0a9b
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/User.java
@@ -0,0 +1,162 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * User representation
+ */
+public interface User extends IdentityObject
+{
+    //TODO: Javadocs
+    //TODO: Exceptions
+
+    //TODO: minimal set of "hard-coded" attributes that make sense:
+    //TODO: Personal - First/Last/Full Name, Phone, Email, Organization, Created Date, Birthdate; Too much??
+
+    //TODO: separate UserProfile?
+
+    //TODO: for some of those builtin attributes like email proper validation (dedicated exception?) is needed
+
+    //TODO: authentication - password/token validation
+
+    //TODO: non human identity - another interface?
+
+
+    // Self
+
+    String getName();
+
+
+    // Built in attributes
+
+    String getFirstName();
+
+    void setFirstName(String firstName);
+
+    String getLastName();
+
+    void setLastName();
+
+    //TODO: this one could be configurable with some regex
+    String getFullName();
+
+    String getEmail();
+
+    void setEmail(String email);
+
+    boolean isEnabled();
+
+    void enable();
+
+    void disable();
+
+    Date getExpirationDate();
+
+    void setExpirationDate(Date expirationDate);
+
+    Date getCreationDate();
+
+
+    // Roles
+
+    void addRole(Role role, Group group);
+
+    void addRole(String role, String groupId);
+
+    Collection<Role> getRoles(Group group);
+
+    Collection<Role> getRoles(String groupId);
+
+    Map<Role, Set<Group>> getMembershipsMap();
+
+    // TODO: ?? Map<Group, Set<Role>> getMembershipMap() <-- both?
+
+    Collection<Membership> getMemberships();
+
+    Collection<Group> getGroups(Role role);
+
+    Collection<Group> getGroups(String role);
+
+    boolean hasRole(Role role, Group group);
+
+    boolean hasRole(String role, String groupId);
+
+
+    // Authentication
+
+    // TODO: token stuff
+    // TODO: boolean validateToken(Object token); ???
+
+    boolean validatePassword(String password);
+
+    void updatePassword(String password);
+
+
+    // Attributes
+
+    /**
+     * Set attribute with given name and value. Operation will overwrite any previous value.
+     * Null value will remove attribute.
+     *
+     * @param name  of attribute
+     * @param value to be set
+     */
+    void setAttribute(String name, String value);
+
+    /**
+     * Set attribute with given name and values. Operation will overwrite any previous values.
+     * Null value or empty array will remove attribute.
+     *
+     * @param name   of attribute
+     * @param values to be set
+     */
+    void setAttribute(String name, String[] values);
+
+    /**
+     * Remove attribute with given name
+     *
+     * @param name of attribute
+     */
+    void removeAttribute(String name);
+
+    /**
+     * @param name of attribute
+     * @return attribute values or null if attribute with given name doesn't exist. If given attribute has many values
+     *         method will return first one
+     */
+    String getAttribute(String name);
+
+    /**
+     * @param name of attribute
+     * @return attribute values or null if attribute with given name doesn't exist
+     */
+    String[] getAttributeValues(String name);
+
+    /**
+     * @return map of attribute names and their values
+     */
+    Map<String, String[]> getAttributes();
+
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/UserQuery.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/UserQuery.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/UserQuery.java
new file mode 100644
index 0000000..f597fec
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/idm/UserQuery.java
@@ -0,0 +1,97 @@
+/*
+ * 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.deltaspike.security.api.idm;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * UserQuery. All applied conditions will be resolved with logical AND.
+ */
+public interface UserQuery
+{
+    //TODO: Javadocs
+    //TODO: Exceptions
+
+    //TODO: add searchBy stuff that makes sense: email, first/last/full name, organization?
+
+    //TODO: make clear comment in javadoc about usage of wildcards -
+    //TODO: should support at least usage of '*' for all built in attributes mentioned above.
+
+
+
+    // Operations
+
+    UserQuery reset();
+
+    UserQuery getImmutable();
+
+    List<User> executeQuery(UserQuery query);
+
+
+    // Conditions
+
+    UserQuery setName(String name);
+
+    String getName();
+
+    UserQuery setRelatedGroup(Group group);
+
+    UserQuery setRelatedGroup(String groupId);
+
+    Group getRelatedGroup();
+
+    UserQuery setRole(Role role);
+
+    UserQuery setRole(String name);
+
+    Role getRole();
+
+    UserQuery setAttributeFilter(String name, String[] values);
+
+    Map<String, String[]> getAttributeFilters();
+
+    // Built in attributes
+
+    UserQuery setFirstName(String firstName);
+
+    String getFirstName();
+
+    UserQuery setLastName(String lastName);
+
+    String getLastName();
+
+    UserQuery setEmail(String email);
+
+    String getEmail();
+
+    UserQuery setEnabled(boolean enabled);
+
+    boolean getEnabled();
+
+
+    // Pagination
+
+    UserQuery sort(boolean ascending);
+
+    void setRange(Range range);
+
+    Range getRange();
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/8ac4f62d/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/spi/idm/IdentityStore.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/spi/idm/IdentityStore.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/spi/idm/IdentityStore.java
new file mode 100644
index 0000000..49f2316
--- /dev/null
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/spi/idm/IdentityStore.java
@@ -0,0 +1,203 @@
+/*
+ * 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.deltaspike.security.spi.idm;
+
+import org.apache.deltaspike.security.api.idm.Group;
+import org.apache.deltaspike.security.api.idm.GroupQuery;
+import org.apache.deltaspike.security.api.idm.Membership;
+import org.apache.deltaspike.security.api.idm.MembershipQuery;
+import org.apache.deltaspike.security.api.idm.Range;
+import org.apache.deltaspike.security.api.idm.Role;
+import org.apache.deltaspike.security.api.idm.RoleQuery;
+import org.apache.deltaspike.security.api.idm.User;
+import org.apache.deltaspike.security.api.idm.UserQuery;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * IdentityStore representation providing minimal SPI
+ *
+ */
+public interface IdentityStore
+{
+   //TODO: Javadocs
+   //TODO: Exceptions 
+
+   //TODO: control hooks, events
+   //TODO: authentication, password strenght, salted password hashes
+
+
+   // User
+
+   User createUser(String name);
+   
+   void removeUser(User user);
+   
+   User getUser(String name);
+   
+
+   // Group
+
+   Group createGroup(String name, Group parent);
+   
+   void removeGroup(Group group);
+   
+   Group getGroup(String name);
+
+
+   // Role
+   
+   Role createRole(String name);
+   
+   void removeRole(Role role);
+   
+   Role getRole(String role);
+ 
+   
+   // Memberships
+   
+   Membership createMembership(Role role, User user, Group group);
+   
+   void removeMembership(Role role, User user, Group group);
+   
+   Membership getMembership(Role role, User user, Group group);
+   
+
+   // Queries
+
+   List<User> executeQuery(UserQuery query, Range range);
+
+   List<Group> executeQuery(GroupQuery query, Range range);
+
+   List<Role> executeQuery(RoleQuery query, Range range);
+
+   List<Membership> executeQuery(MembershipQuery query, Range range);
+   
+   
+   // Attributes
+   
+   
+   // User
+
+   /**
+    * Set attribute with given name and values. Operation will overwrite any previous values.
+    * Null value or empty array will remove attribute.
+    *
+    * @param user
+    * @param name of attribute
+    * @param values to be set
+    */
+   void setAttribute(User user, String name, String[] values);
+
+   /**
+    * @param user
+    * Remove attribute with given name
+    *
+    * @param name of attribute
+    */
+   void removeAttribute(User user, String name);
+
+   
+   /**
+    * @param user
+    * @param name of attribute
+    * @return attribute values or null if attribute with given name doesn't exist
+    */
+   String[] getAttributeValues(User user, String name);
+
+   /**
+    * @param user
+    * @return map of attribute names and their values
+    */
+   Map<String, String[]> getAttributes(User user);
+   
+   
+   // Group
+
+   /**
+    * Set attribute with given name and values. Operation will overwrite any previous values.
+    * Null value or empty array will remove attribute.
+    *
+    * @param group
+    * @param name of attribute
+    * @param values to be set
+    */
+   void setAttribute(Group group, String name, String[] values);
+
+   /**
+    * Remove attribute with given name
+    *
+    * @param group
+    * @param name of attribute
+    */
+   void removeAttribute(Group group, String name);
+
+
+   /**
+    * @param group
+    * @param name of attribute
+    * @return attribute values or null if attribute with given name doesn't exist
+    */
+   String[] getAttributeValues(Group group, String name);
+
+   /**
+    * @param group
+    * @return map of attribute names and their values
+    */
+   Map<String, String[]> getAttributes(Group group);
+   
+   
+   // Role
+
+   /**
+    * Set attribute with given name and values. Operation will overwrite any previous values.
+    * Null value or empty array will remove attribute.
+    *
+    * @param role
+    * @param name of attribute
+    * @param values to be set
+    */
+   void setAttribute(Role role, String name, String[] values);
+
+   /**
+    * Remove attribute with given name
+    *
+    * @param role
+    * @param name of attribute
+    */
+   void removeAttribute(Role role, String name);
+
+
+   /**
+    * @param role
+    * @param name of attribute
+    * @return attribute values or null if attribute with given name doesn't exist
+    */
+   String[] getAttributeValues(Role role, String name);
+
+   /**
+    * @param role
+    * @return map of attribute names and their values
+    */
+   Map<String, String[]> getAttributes(Role role);
+   
+   
+
+}