You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by aw...@apache.org on 2010/03/08 20:22:22 UTC
svn commit: r920467 - in /incubator/aries/trunk/jmx:
jmx-api/src/main/java/org/osgi/jmx/service/useradmin/
jmx-core/src/main/java/org/apache/aries/jmx/codec/
jmx-core/src/main/java/org/apache/aries/jmx/useradmin/
jmx-core/src/test/java/org/apache/aries...
Author: awojtuniak
Date: Mon Mar 8 19:22:22 2010
New Revision: 920467
URL: http://svn.apache.org/viewvc?rev=920467&view=rev
Log:
ARIES-33 Updating UserAdminMBean API and implementation
Modified:
incubator/aries/trunk/jmx/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java
incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java
incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java
incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java
incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/useradmin/UserAdmin.java
incubator/aries/trunk/jmx/jmx-core/src/test/java/org/apache/aries/jmx/useradmin/UserAdminTest.java
Modified: incubator/aries/trunk/jmx/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java?rev=920467&r1=920466&r2=920467&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java (original)
+++ incubator/aries/trunk/jmx/jmx-api/src/main/java/org/osgi/jmx/service/useradmin/UserAdminMBean.java Mon Mar 8 19:22:22 2010
@@ -1,5 +1,5 @@
/*
- * Copyright (c) OSGi Alliance (2009). All Rights Reserved.
+ * Copyright (c) OSGi Alliance (2009, 2010). All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,86 +16,97 @@
package org.osgi.jmx.service.useradmin;
-import java.io.*;
+import java.io.IOException;
-import javax.management.openmbean.*;
+import javax.management.openmbean.CompositeData;
+import javax.management.openmbean.CompositeType;
+import javax.management.openmbean.SimpleType;
+import javax.management.openmbean.TabularData;
-import org.osgi.jmx.*;
+import org.osgi.jmx.Item;
+import org.osgi.jmx.JmxConstants;
/**
* This MBean provides the management interface to the OSGi User Manager Service
*
- * @version $Rev$
+ * @version $Revision$
+ * @ThreadSafe
*/
public interface UserAdminMBean {
/**
* User Admin MBean object name.
*/
- String OBJECTNAME = JmxConstants.OSGI_COMPENDIUM
- + ":service=useradmin,version=1.1";
+ String OBJECTNAME = JmxConstants.OSGI_COMPENDIUM
+ + ":service=useradmin,version=1.1";
/**
* The key NAME, used in {@link #NAME_ITEM}.
*/
- String NAME = "Name";
+ String NAME = "Name";
/**
- * The user name for this authorization object. The key is {@link #NAME} and
- * the type is {@link SimpleType#STRING}.
+ * 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);
+ 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";
+ 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);
+ 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);
+ 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";
+ 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);
+ 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";
+ 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);
+ Item PROPERTIES_ITEM = new Item(
+ PROPERTIES,
+ "A properties as defined by org.osgi.service.useradmin.Role",
+ JmxConstants.PROPERTIES_TYPE);
/**
- * The item containing the type of Composite Type for a Role. It contains
- * the following items:
+ * The Composite Type for a Role. It contains the following items:
* <ul>
* <li>{@link #NAME}</li>
* <li>{@link #TYPE}</li>
@@ -103,24 +114,26 @@
* </ul>
*
*/
- 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);
+ 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);
/**
* The CREDENTIALS key, used in {@link #CREDENTIALS_ITEM}.
*/
- String CREDENTIALS = "Credentials";
+ String CREDENTIALS = "Credentials";
/**
* The item containing the credentials of a user. The key is
- * {@link #CREDENTIALS} and the type is {@link JmxConstants#PROPERTIES_TYPE}
- * .
+ * {@link #CREDENTIALS} and the type is {@link JmxConstants#PROPERTIES_TYPE} .
*/
- Item CREDENTIALS_ITEM = new Item(CREDENTIALS,
- "The credentials for this user", 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
@@ -132,40 +145,42 @@
* <li>{@link #CREDENTIALS}</li>
* </ul>
*/
- CompositeType USER_TYPE = Item
- .extend(
- ROLE_TYPE,
- "USER",
- "Mapping of org.osgi.service.useradmin.User for remote management purposes. User extends Role",
- CREDENTIALS_ITEM);
+ 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";
+ 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);
+ 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";
+ 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}
- * .
+ * {@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);
+ 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
@@ -177,26 +192,22 @@
* <li>{@link #REQUIRED_MEMBERS}</li>
* </ul>
*/
- 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);
+ 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 user name is not a User
+ * @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 user name is not a User
*/
void addCredential(String key, byte[] value, String username)
throws IOException;
@@ -204,65 +215,46 @@
/**
* 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
+ * @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, String value, String username)
+ 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</code> as
- * member.
- * @param rolename
- * The <code>rolename</code> (User or Group) that must be added.
+ * @param groupname The group name that receives the <code>rolename</code>
+ * as member.
+ * @param rolename The <code>rolename</code> (User or Group) that must be
+ * added.
* @return <code>true</code> if the role was added to the group
- * @throws IOException
- * if the operation fails
+ * @throws IOException if the operation fails
*
- * TODO Hal, please check, I am not clear who is the receiver
- * and who is the parameter. The ordering seems very confusing,
- * because here the rolename seems the parameter but in all
- * other calls it is the dest?
*/
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</code>)
- * @param rolename
- * The role name
- * @throws IOException
- * if the operation fails
+ * @param key The key of the property to add
+ * @param value The value of the property to add (<code>String</code>)
+ * @param rolename The role name
+ * @throws IOException if the operation fails
*/
- void addProperty(String key, String value, String rolename)
+ 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
+ * @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
*/
void addProperty(String key, byte[] value, String rolename)
throws IOException;
@@ -270,13 +262,10 @@
/**
* Add a required member to the group
*
- * @param groupname
- * The group name that is addded
- * @param rolename
- * The role that
+ * @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 IOException if the operation fails
*/
boolean addRequiredMember(String groupname, String rolename)
throws IOException;
@@ -284,30 +273,24 @@
/**
* Create a User
*
- * @param name
- * Name of the user to create
- * @throws IOException
- * if the operation fails
+ * @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
+ * @param name Name of the group to create
+ * @throws IOException if the operation fails
*/
void createGroup(String name) throws IOException;
/**
* Create a Role
*
- * @param name
- * of the role to create
- * @throws IOException
- * if the operation fails
+ * @param name of the role to create
+ * @throws IOException if the operation fails
*/
void createRole(String name) throws IOException;
@@ -316,13 +299,10 @@
*
* The Composite Data is typed by {@link #AUTORIZATION_TYPE}.
*
- * @param user
- * The user name
+ * @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
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the user name is not a User
*/
CompositeData getAuthorization(String user) throws IOException;
@@ -332,14 +312,11 @@
* The returned Tabular Data is typed by
* {@link JmxConstants#PROPERTIES_TYPE}.
*
- * @param username
- * The user name
+ * @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
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the user name is not a User
*/
TabularData getCredentials(String username) throws IOException;
@@ -348,13 +325,10 @@
*
* The returned Composite Data is typed by {@link #GROUP_TYPE}
*
- * @param groupname
- * The group name
+ * @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
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the group name is not a Group
*/
CompositeData getGroup(String groupname) throws IOException;
@@ -362,47 +336,37 @@
* Answer the list of group names
*
* @return The list of group names
- * @throws IOException
- * if the operation fails
+ * @throws IOException if the operation fails
*/
String[] listGroups() throws IOException;
/**
* Answer the list of group names
*
- * @param filter
- * The filter to apply
+ * @param filter The filter to apply
* @return The list of group names
- * @throws IOException
- * if the operation fails
+ * @throws IOException if the operation fails
*/
String[] getGroups(String filter) throws IOException;
/**
* Answer the list of implied roles for a user
*
- * TODO I do not know how this maps to User Admin?
- *
- * @param username
- * The name of the user that has the implied roles
+ * @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
+ * @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
+ * @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 <code>groupname</code> is not a group
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the <code>groupname</code> is not a
+ * group
*/
String[] getMembers(String groupname) throws IOException;
@@ -412,25 +376,20 @@
* The returned Tabular Data is typed by
* {@link JmxConstants#PROPERTIES_TYPE}.
*
- * @param rolename
- * The name of the role to get properties from
+ * @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 IOException if the operation fails
*/
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
+ * @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
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the group name is not a group
*/
String[] getRequiredMembers(String groupname) throws IOException;
@@ -439,39 +398,30 @@
*
* The returned Composite Data is typed by {@link #ROLE_TYPE}.
*
- * TODO Is this also all users and groups?
- *
- * @param name
- * The name of the role to get the data from
+ * @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 IOException if the operation fails
*/
CompositeData getRole(String name) throws IOException;
/**
* Answer the list of role names in the User Admin database
*
- * TODO Is this also all users and groups?
- *
* @return The list of role names
- * @throws IOException
- * if the operation fails
+ * @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</code> that is used to filter
- * the roles by applying to the properties, if <code>null</code>
- * all roles are returned.
+ * @param filter The string representation of the
+ * <code>org.osgi.framework.Filter</code> that is used to filter
+ * the roles by applying to the properties, if <code>null</code>
+ * all roles are returned.
*
* @return The list the role names
- * @throws IOException
- * if the operation fails
+ * @throws IOException if the operation fails
*/
String[] getRoles(String filter) throws IOException;
@@ -480,13 +430,11 @@
*
* The returned Composite Data is typed by {@link #USER_TYPE}.
*
- * @param username
- * The name of the requested user
+ * @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 <code>username</code> is not a User
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the <code>username</code> is not a
+ * User
*/
CompositeData getUser(String username) throws IOException;
@@ -494,61 +442,49 @@
* 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
+ * @param key The key to compare
+ * @param value The value to compare
* @return The User
- * @throws IOException
- * if the operation fails
+ * @throws IOException if the operation fails
*/
- String getUser(String key, String value) throws IOException;
+ 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
+ * @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
+ * @param filter The filter to apply
* @return The list of user names
- * @throws IOException
- * if the operation fails
+ * @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
+ * @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 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
+ * @throws IOException if the operation fails
+ * @throws IllegalArgumentException if the groupname is not a Group
*/
boolean removeMember(String groupname, String rolename) throws IOException;
@@ -557,8 +493,7 @@
*
* @param key
* @param rolename
- * @throws IOException
- * if the operation fails
+ * @throws IOException if the operation fails
*/
void removeProperty(String key, String rolename) throws IOException;
@@ -567,8 +502,7 @@
*
* @param name
* @return true if the remove succeeded
- * @throws IOException
- * if the operation fails
+ * @throws IOException if the operation fails
*/
boolean removeRole(String name) throws IOException;
@@ -577,8 +511,7 @@
*
* @param name
* @return true if the remove succeeded
- * @throws IOException
- * if the operation fails
+ * @throws IOException if the operation fails
*/
boolean removeGroup(String name) throws IOException;
@@ -587,8 +520,7 @@
*
* @param name
* @return true if the remove succeeded
- * @throws IOException
- * if the operation fails
+ * @throws IOException if the operation fails
*/
boolean removeUser(String name) throws IOException;
Modified: incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java?rev=920467&r1=920466&r2=920467&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java (original)
+++ incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/GroupData.java Mon Mar 8 19:22:22 2010
@@ -17,7 +17,6 @@
package org.apache.aries.jmx.codec;
import java.util.ArrayList;
-import java.util.Dictionary;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -25,7 +24,6 @@
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.TabularData;
import org.osgi.jmx.service.useradmin.UserAdminMBean;
import org.osgi.service.useradmin.Group;
@@ -58,7 +56,7 @@
* @param group {@link Group} instance.
*/
public GroupData(Group group) {
- super(group.getName(), Role.GROUP, group.getProperties(), group.getCredentials());
+ super(group.getName(), Role.GROUP);
setRequiredMembers(group);
setMembers(group);
}
@@ -69,11 +67,9 @@
* @param name group name.
* @param members basic members.
* @param requiredMembers required members.
- * @param properties role properties.
- * @param credentials group credentials.
*/
- public GroupData(String name, String[] members, String[] requiredMembers, Dictionary<String, Object> properties, Dictionary<String, Object> credentials) {
- super(name, Role.GROUP, properties, credentials);
+ public GroupData(String name, String[] members, String[] requiredMembers) {
+ super(name, Role.GROUP);
this.members = members;
this.requiredMembers = requiredMembers;
}
@@ -90,8 +86,6 @@
items.put(UserAdminMBean.TYPE, type);
items.put(UserAdminMBean.MEMBERS, members);
items.put(UserAdminMBean.REQUIRED_MEMBERS, requiredMembers);
- items.put(UserAdminMBean.PROPERTIES, toTabularData(properties));
- items.put(UserAdminMBean.CREDENTIALS, toTabularData(credentials));
return new CompositeDataSupport(UserAdminMBean.GROUP_TYPE, items);
} catch (OpenDataException e) {
throw new IllegalStateException("Can't create CompositeData" + e);
@@ -112,11 +106,7 @@
String name = (String) data.get(UserAdminMBean.NAME);
String[] members = (String[]) data.get(UserAdminMBean.MEMBERS);
String[] requiredMembers = (String[]) data.get(UserAdminMBean.REQUIRED_MEMBERS);
- TabularData propsData = (TabularData) data.get(UserAdminMBean.PROPERTIES);
- Dictionary<String, Object> properties = propertiesFrom(propsData);
- TabularData credData = (TabularData)data.get(UserAdminMBean.CREDENTIALS);
- Dictionary<String, Object> credentials = propertiesFrom(credData);
- return new GroupData(name, members, requiredMembers, properties, credentials);
+ return new GroupData(name, members, requiredMembers);
}
/**
Modified: incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java?rev=920467&r1=920466&r2=920467&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java (original)
+++ incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/RoleData.java Mon Mar 8 19:22:22 2010
@@ -52,29 +52,23 @@
* role type.
*/
protected int type;
- /**
- * role properties.
- */
- protected Dictionary<String, Object> properties;
/**
* Constructs new RoleData from Role object.
* @param role {@link Role} instance.
*/
public RoleData(Role role){
- this(role.getName(),role.getType(),role.getProperties());
+ this(role.getName(),role.getType());
}
/**
* Constructs new RoleData.
* @param name role name.
* @param type role type.
- * @param properties role properties.
*/
- public RoleData(String name, int type, Dictionary<String, Object> properties){
+ public RoleData(String name, int type){
this.name = name;
this.type = type;
- this.properties = properties;
}
/**
@@ -88,7 +82,6 @@
Map<String, Object> items = new HashMap<String, Object>();
items.put(UserAdminMBean.NAME, name);
items.put(UserAdminMBean.TYPE, type);
- items.put(UserAdminMBean.PROPERTIES, toTabularData(properties));
return new CompositeDataSupport(UserAdminMBean.ROLE_TYPE, items);
} catch (OpenDataException e) {
throw new IllegalStateException("Can't create CompositeData" + e);
@@ -107,9 +100,7 @@
}
String name = (String) data.get(UserAdminMBean.NAME);
int type = (Integer) data.get(UserAdminMBean.TYPE);
- TabularData tabularData = (TabularData) data.get(UserAdminMBean.PROPERTIES);
- Dictionary<String, Object> properties = propertiesFrom(tabularData);
- return new RoleData(name, type, properties);
+ return new RoleData(name, type);
}
/**
@@ -163,11 +154,4 @@
return type;
}
- /**
- * @return the properties
- */
- public Dictionary<String, Object> getProperties() {
- return properties;
- }
-
}
\ No newline at end of file
Modified: incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java?rev=920467&r1=920466&r2=920467&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java (original)
+++ incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/codec/UserData.java Mon Mar 8 19:22:22 2010
@@ -16,14 +16,12 @@
*/
package org.apache.aries.jmx.codec;
-import java.util.Dictionary;
import java.util.HashMap;
import java.util.Map;
import javax.management.openmbean.CompositeData;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.openmbean.OpenDataException;
-import javax.management.openmbean.TabularData;
import org.osgi.jmx.service.useradmin.UserAdminMBean;
import org.osgi.service.useradmin.User;
@@ -38,23 +36,15 @@
* @version $Rev$ $Date$
*/
public class UserData extends RoleData {
-
- /**
- * @see UserAdminMBean#CREDENTIALS_ITEM
- */
- protected Dictionary<String, Object> credentials;
/**
* Constructs new UserData.
*
* @param name user name.
* @param type role type.
- * @param properties role properties.
- * @param credentials role credentials.
*/
- public UserData(String name, int type, Dictionary<String, Object> properties, Dictionary<String, Object> credentials){
- super(name, type, properties);
- this.credentials = credentials;
+ public UserData(String name, int type){
+ super(name, type);
}
/**
@@ -63,7 +53,7 @@
* @param user {@link User} instance.
*/
public UserData(User user){
- this(user.getName(), user.getType(), user.getProperties(), user.getCredentials());
+ this(user.getName(), user.getType());
}
/**
@@ -77,8 +67,6 @@
Map<String, Object> items = new HashMap<String, Object>();
items.put(UserAdminMBean.NAME, name);
items.put(UserAdminMBean.TYPE, type);
- items.put(UserAdminMBean.CREDENTIALS, toTabularData(credentials));
- items.put(UserAdminMBean.PROPERTIES, toTabularData(properties));
return new CompositeDataSupport(UserAdminMBean.USER_TYPE, items);
} catch (OpenDataException e) {
throw new IllegalStateException("Can't create CompositeData" + e);
@@ -97,10 +85,6 @@
}
String name = (String) data.get(UserAdminMBean.NAME);
int type = (Integer)data.get(UserAdminMBean.TYPE);
- TabularData propData = (TabularData)data.get(UserAdminMBean.PROPERTIES);
- TabularData credData = (TabularData)data.get(UserAdminMBean.CREDENTIALS);
- Dictionary<String, Object> properties = propertiesFrom(propData);
- Dictionary<String, Object> credentials = propertiesFrom(credData);
- return new UserData(name, type, properties, credentials);
+ return new UserData(name, type);
}
}
Modified: incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/useradmin/UserAdmin.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/useradmin/UserAdmin.java?rev=920467&r1=920466&r2=920467&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/useradmin/UserAdmin.java (original)
+++ incubator/aries/trunk/jmx/jmx-core/src/main/java/org/apache/aries/jmx/useradmin/UserAdmin.java Mon Mar 8 19:22:22 2010
@@ -100,10 +100,9 @@
}
/**
- * @see org.osgi.jmx.service.useradmin.UserAdminMBean#addCredential(java.lang.String, java.lang.String,
- * java.lang.String)
+ * @see org.osgi.jmx.service.useradmin.UserAdminMBean#addCredentialString(String, String, String)
*/
- public void addCredential(String key, String value, String username) throws IOException {
+ public void addCredentialString(String key, String value, String username) throws IOException {
Role role = userAdmin.getRole(username);
if (role == null) {
throw new IOException("Operation fails user with provided username = [" + username + "] doesn't exist");
@@ -130,10 +129,9 @@
}
/**
- * @see org.osgi.jmx.service.useradmin.UserAdminMBean#addProperty(java.lang.String, java.lang.String,
- * java.lang.String)
+ * @see org.osgi.jmx.service.useradmin.UserAdminMBean#addPropertyString(String, String, String)
*/
- public void addProperty(String key, String value, String rolename) throws IOException {
+ public void addPropertyString(String key, String value, String rolename) throws IOException {
addRoleProperty(key, value, rolename);
}
@@ -383,9 +381,9 @@
}
/**
- * @see org.osgi.jmx.service.useradmin.UserAdminMBean#getUser(java.lang.String, java.lang.String)
+ * @see org.osgi.jmx.service.useradmin.UserAdminMBean#getUserWithProperty(String, String)
*/
- public String getUser(String key, String value) throws IOException {
+ public String getUserWithProperty(String key, String value) throws IOException {
User user = userAdmin.getUser(key, value);
if (user == null) {
return null;
Modified: incubator/aries/trunk/jmx/jmx-core/src/test/java/org/apache/aries/jmx/useradmin/UserAdminTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jmx/jmx-core/src/test/java/org/apache/aries/jmx/useradmin/UserAdminTest.java?rev=920467&r1=920466&r2=920467&view=diff
==============================================================================
--- incubator/aries/trunk/jmx/jmx-core/src/test/java/org/apache/aries/jmx/useradmin/UserAdminTest.java (original)
+++ incubator/aries/trunk/jmx/jmx-core/src/test/java/org/apache/aries/jmx/useradmin/UserAdminTest.java Mon Mar 8 19:22:22 2010
@@ -66,7 +66,7 @@
* @throws IOException
*/
@Test
- public void testAddCredentialStringByteArrayString() throws IOException {
+ public void testAddCredential() throws IOException {
User user1 = Mockito.mock(User.class);
Dictionary<String, Object> credentials = new Hashtable<String, Object>();
Mockito.when(userAdmin.getRole("user1")).thenReturn(user1);
@@ -79,19 +79,19 @@
/**
* Test method for
- * {@link org.apache.aries.jmx.useradmin.UserAdmin#addCredential(java.lang.String, java.lang.String, java.lang.String)}
+ * {@link org.apache.aries.jmx.useradmin.UserAdmin#addCredentialString(String, String, String)}
* .
*
* @throws IOException
*/
@Test
- public void testAddCredentialStringStringString() throws IOException {
+ public void testAddCredentialString() throws IOException {
User user1 = Mockito.mock(User.class);
Dictionary<String, Object> credentials = new Hashtable<String, Object>();
Mockito.when(userAdmin.getRole("user1")).thenReturn(user1);
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getCredentials()).thenReturn(credentials);
- mbean.addCredential("password", "1234", "user1");
+ mbean.addCredentialString("password", "1234", "user1");
Assert.assertEquals("1234", (String) credentials.get("password"));
}
@@ -115,19 +115,19 @@
/**
* Test method for
- * {@link org.apache.aries.jmx.useradmin.UserAdmin#addProperty(java.lang.String, java.lang.String, java.lang.String)}
+ * {@link org.apache.aries.jmx.useradmin.UserAdmin#addPropertyString(String, String, String)}
* .
*
* @throws IOException
*/
@Test
- public void testAddPropertyStringStringString() throws IOException {
+ public void testAddPropertyString() throws IOException {
User user1 = Mockito.mock(User.class);
Dictionary<String, Object> props = new Hashtable<String, Object>();
Mockito.when(userAdmin.getRole("user1")).thenReturn(user1);
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getProperties()).thenReturn(props);
- mbean.addProperty("key", "1234", "user1");
+ mbean.addPropertyString("key", "1234", "user1");
Assert.assertEquals("1234", (String) props.get("key"));
}
@@ -138,7 +138,7 @@
* @throws IOException
*/
@Test
- public void testAddPropertyStringByteArrayString() throws IOException {
+ public void testAddProperty() throws IOException {
User user1 = Mockito.mock(User.class);
Dictionary<String, Object> props = new Hashtable<String, Object>();
Mockito.when(userAdmin.getRole("user1")).thenReturn(user1);
@@ -402,7 +402,7 @@
* @throws IOException
*/
@Test
- public void testGetUserString() throws IOException {
+ public void testGetUser() throws IOException {
User user1 = Mockito.mock(User.class);
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getName()).thenReturn("user1");
@@ -417,17 +417,17 @@
}
/**
- * Test method for {@link org.apache.aries.jmx.useradmin.UserAdmin#getUser(java.lang.String, java.lang.String)}.
+ * Test method for {@link org.apache.aries.jmx.useradmin.UserAdmin#getUserWithProperty(String, String)}.
*
* @throws IOException
*/
@Test
- public void testGetUserStringString() throws IOException {
+ public void testGetUserString() throws IOException {
User user1 = Mockito.mock(User.class);
Mockito.when(user1.getType()).thenReturn(Role.USER);
Mockito.when(user1.getName()).thenReturn("user1");
Mockito.when(userAdmin.getUser("key", "valuetest")).thenReturn(user1);
- String username = mbean.getUser("key", "valuetest");
+ String username = mbean.getUserWithProperty("key", "valuetest");
Assert.assertEquals(username, "user1");
}