Return-Path: X-Original-To: apmail-aries-commits-archive@www.apache.org Delivered-To: apmail-aries-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 70511CF1D for ; Fri, 8 Jun 2012 15:06:24 +0000 (UTC) Received: (qmail 58281 invoked by uid 500); 8 Jun 2012 15:06:24 -0000 Delivered-To: apmail-aries-commits-archive@aries.apache.org Received: (qmail 58218 invoked by uid 500); 8 Jun 2012 15:06:24 -0000 Mailing-List: contact commits-help@aries.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@aries.apache.org Delivered-To: mailing list commits@aries.apache.org Received: (qmail 58210 invoked by uid 99); 8 Jun 2012 15:06:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 15:06:24 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Jun 2012 15:06:21 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 29A47238899C; Fri, 8 Jun 2012 15:06:01 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1348100 - in /aries/trunk/sandbox/jmx-next: jmx-api/src/main/java/org/osgi/jmx/service/useradmin/ jmx-core/src/main/java/org/apache/aries/jmx/codec/ Date: Fri, 08 Jun 2012 15:06:00 -0000 To: commits@aries.apache.org From: davidb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120608150601.29A47238899C@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: davidb Date: Fri Jun 8 15:06:00 2012 New Revision: 1348100 URL: http://svn.apache.org/viewvc?rev=1348100&view=rev Log: Update UserAdmin with credentials as required by the spec. Modified: aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java Modified: aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java?rev=1348100&r1=1348099&r2=1348100&view=diff ============================================================================== --- aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java (original) +++ aries/trunk/sandbox/jmx-next/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java Fri Jun 8 15:06:00 2012 @@ -33,470 +33,470 @@ import org.osgi.jmx.JmxConstants; * @ThreadSafe */ public interface UserAdminMBean { - /** - * User Admin MBean object name. - */ - String OBJECTNAME = JmxConstants.OSGI_COMPENDIUM + ":service=useradmin,version=1.1"; - - /** - * The key NAME, used in {@link #NAME_ITEM}. - */ - String NAME = "Name"; - - /** - * The item for the user name for an authorization object. The key is - * {@link #NAME} and the type is {@link SimpleType#STRING}. - */ - Item NAME_ITEM = new Item(NAME, "The user name for this authorization object", SimpleType.STRING); - - /** - * The key ROLES, used in {@link #ROLES_ITEM}. - */ - String ROLES = "Roles"; - - /** - * The item containing the roles for this authorization object. The key is - * {@link #ROLES}. and the type is {@link JmxConstants#STRING_ARRAY_TYPE}. - */ - Item ROLES_ITEM = new Item(ROLES, "The names of the roles encapsulated by this auth object", JmxConstants.STRING_ARRAY_TYPE); - - /** - * The Composite Type for an Authorization object. It consists of the - * {@link #NAME_ITEM} and {@link #TYPE_ITEM} items. - */ - CompositeType AUTORIZATION_TYPE = Item.compositeType("AUTHORIZATION", "An authorization object defines which roles has a user got", NAME_ITEM, ROLES_ITEM); - /** - * The Role TYPE key, used in {@link #TYPE_ITEM}. - */ - String TYPE = "Type"; - - /** - * The item containing the type of the roles encapsulated by this - * authorization object. The key is {@link #TYPE} and the type is - * {@link SimpleType#INTEGER}. - */ - Item TYPE_ITEM = new Item(TYPE, "An integer representing type of the role: {0=Role,1=user,2=group}", SimpleType.INTEGER); - - /** - * The PROPERTIES key, used in {@link #PROPERTIES_ITEM}. - */ - String PROPERTIES = "Properties"; - - /** - * The item containing the properties of a Role. The key is - * {@link #PROPERTIES} and the type is {@link JmxConstants#PROPERTIES_TYPE}. - */ - Item PROPERTIES_ITEM = new Item(PROPERTIES, "A properties as defined by org.osgi.service.useradmin.Role", JmxConstants.PROPERTIES_TYPE); - /** - * The Composite Type for a Role. It contains the following items: - *
    - *
  • {@link #NAME}
  • - *
  • {@link #TYPE}
  • - *
  • {@link #PROPERTIES}
  • - *
- * - */ - CompositeType ROLE_TYPE = Item.compositeType("ROLE", - "Mapping of org.osgi.service.useradmin.Role for remote management purposes. User and Group extend Role", - NAME_ITEM, - TYPE_ITEM, - PROPERTIES_ITEM); - - /** - * The CREDENTIALS key, used in {@link #CREDENTIALS_ITEM}. - */ - String CREDENTIALS = "Credentials"; - - /** - * The item containing the credentials of a user. The key is - * {@link #CREDENTIALS} and the type is {@link JmxConstants#PROPERTIES_TYPE} - * . - */ - Item CREDENTIALS_ITEM = new Item(CREDENTIALS, "The credentials for this user", JmxConstants.PROPERTIES_TYPE); - - /** - * A Composite Type for a User. A User contains its Role description and - * adds the credentials. It extends {@link #ROLE_TYPE} and adds - * {@link #CREDENTIALS_ITEM}. - * - * This type extends the {@link #ROLE_TYPE}. It adds: - *
    - *
  • {@link #CREDENTIALS}
  • - *
- */ - CompositeType USER_TYPE = Item.extend(ROLE_TYPE, "USER", "Mapping of org.osgi.service.useradmin.User for remote management purposes. User extends Role"); - - /** - * The MEMBERS key, used in {@link #MEMBERS_ITEM}. - */ - String MEMBERS = "Members"; - - /** - * The item containing the members of a group. The key is {@link #MEMBERS} - * and the type is {@link JmxConstants#STRING_ARRAY_TYPE}. It is used in - * {@link #GROUP_TYPE}. - */ - Item MEMBERS_ITEM = new Item(MEMBERS, "The members of this group", JmxConstants.STRING_ARRAY_TYPE); - - /** - * The REQUIRED_MEMBERS key, used in {@link #REQUIRED_MEMBERS_ITEM}. - */ - String REQUIRED_MEMBERS = "RequiredMembers"; - - /** - * The item containing the required members of a group. The key is - * {@link #REQUIRED_MEMBERS} and the type is - * {@link JmxConstants#STRING_ARRAY_TYPE}. It is used in {@link #GROUP_TYPE} - * . - */ - Item REQUIRED_MEMBERS_ITEM = new Item(REQUIRED_MEMBERS, "The required members of this group", JmxConstants.STRING_ARRAY_TYPE); - - /** - * The Composite Type for a Group. It extends {@link #USER_TYPE} and adds - * {@link #MEMBERS_ITEM}, and {@link #REQUIRED_MEMBERS_ITEM}. - * - * This type extends the {@link #USER_TYPE}. It adds: - *
    - *
  • {@link #MEMBERS}
  • - *
  • {@link #REQUIRED_MEMBERS}
  • - *
- * If there are no members or required members an empty array is returned in - * the respective items. - */ - CompositeType GROUP_TYPE = Item.extend(USER_TYPE, - "GROUP", - "Mapping of org.osgi.service.useradmin.Group for remote management purposes. Group extends User which in turn extends Role", - MEMBERS_ITEM, - REQUIRED_MEMBERS_ITEM); - - /** - * Add credentials to a user, associated with the supplied key - * - * @param key The key of the credential to add - * @param value The value of the credential to add - * @param username The name of the user that gets the credential. - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the username is not a User - */ - void addCredential(String key, byte[] value, String username) throws IOException; - - /** - * Add credentials to a user, associated with the supplied key - * - * @param key The key of the credential to add - * @param value The value of the credential to add - * @param username The name of the user that gets the credential. - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the username is not a User - */ - void addCredentialString(String key, String value, String username) throws IOException; - - /** - * Add a member to the group. - * - * @param groupname The group name that receives the {@code rolename} as - * member. - * @param rolename The {@code rolename} (User or Group) that must be added. - * @return {@code true} if the role was added to the group - * @throws IOException if the operation fails - * @throws IllegalArgumentException if an invalid group name or role name is - * specified - * - */ - boolean addMember(String groupname, String rolename) throws IOException; - - /** - * Add or update a property on a role - * - * @param key The key of the property to add - * @param value The value of the property to add ({@code String}) - * @param rolename The role name - * @throws IOException if the operation fails - * @throws IllegalArgumentException if an invalid role name is specified - */ - void addPropertyString(String key, String value, String rolename) throws IOException; - - /** - * Add or update a property on a role. - * - * @param key The added property key - * @param value The added byte[] property value - * @param rolename The role name that receives the property - * @throws IOException if the operation fails - * @throws IllegalArgumentException if an invalid role name is specified - */ - void addProperty(String key, byte[] value, String rolename) throws IOException; - - /** - * Add a required member to the group - * - * @param groupname The group name that is addded - * @param rolename The role that - * @return true if the role was added to the group - * @throws IOException if the operation fails - * @throws IllegalArgumentException if an invalid group name or role name is - * specified - */ - boolean addRequiredMember(String groupname, String rolename) throws IOException; - - /** - * Create a User - * - * @param name Name of the user to create - * @throws IOException if the operation fails - */ - void createUser(String name) throws IOException; - - /** - * Create a Group - * - * @param name Name of the group to create - * @throws IOException if the operation fails - */ - void createGroup(String name) throws IOException; - - /** - * This method was specified in error and must not be used. - * - * @param name Ignored. - * @throws IOException This method will throw an exception if called. - * @deprecated This method was specified in error. It does not function and - * must not be used. Use either {@link #createUser(String)} or - * {@link #createGroup(String)}. - */ - void createRole(String name) throws IOException; - - /** - * Answer the authorization for the user name. - * - * The Composite Data is typed by {@link #AUTORIZATION_TYPE}. - * - * @param user The user name - * @return the Authorization typed by {@link #AUTORIZATION_TYPE}. - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the user name is not a User - */ - CompositeData getAuthorization(String user) throws IOException; - - /** - * Answer the credentials associated with a user. - * - * The returned Tabular Data is typed by - * {@link JmxConstants#PROPERTIES_TYPE}. - * - * @param username The user name - * @return the credentials associated with the user, see - * {@link JmxConstants#PROPERTIES_TYPE} - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the user name is not a User - */ - TabularData getCredentials(String username) throws IOException; - - /** - * Answer the Group associated with the group name. - * - * The returned Composite Data is typed by {@link #GROUP_TYPE} - * - * @param groupname The group name - * @return the Group, see {@link #GROUP_TYPE} - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the group name is not a Group - */ - CompositeData getGroup(String groupname) throws IOException; - - /** - * Answer the list of group names - * - * @return The list of group names - * @throws IOException if the operation fails - */ - String[] listGroups() throws IOException; - - /** - * Answer the list of group names - * - * @param filter The filter to apply - * @return The list of group names - * @throws IOException if the operation fails - */ - String[] getGroups(String filter) throws IOException; - - /** - * Answer the list of implied roles for a user - * - * @param username The name of the user that has the implied roles - * @return The list of role names - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the username is not a User - */ - String[] getImpliedRoles(String username) throws IOException; - - /** - * Answer the the user names which are members of the group - * - * @param groupname The name of the group to get the members from - * @return The list of user names - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the groupname is not a Group - */ - String[] getMembers(String groupname) throws IOException; - - /** - * Answer the properties associated with a role. - * - * The returned Tabular Data is typed by - * {@link JmxConstants#PROPERTIES_TYPE}. - * - * @param rolename The name of the role to get properties from - * @return the properties associated with the role, see - * {@link JmxConstants#PROPERTIES_TYPE} - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the rolename is not a role - */ - TabularData getProperties(String rolename) throws IOException; - - /** - * Answer the list of user names which are required members of this group - * - * @param groupname The name of the group to get the required members from - * @return The list of user names - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the group name is not a Group - */ - String[] getRequiredMembers(String groupname) throws IOException; - - /** - * Answer the role associated with a name. - * - * The returned Composite Data is typed by {@link #ROLE_TYPE}. - * - * @param name The name of the role to get the data from - * @return the Role, see {@link #ROLE_TYPE} - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the name is not a role - */ - CompositeData getRole(String name) throws IOException; - - /** - * Answer the list of role names in the User Admin database - * - * @return The list of role names - * @throws IOException if the operation fails - */ - String[] listRoles() throws IOException; - - /** - * Answer the list of role names which match the supplied filter - * - * @param filter The string representation of the - * {@code org.osgi.framework.Filter} that is used to filter the roles - * by applying to the properties, if {@code null} all roles are - * returned. - * - * @return The list the role names - * @throws IOException if the operation fails - */ - String[] getRoles(String filter) throws IOException; - - /** - * Answer the User associated with the user name. - * - * The returned Composite Data is typed by {@link #USER_TYPE}. - * - * @param username The name of the requested user - * @return The User, see {@link #USER_TYPE} - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the username is not a User - */ - CompositeData getUser(String username) throws IOException; - - /** - * Answer the user name with the given property key-value pair from the User - * Admin service database. - * - * @param key The key to compare - * @param value The value to compare - * @return The User - * @throws IOException if the operation fails - */ - String getUserWithProperty(String key, String value) throws IOException; - - /** - * Answer the list of user names in the User Admin database - * - * @return The list of user names - * @throws IOException if the operation fails - */ - String[] listUsers() throws IOException; - - /** - * Answer the list of user names in the User Admin database - * - * @param filter The filter to apply - * @return The list of user names - * @throws IOException if the operation fails - */ - String[] getUsers(String filter) throws IOException; - - /** - * Remove the credential associated with the given user - * - * @param key The key of the credential to remove - * @param username The name of the user for which the credential must be - * removed - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the username is not a User - */ - void removeCredential(String key, String username) throws IOException; - - /** - * Remove a role from the group - * - * @param groupname The group name - * @param rolename - * @return true if the role was removed from the group - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the groupname is not a Group - */ - boolean removeMember(String groupname, String rolename) throws IOException; - - /** - * Remove a property from a role - * - * @param key - * @param rolename - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the rolename is not a role - */ - void removeProperty(String key, String rolename) throws IOException; - - /** - * Remove the Role associated with the name - * - * @param name - * @return true if the remove succeeded - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the name is not a role - */ - boolean removeRole(String name) throws IOException; - - /** - * Remove the Group associated with the name - * - * @param name - * @return true if the remove succeeded - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the name is not a Group - */ - boolean removeGroup(String name) throws IOException; - - /** - * Remove the User associated with the name - * - * @param name - * @return true if the remove succeeded - * @throws IOException if the operation fails - * @throws IllegalArgumentException if the name is not a User - */ - boolean removeUser(String name) throws IOException; + /** + * User Admin MBean object name. + */ + String OBJECTNAME = JmxConstants.OSGI_COMPENDIUM + ":service=useradmin,version=1.1"; + + /** + * The key NAME, used in {@link #NAME_ITEM}. + */ + String NAME = "Name"; + + /** + * The item for the user name for an authorization object. The key is + * {@link #NAME} and the type is {@link SimpleType#STRING}. + */ + Item NAME_ITEM = new Item(NAME, "The user name for this authorization object", SimpleType.STRING); + + /** + * The key ROLES, used in {@link #ROLES_ITEM}. + */ + String ROLES = "Roles"; + + /** + * The item containing the roles for this authorization object. The key is + * {@link #ROLES}. and the type is {@link JmxConstants#STRING_ARRAY_TYPE}. + */ + Item ROLES_ITEM = new Item(ROLES, "The names of the roles encapsulated by this auth object", JmxConstants.STRING_ARRAY_TYPE); + + /** + * The Composite Type for an Authorization object. It consists of the + * {@link #NAME_ITEM} and {@link #ROLES_ITEM} items. + */ + CompositeType AUTORIZATION_TYPE = Item.compositeType("AUTHORIZATION", "An authorization object defines which roles has a user got", NAME_ITEM, ROLES_ITEM); + /** + * The Role TYPE key, used in {@link #TYPE_ITEM}. + */ + String TYPE = "Type"; + + /** + * The item containing the type of the roles encapsulated by this + * authorization object. The key is {@link #TYPE} and the type is + * {@link SimpleType#INTEGER}. + */ + Item TYPE_ITEM = new Item(TYPE, "An integer representing type of the role: {0=Role,1=user,2=group}", SimpleType.INTEGER); + + /** + * The PROPERTIES key, used in {@link #PROPERTIES_ITEM}. + */ + String PROPERTIES = "Properties"; + + /** + * The item containing the properties of a Role. The key is + * {@link #PROPERTIES} and the type is {@link JmxConstants#PROPERTIES_TYPE}. + */ + Item PROPERTIES_ITEM = new Item(PROPERTIES, "A properties as defined by org.osgi.service.useradmin.Role", JmxConstants.PROPERTIES_TYPE); + /** + * The Composite Type for a Role. It contains the following items: + *
    + *
  • {@link #NAME}
  • + *
  • {@link #TYPE}
  • + *
  • {@link #PROPERTIES}
  • + *
+ * + */ + CompositeType ROLE_TYPE = Item.compositeType("ROLE", + "Mapping of org.osgi.service.useradmin.Role for remote management purposes. User and Group extend Role", + NAME_ITEM, + TYPE_ITEM, + PROPERTIES_ITEM); + + /** + * The CREDENTIALS key, used in {@link #CREDENTIALS_ITEM}. + */ + String CREDENTIALS = "Credentials"; + + /** + * The item containing the credentials of a user. The key is + * {@link #CREDENTIALS} and the type is {@link JmxConstants#PROPERTIES_TYPE} + * . + */ + Item CREDENTIALS_ITEM = new Item(CREDENTIALS, "The credentials for this user", JmxConstants.PROPERTIES_TYPE); + + /** + * A Composite Type for a User. A User contains its Role description and + * adds the credentials. It extends {@link #ROLE_TYPE} and adds + * {@link #CREDENTIALS_ITEM}. + * + * This type extends the {@link #ROLE_TYPE}. It adds: + *
    + *
  • {@link #CREDENTIALS}
  • + *
+ */ + CompositeType USER_TYPE = Item.extend(ROLE_TYPE, "USER", "Mapping of org.osgi.service.useradmin.User for remote management purposes. User extends Role", CREDENTIALS_ITEM); + + /** + * The MEMBERS key, used in {@link #MEMBERS_ITEM}. + */ + String MEMBERS = "Members"; + + /** + * The item containing the members of a group. The key is {@link #MEMBERS} + * and the type is {@link JmxConstants#STRING_ARRAY_TYPE}. It is used in + * {@link #GROUP_TYPE}. + */ + Item MEMBERS_ITEM = new Item(MEMBERS, "The members of this group", JmxConstants.STRING_ARRAY_TYPE); + + /** + * The REQUIRED_MEMBERS key, used in {@link #REQUIRED_MEMBERS_ITEM}. + */ + String REQUIRED_MEMBERS = "RequiredMembers"; + + /** + * The item containing the required members of a group. The key is + * {@link #REQUIRED_MEMBERS} and the type is + * {@link JmxConstants#STRING_ARRAY_TYPE}. It is used in {@link #GROUP_TYPE} + * . + */ + Item REQUIRED_MEMBERS_ITEM = new Item(REQUIRED_MEMBERS, "The required members of this group", JmxConstants.STRING_ARRAY_TYPE); + + /** + * The Composite Type for a Group. It extends {@link #USER_TYPE} and adds + * {@link #MEMBERS_ITEM}, and {@link #REQUIRED_MEMBERS_ITEM}. + * + * This type extends the {@link #USER_TYPE}. It adds: + *
    + *
  • {@link #MEMBERS}
  • + *
  • {@link #REQUIRED_MEMBERS}
  • + *
+ * If there are no members or required members an empty array is returned in + * the respective items. + */ + CompositeType GROUP_TYPE = Item.extend(USER_TYPE, + "GROUP", + "Mapping of org.osgi.service.useradmin.Group for remote management purposes. Group extends User which in turn extends Role", + MEMBERS_ITEM, + REQUIRED_MEMBERS_ITEM); + + /** + * Add credentials to a user, associated with the supplied key + * + * @param key The key of the credential to add + * @param value The value of the credential to add + * @param username The name of the user that gets the credential. + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the username is not a User + */ + void addCredential(String key, byte[] value, String username) throws IOException; + + /** + * Add credentials to a user, associated with the supplied key + * + * @param key The key of the credential to add + * @param value The value of the credential to add + * @param username The name of the user that gets the credential. + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the username is not a User + */ + void addCredentialString(String key, String value, String username) throws IOException; + + /** + * Add a member to the group. + * + * @param groupname The group name that receives the {@code rolename} as + * member. + * @param rolename The {@code rolename} (User or Group) that must be added. + * @return {@code true} if the role was added to the group + * @throws IOException if the operation fails + * @throws IllegalArgumentException if an invalid group name or role name is + * specified + * + */ + boolean addMember(String groupname, String rolename) throws IOException; + + /** + * Add or update a property on a role + * + * @param key The key of the property to add + * @param value The value of the property to add ({@code String}) + * @param rolename The role name + * @throws IOException if the operation fails + * @throws IllegalArgumentException if an invalid role name is specified + */ + void addPropertyString(String key, String value, String rolename) throws IOException; + + /** + * Add or update a property on a role. + * + * @param key The added property key + * @param value The added byte[] property value + * @param rolename The role name that receives the property + * @throws IOException if the operation fails + * @throws IllegalArgumentException if an invalid role name is specified + */ + void addProperty(String key, byte[] value, String rolename) throws IOException; + + /** + * Add a required member to the group + * + * @param groupname The group name that is addded + * @param rolename The role that + * @return true if the role was added to the group + * @throws IOException if the operation fails + * @throws IllegalArgumentException if an invalid group name or role name is + * specified + */ + boolean addRequiredMember(String groupname, String rolename) throws IOException; + + /** + * Create a User + * + * @param name Name of the user to create + * @throws IOException if the operation fails + */ + void createUser(String name) throws IOException; + + /** + * Create a Group + * + * @param name Name of the group to create + * @throws IOException if the operation fails + */ + void createGroup(String name) throws IOException; + + /** + * This method was specified in error and must not be used. + * + * @param name Ignored. + * @throws IOException This method will throw an exception if called. + * @deprecated This method was specified in error. It does not function and + * must not be used. Use either {@link #createUser(String)} or + * {@link #createGroup(String)}. + */ + void createRole(String name) throws IOException; + + /** + * Answer the authorization for the user name. + * + * The Composite Data is typed by {@link #AUTORIZATION_TYPE}. + * + * @param user The user name + * @return the Authorization typed by {@link #AUTORIZATION_TYPE}. + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the user name is not a User + */ + CompositeData getAuthorization(String user) throws IOException; + + /** + * Answer the credentials associated with a user. + * + * The returned Tabular Data is typed by + * {@link JmxConstants#PROPERTIES_TYPE}. + * + * @param username The user name + * @return the credentials associated with the user, see + * {@link JmxConstants#PROPERTIES_TYPE} + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the user name is not a User + */ + TabularData getCredentials(String username) throws IOException; + + /** + * Answer the Group associated with the group name. + * + * The returned Composite Data is typed by {@link #GROUP_TYPE} + * + * @param groupname The group name + * @return the Group, see {@link #GROUP_TYPE} + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the group name is not a Group + */ + CompositeData getGroup(String groupname) throws IOException; + + /** + * Answer the list of group names + * + * @return The list of group names + * @throws IOException if the operation fails + */ + String[] listGroups() throws IOException; + + /** + * Answer the list of group names + * + * @param filter The filter to apply + * @return The list of group names + * @throws IOException if the operation fails + */ + String[] getGroups(String filter) throws IOException; + + /** + * Answer the list of implied roles for a user + * + * @param username The name of the user that has the implied roles + * @return The list of role names + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the username is not a User + */ + String[] getImpliedRoles(String username) throws IOException; + + /** + * Answer the the user names which are members of the group + * + * @param groupname The name of the group to get the members from + * @return The list of user names + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the groupname is not a Group + */ + String[] getMembers(String groupname) throws IOException; + + /** + * Answer the properties associated with a role. + * + * The returned Tabular Data is typed by + * {@link JmxConstants#PROPERTIES_TYPE}. + * + * @param rolename The name of the role to get properties from + * @return the properties associated with the role, see + * {@link JmxConstants#PROPERTIES_TYPE} + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the rolename is not a role + */ + TabularData getProperties(String rolename) throws IOException; + + /** + * Answer the list of user names which are required members of this group + * + * @param groupname The name of the group to get the required members from + * @return The list of user names + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the group name is not a Group + */ + String[] getRequiredMembers(String groupname) throws IOException; + + /** + * Answer the role associated with a name. + * + * The returned Composite Data is typed by {@link #ROLE_TYPE}. + * + * @param name The name of the role to get the data from + * @return the Role, see {@link #ROLE_TYPE} + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the name is not a role + */ + CompositeData getRole(String name) throws IOException; + + /** + * Answer the list of role names in the User Admin database + * + * @return The list of role names + * @throws IOException if the operation fails + */ + String[] listRoles() throws IOException; + + /** + * Answer the list of role names which match the supplied filter + * + * @param filter The string representation of the + * {@code org.osgi.framework.Filter} that is used to filter the roles + * by applying to the properties, if {@code null} all roles are + * returned. + * + * @return The list the role names + * @throws IOException if the operation fails + */ + String[] getRoles(String filter) throws IOException; + + /** + * Answer the User associated with the user name. + * + * The returned Composite Data is typed by {@link #USER_TYPE}. + * + * @param username The name of the requested user + * @return The User, see {@link #USER_TYPE} + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the username is not a User + */ + CompositeData getUser(String username) throws IOException; + + /** + * Answer the user name with the given property key-value pair from the User + * Admin service database. + * + * @param key The key to compare + * @param value The value to compare + * @return The User + * @throws IOException if the operation fails + */ + String getUserWithProperty(String key, String value) throws IOException; + + /** + * Answer the list of user names in the User Admin database + * + * @return The list of user names + * @throws IOException if the operation fails + */ + String[] listUsers() throws IOException; + + /** + * Answer the list of user names in the User Admin database + * + * @param filter The filter to apply + * @return The list of user names + * @throws IOException if the operation fails + */ + String[] getUsers(String filter) throws IOException; + + /** + * Remove the credential associated with the given user + * + * @param key The key of the credential to remove + * @param username The name of the user for which the credential must be + * removed + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the username is not a User + */ + void removeCredential(String key, String username) throws IOException; + + /** + * Remove a role from the group + * + * @param groupname The group name + * @param rolename + * @return true if the role was removed from the group + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the groupname is not a Group + */ + boolean removeMember(String groupname, String rolename) throws IOException; + + /** + * Remove a property from a role + * + * @param key + * @param rolename + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the rolename is not a role + */ + void removeProperty(String key, String rolename) throws IOException; + + /** + * Remove the Role associated with the name + * + * @param name + * @return true if the remove succeeded + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the name is not a role + */ + boolean removeRole(String name) throws IOException; + + /** + * Remove the Group associated with the name + * + * @param name + * @return true if the remove succeeded + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the name is not a Group + */ + boolean removeGroup(String name) throws IOException; + + /** + * Remove the User associated with the name + * + * @param name + * @return true if the remove succeeded + * @throws IOException if the operation fails + * @throws IllegalArgumentException if the name is not a User + */ + boolean removeUser(String name) throws IOException; } Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java?rev=1348100&r1=1348099&r2=1348100&view=diff ============================================================================== --- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java (original) +++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java Fri Jun 8 15:06:00 2012 @@ -58,7 +58,7 @@ public class GroupData extends UserData * @param group {@link Group} instance. */ public GroupData(Group group) { - super(group.getName(), Role.GROUP, group.getProperties()); + super(group.getName(), Role.GROUP, group.getProperties(), group.getCredentials()); this.members = toArray(group.getMembers()); this.requiredMembers = toArray(group.getRequiredMembers()); } @@ -71,8 +71,8 @@ public class GroupData extends UserData * @param members basic members. * @param requiredMembers required members. */ - public GroupData(String name, Dictionary properties, String[] members, String[] requiredMembers) { - super(name, Role.GROUP, properties); + public GroupData(String name, Dictionary properties, Dictionary credentials, String[] members, String[] requiredMembers) { + super(name, Role.GROUP, properties, credentials); this.members = (members == null) ? new String[0] : members; this.requiredMembers = (requiredMembers == null) ? new String[0] : requiredMembers; } @@ -88,6 +88,7 @@ public class GroupData extends UserData items.put(UserAdminMBean.NAME, name); items.put(UserAdminMBean.TYPE, type); items.put(UserAdminMBean.PROPERTIES, getPropertiesTable()); + items.put(UserAdminMBean.CREDENTIALS, getCredentialsTable()); items.put(UserAdminMBean.MEMBERS, members); items.put(UserAdminMBean.REQUIRED_MEMBERS, requiredMembers); return new CompositeDataSupport(UserAdminMBean.GROUP_TYPE, items); @@ -109,10 +110,11 @@ public class GroupData extends UserData } String name = (String) data.get(UserAdminMBean.NAME); Dictionary props = propertiesFrom((TabularData) data.get(UserAdminMBean.PROPERTIES)); + Dictionary credentials = propertiesFrom((TabularData) data.get(UserAdminMBean.CREDENTIALS)); String[] members = (String[]) data.get(UserAdminMBean.MEMBERS); String[] requiredMembers = (String[]) data.get(UserAdminMBean.REQUIRED_MEMBERS); - return new GroupData(name, props, members, requiredMembers); + return new GroupData(name, props, credentials, members, requiredMembers); } /** Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java?rev=1348100&r1=1348099&r2=1348100&view=diff ============================================================================== --- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java (original) +++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java Fri Jun 8 15:06:00 2012 @@ -105,8 +105,12 @@ public class RoleData { } protected TabularData getPropertiesTable() { + return getPropertiesTable(properties); + } + + protected static TabularData getPropertiesTable(List> data) { TabularData propertiesTable = new TabularDataSupport(JmxConstants.PROPERTIES_TYPE); - for (PropertyData propertyData : properties) { + for (PropertyData propertyData : data) { propertiesTable.put(propertyData.toCompositeData()); } return propertiesTable; Modified: aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java URL: http://svn.apache.org/viewvc/aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java?rev=1348100&r1=1348099&r2=1348100&view=diff ============================================================================== --- aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java (original) +++ aries/trunk/sandbox/jmx-next/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java Fri Jun 8 15:06:00 2012 @@ -16,8 +16,11 @@ */ package org.apache.aries.jmx.codec; +import java.util.ArrayList; import java.util.Dictionary; +import java.util.Enumeration; import java.util.HashMap; +import java.util.List; import java.util.Map; import javax.management.openmbean.CompositeData; @@ -40,12 +43,17 @@ import org.osgi.service.useradmin.User; public class UserData extends RoleData { /** + * user credentials. + */ + protected List> credentials = new ArrayList>(); + + /** * Constructs new UserData from {@link User} object. * * @param user {@link User} instance. */ public UserData(User user){ - super(user.getName(), user.getType(), user.getProperties()); + this(user.getName(), user.getType(), user.getProperties(), user.getCredentials()); } /** @@ -54,9 +62,17 @@ public class UserData extends RoleData { * @param name user name. * @param type role type. * @param properties user properties. + * @param credentials user credentials. */ - public UserData(String name, int type, Dictionary properties) { + public UserData(String name, int type, Dictionary properties, Dictionary credentials) { super(name, type, properties); + + if (credentials != null) { + for (Enumeration e = credentials.keys(); e.hasMoreElements(); ) { + String key = e.nextElement().toString(); + this.credentials.add(PropertyData.newInstance(key, credentials.get(key))); + } + } } /** @@ -71,12 +87,17 @@ public class UserData extends RoleData { items.put(UserAdminMBean.NAME, name); items.put(UserAdminMBean.TYPE, type); items.put(UserAdminMBean.PROPERTIES, getPropertiesTable()); + items.put(UserAdminMBean.CREDENTIALS, getCredentialsTable()); return new CompositeDataSupport(UserAdminMBean.USER_TYPE, items); } catch (OpenDataException e) { throw new IllegalStateException("Can't create CompositeData" + e); } } + protected TabularData getCredentialsTable() { + return getPropertiesTable(credentials); + } + /** * Static factory method to create UserData from CompositeData object. * @@ -90,7 +111,7 @@ public class UserData extends RoleData { String name = (String) data.get(UserAdminMBean.NAME); int type = (Integer)data.get(UserAdminMBean.TYPE); Dictionary props = propertiesFrom((TabularData) data.get(UserAdminMBean.PROPERTIES)); - - return new UserData(name, type, props); + Dictionary credentials = propertiesFrom((TabularData) data.get(UserAdminMBean.CREDENTIALS)); + return new UserData(name, type, props, credentials); } }