/**
*
- * This class provides a set of API to handle requests for registering account
- * information of authorized user, and publishing and finding resources.
+ * This class provides a set of APIs to handle requests about account
+ * information of authorized user.
*
*/
public class AccountServerManager {
+ /**
+ * API for requesting user account
+ *
+ * @param userId
+ * user identifier
+ * @param deviceId
+ * device identifier
+ * @return Boolean - true if registered, otherwise false
+ */
public Boolean registerUserAccount(String userId, String deviceId) {
Boolean ret = false;
return ret;
}
+ /**
+ * API for requesting user account and getting session code for registered
+ * user.
+ *
+ * @param userId
+ * user identifier
+ * @return String - session code for registered user
+ */
public String registerUserAccount(String userId) {
String sessionCode = null;
}
/**
- * API for requesting user identifier to interested authorization server
- *
- * @param accessToeken
- * access token
+ * API for requesting user identifier corresponding with authorization
+ * information.
+ *
+ * @param authCode
+ * authorization code
* @param authServer
* authorization server
* @return String - user identifier
return userId;
}
+ /**
+ * API for requesting user identifier corresponding with session code.
+ *
+ * @param sessionCode
+ * session code
+ * @return String - user identifier
+ */
public String requestUserId(String sessionCode) {
String userId = null;
}
/**
- * API for getting devices according to authorized user from database
- *
+ * API for getting devices corresponding with user identifier.
+ *
* @param userId
- * identifier of authorized user
+ * user identifier
* @return ArrayList<String> - list of devices
*/
public ArrayList<String> requestAccountDevices(String userId) {
return deviceList;
}
- /**
- * API for requesting access token to interested authorization server
- *
- * @param authServer
- * server name for authorization
- * @param authCode
- * authorization code
- * @return ArrayList<String> - array list of name of authorization servers
- */
private String getAccessToken(String authCode, String authServer) {
String accessToken = null;
- if (authServer.equals(Const.GITHUB)) {
+ if (authServer.equals(Constants.GITHUB)) {
GitHub gitHub = new GitHub();
accessToken = gitHub.requestAccessToken(authCode);
String userId = null;
- if (authServer.equals(Const.GITHUB)) {
+ if (authServer.equals(Constants.GITHUB)) {
GitHub gitHub = new GitHub();
userId = gitHub.requestGetUserInfo(accessToken);
private String generateSessionCode() {
- String sessionCode = "";
+ StringBuffer sessionCode = new StringBuffer();
Random random = new Random();
int randomNum = random.nextInt(122);
|| (randomNum >= 97 && randomNum <= 122)) {
code = (char) randomNum;
- sessionCode += code;
+ sessionCode.append(code);
randomNum = random.nextInt(122);
break;
}
}
- return sessionCode;
+ return sessionCode.toString();
}
}