Merge pull request #51 from nitta-lab-2018/Accounts
確認しました
commit dc3e9369fbed4cd149d06536a1195dad1f345c17
2 parents ceae9ae + f91b343
Takashi Kazehaya authored on 12 Jun 2018
Showing 3 changed files
View
1
■■■■
src/main/java/cactusServer/entities/Account.java
setName(userName);
setPass(userPass);
setUniqueID(uniqueID);
formToken();
login = true;
}
 
public String getId() {
return id;
View
13
src/main/java/cactusServer/models/Accounts.java
private static Accounts theInstance = null;
private ArrayList<Account> accounts = new ArrayList<>(ACCOUNT_NUM_MAX);
private HashSet<String> userIDSet = new HashSet<>(ACCOUNT_NUM_MAX);
private HashSet<String> uniqueIDSet = new HashSet<>(ACCOUNT_NUM_MAX);
private URIAddressedEntity session;
 
private Accounts() {
 
}
 
uniqueIDSet);
uniqueIDSet.add(uniqueID);
Account newAccount = new Account(userID, userName, userPass, uniqueID);
accounts.add(newAccount);
session = new URIAddressedEntity("/CactusServer/rest/accounts/" + uniqueID, newAccount);
 
return session;
return new URIAddressedEntity("/CactusServer/rest/accounts/" + uniqueID, newAccount);
}
 
public Account getAccountToken(String token) {
Account editAccount;
public URIAddressedEntity loginAccount(String userID, String userPass) {
if (getAccountByID(userID) != null && getAccountByID(userID).getPass().equals(userPass)) {
Accounts.getInstance().getAccountByID(userID).setLogin(true);
Accounts.getInstance().getAccountByID(userID).formToken();
session = new URIAddressedEntity(
return new URIAddressedEntity(
"/CactusServer/rest/accounts/" + Accounts.getInstance().getAccountByID(userID).getUniqueID(),
Accounts.getInstance().getAccountByID(userID));
return session;
} else {
return null;
}
}
View
4
src/main/java/cactusServer/resources/AccountsRest.java
@Produces(MediaType.APPLICATION_JSON)
public URIAddressedEntity createAccount(@FormParam("userID") String userID, @FormParam("userName") String userName,
@FormParam("userPass") String userPass) {
URIAddressedEntity editAccount = Accounts.getInstance().createAcount(userID, userName, userPass);
if(editAccount != null) {
if (editAccount != null) {
return editAccount;
}else {
} else {
throw new WebApplicationException(409);
}
}