Design the implementation of this interface import java.util.List; /** * A simpl
ID: 3683276 • Letter: D
Question
Design the implementation of this interface
import java.util.List;
/**
* A simple interface to the token data structure that will be
* returned by a group server.
*
* You will need to develop a class that implements this interface so
* that your code can interface with the tokens created by your group
* server.
*
*/
public interface UserToken
{
/**
* This method should return a string describing the issuer of
* this token. This string identifies the group server that
* created this token. For instance, if "Alice" requests a token
* from the group server "Server1", this method will return the
* string "Server1".
*
* @return The issuer of this token
*
*/
public String getIssuer();
/**
* This method should return a string indicating the name of the
* subject of the token. For instance, if "Alice" requests a
* token from the group server "Server1", this method will return
* the string "Alice".
*
* @return The subject of this token
*
*/
public String getSubject();
/**
* This method extracts the list of groups that the owner of this
* token has access to. If "Alice" is a member of the groups "G1"
* and "G2" defined at the group server "Server1", this method
* will return ["G1", "G2"].
*
* @return The list of group memberships encoded in this token
*
*/
public List<String> getGroups();
} //-- end interface UserToken
Here is a brief description of the functionality that your group server and client need to implement:
o boolean connect(String server, int port)
Your implementation of this method is responsible for establishing a connection to the group server. No other method provided by your group client application should be able to work until this connection is established!
o void disconnect()
This method is responsible for cleanly tearing down the connection to the group server. It should be invoked when exiting the client application, or any other time that the user wishes to disconnect from a particular group server.
o UserToken getToken(String username)
This method is used to obtain the token describing the group memberships of a particular user. For simplicity, the client does not need to "log in" to obtain this token: simply providing the user name is good enough for this phase of the project.
o boolean createUser(String username, UserToken token)
This method creates a new user at the group server. The token parameter is used to identify the user who is requesting the creation of the new account. This should only succeed if the requesting user is a member of the administrative group "ADMIN". That is, not all users should be allowed to create other user accounts.
o boolean createGroup(String groupname, UserToken token)
This method allows the owner of token to create a new group. The owner of token should be flagged as the owner of the new group. Any user can create a group.
o boolean addUserToGroup(String user, String group, UserToken token)
This method enables the owner of token to add the user user to the group group. This operation requires that the owner of token is also the owner of group.
o boolean deleteUserFromGroup(String user, String group, UserToken token)
This method enables the owner of token to remove the user user from the group group. This operation requires that the owner of token is also the owner of group.
o List<String> listMembers(String group, UserToken token)
Provided that the owner of token is also the owner of group, this method will return a list of all users that are currently members of group.
Explanation / Answer
/***** GroupClient.java****/
/*** Server.java ***/
/*** GroupServer.java ****/
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.