Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse')
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java9
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionDatabaseStore.java7
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionImpl.java8
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionStorage.java3
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSubscriptionGroupImpl.java11
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java2
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java100
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsSubscriptionStorage.java105
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtil.java34
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientArtifact.java10
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientStorage.java40
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/JdbcJaxRsOAuthStorage.java40
-rw-r--r--plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/OAuthTypes.java14
15 files changed, 178 insertions, 209 deletions
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java
index b1d2608b723..efd4b620896 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountArtifact.java
@@ -36,7 +36,7 @@ public class AccountArtifact extends BaseIdentity<String>implements Account {
}
@Override
- public long getId() {
+ public Long getId() {
return artifact.getUuid();
}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java
index 0f1f35e0b78..fe89592c15f 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountFactory.java
@@ -16,6 +16,7 @@ import org.eclipse.osee.account.admin.AccountPreferences;
import org.eclipse.osee.account.admin.AccountSession;
import org.eclipse.osee.account.admin.SubscriptionGroup;
import org.eclipse.osee.account.rest.model.AccountWebPreferences;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.type.ResultSetTransform.Function;
@@ -72,14 +73,14 @@ public class AccountFactory {
}
}
- public AccountSession newAccountSession(long accountId, String sessionToken, String accessedFrom, String accessDetails) {
+ public AccountSession newAccountSession(ArtifactId accountId, String sessionToken, String accessedFrom, String accessDetails) {
Date currentDate = new Date();
return newAccountSession(accountId, sessionToken, currentDate, currentDate, accessedFrom, accessDetails);
}
- public AccountSession newAccountSession(long accountId, String sessionToken, Date createdOn, Date lastAccessedOn, String accessedFrom, String accessDetails) {
+ public AccountSession newAccountSession(ArtifactId accountId, String sessionToken, Date createdOn, Date lastAccessedOn, String accessedFrom, String accessDetails) {
AccountSessionImpl session = new AccountSessionImpl();
- session.setAccountId(accountId);
+ session.setAccountId(accountId.getUuid());
session.setSessionToken(sessionToken);
session.setCreatedOn(createdOn);
session.setLastAccessedOn(lastAccessedOn);
@@ -89,7 +90,7 @@ public class AccountFactory {
}
public SubscriptionGroup newAccountSubscriptionGroup(ArtifactReadable source) {
- return new AccountSubscriptionGroupImpl(source.getGuid(), source);
+ return new AccountSubscriptionGroupImpl(source);
}
public ResultSet<SubscriptionGroup> newAccountSubscriptionGroupResultSet(ResultSet<ArtifactReadable> results) {
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java
index b57f99f1cf5..050409a8b80 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountPreferencesArtifact.java
@@ -39,7 +39,7 @@ public class AccountPreferencesArtifact extends BaseIdentity<String>implements A
}
@Override
- public long getId() {
+ public Long getId() {
return artifact.getUuid();
}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionDatabaseStore.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionDatabaseStore.java
index ad3834901be..556ef823439 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionDatabaseStore.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionDatabaseStore.java
@@ -17,6 +17,8 @@ import java.util.List;
import java.util.concurrent.Callable;
import org.eclipse.osee.account.admin.AccountSession;
import org.eclipse.osee.executor.admin.CancellableCallable;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.type.ResultSets;
import org.eclipse.osee.framework.jdk.core.util.Lib;
@@ -71,7 +73,7 @@ public class AccountSessionDatabaseStore implements AccountSessionStorage {
}
@Override
- public Callable<ResultSet<AccountSession>> getAccountSessionByAccountId(long accountId) {
+ public Callable<ResultSet<AccountSession>> getAccountSessionByAccountId(ArtifactId accountId) {
return selectAccess(SELECT_BY_ACCOUNT_ID, accountId);
}
@@ -96,7 +98,8 @@ public class AccountSessionDatabaseStore implements AccountSessionStorage {
Date lastAccessedOn = chStmt.getTimestamp("last_accessed_on");
String accessedFrom = chStmt.getString("accessed_from");
String accessDetails = chStmt.getString("access_details");
- AccountSession session = factory.newAccountSession(accountId, sessionToken, createdOn, lastAccessedOn,
+ ArtifactId artId = TokenFactory.createArtifactId(accountId);
+ AccountSession session = factory.newAccountSession(artId, sessionToken, createdOn, lastAccessedOn,
accessedFrom, accessDetails);
list.add(session);
}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionImpl.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionImpl.java
index 052ee3759c7..502558fb171 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionImpl.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionImpl.java
@@ -18,7 +18,7 @@ import org.eclipse.osee.account.admin.AccountSession;
*/
public class AccountSessionImpl implements AccountSession {
- private long accountId;
+ private Long accountId;
private String sessionToken;
private Date createdOn;
private Date lastAccessedOn;
@@ -26,7 +26,7 @@ public class AccountSessionImpl implements AccountSession {
private String accessDetails;
@Override
- public long getAccountId() {
+ public Long getAccountId() {
return accountId;
}
@@ -55,7 +55,7 @@ public class AccountSessionImpl implements AccountSession {
return accessDetails;
}
- public void setAccountId(long accountId) {
+ public void setAccountId(Long accountId) {
this.accountId = accountId;
}
@@ -107,7 +107,7 @@ public class AccountSessionImpl implements AccountSession {
} else if (!sessionToken.equals(other.sessionToken)) {
return false;
}
- if (accountId != other.accountId) {
+ if (!accountId.equals(other.accountId)) {
return false;
}
return true;
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionStorage.java
index 8d2f7872bc1..b02dbfd1f96 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionStorage.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSessionStorage.java
@@ -12,6 +12,7 @@ package org.eclipse.osee.orcs.account.admin.internal;
import java.util.concurrent.Callable;
import org.eclipse.osee.account.admin.AccountSession;
+import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
/**
@@ -19,7 +20,7 @@ import org.eclipse.osee.framework.jdk.core.type.ResultSet;
*/
public interface AccountSessionStorage {
- Callable<ResultSet<AccountSession>> getAccountSessionByAccountId(long accountId);
+ Callable<ResultSet<AccountSession>> getAccountSessionByAccountId(ArtifactId accountId);
Callable<ResultSet<AccountSession>> getAccountSessionBySessionToken(String sessionToken);
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSubscriptionGroupImpl.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSubscriptionGroupImpl.java
index 1f2a0a893d9..b32e89353f6 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSubscriptionGroupImpl.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/AccountSubscriptionGroupImpl.java
@@ -11,6 +11,7 @@
package org.eclipse.osee.orcs.account.admin.internal;
import org.eclipse.osee.account.admin.SubscriptionGroup;
+import org.eclipse.osee.account.rest.model.SubscriptionGroupId;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.jdk.core.type.BaseIdentity;
import org.eclipse.osee.orcs.data.ArtifactReadable;
@@ -18,19 +19,21 @@ import org.eclipse.osee.orcs.data.ArtifactReadable;
/**
* @author Roberto E. Escobar
*/
-public class AccountSubscriptionGroupImpl extends BaseIdentity<String>implements SubscriptionGroup {
+public class AccountSubscriptionGroupImpl extends BaseIdentity<String> implements SubscriptionGroup {
private static final String NOT_AVAILABLE = "N/A";
private final ArtifactReadable artifact;
+ private final SubscriptionGroupId id;
- public AccountSubscriptionGroupImpl(String uuid, ArtifactReadable artifact) {
+ public AccountSubscriptionGroupImpl(ArtifactReadable artifact) {
super(artifact.getGuid());
this.artifact = artifact;
+ this.id = new SubscriptionGroupId(artifact.getUuid());
}
@Override
- public long getId() {
- return artifact.getUuid();
+ public SubscriptionGroupId getId() {
+ return id;
}
@Override
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java
index d0ee1764e41..291291d9f16 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/BootstrapAccount.java
@@ -29,7 +29,7 @@ public class BootstrapAccount extends BaseIdentity<String>implements Account, Ac
}
@Override
- public long getId() {
+ public Long getId() {
return -1L;
}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java
index f6fa30981c0..901f7292f72 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsAccountStorage.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.orcs.account.admin.internal;
-import com.google.common.base.Supplier;
-import com.google.common.base.Suppliers;
import java.io.StringWriter;
import java.util.Collections;
import java.util.Map;
@@ -23,21 +21,20 @@ import org.eclipse.osee.account.admin.CreateAccountRequest;
import org.eclipse.osee.account.admin.ds.AccountStorage;
import org.eclipse.osee.account.rest.model.AccountWebPreferences;
import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.SystemUser;
-import org.eclipse.osee.framework.jdk.core.type.Identifiable;
-import org.eclipse.osee.framework.jdk.core.type.Identity;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.type.PropertyStore;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.type.ResultSets;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcService;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.transaction.TransactionBuilder;
-import org.eclipse.osee.orcs.utility.OrcsUtil;
+import com.google.common.base.Supplier;
+import com.google.common.base.Suppliers;
/**
* @author Roberto E. Escobar
@@ -92,29 +89,9 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt
}
@Override
- public ResultSet<Account> getAccountByUserName(String username) {
+ public ResultSet<Account> getAccountById(ArtifactId accountId) {
ResultSet<ArtifactReadable> results =
- newQuery().andIsOfType(CoreArtifactTypes.User).and(CoreAttributeTypes.UserId, username).getResults();
- return getFactory().newAccountResultSet(results);
- }
-
- @Override
- public ResultSet<Account> getAccountByGuid(String guid) {
- ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(guid).getResults();
- return getFactory().newAccountResultSet(results);
- }
-
- @Override
- public ResultSet<Account> getAccountByUuid(String accountUuid) {
- ResultSet<ArtifactReadable> results =
- newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(Long.parseLong(accountUuid)).getResults();
- return getFactory().newAccountResultSet(results);
- }
-
- @Override
- public ResultSet<Account> getAccountByLocalId(long accountId) {
- int id = Long.valueOf(accountId).intValue();
- ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(id).getResults();
+ newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(accountId.getUuid()).getResults();
return getFactory().newAccountResultSet(results);
}
@@ -126,27 +103,14 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt
}
@Override
- public ResultSet<Account> getAccountByName(String name) {
- ResultSet<ArtifactReadable> results =
- newQuery().andIsOfType(CoreArtifactTypes.User).andNameEquals(name).getResults();
- return getFactory().newAccountResultSet(results);
- }
-
- @Override
- public ResultSet<AccountPreferences> getAccountPreferencesById(long accountId) {
- int id = Long.valueOf(accountId).intValue();
+ public ResultSet<AccountPreferences> getAccountPreferencesById(ArtifactId accountId) {
+ int id = Long.valueOf(accountId.getUuid()).intValue();
ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(id).getResults();
return getFactory().newAccountPreferencesResultSet(results);
}
@Override
- public ResultSet<AccountPreferences> getAccountPreferencesByGuid(String guid) {
- ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(guid).getResults();
- return getFactory().newAccountPreferencesResultSet(results);
- }
-
- @Override
- public Identifiable<String> createAccount(CreateAccountRequest request) {
+ public ArtifactId createAccount(CreateAccountRequest request) {
TransactionBuilder tx = newTransaction("Create Account");
ArtifactId artId = tx.createArtifact(CoreArtifactTypes.User, request.getDisplayName());
tx.setSoleAttributeFromString(artId, CoreAttributeTypes.Email, request.getEmail());
@@ -155,7 +119,7 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt
Map<String, String> preferences = request.getPreferences();
if (preferences != null && !preferences.isEmpty()) {
- String prefValue = asString(artId.getGuid(), preferences);
+ String prefValue = asString(artId, preferences);
tx.createAttribute(artId, CoreAttributeTypes.UserSettings, prefValue);
}
tx.commit();
@@ -163,16 +127,14 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt
}
@Override
- public void setActive(Identifiable<String> account, boolean active) {
- ArtifactId artId = OrcsUtil.newArtifactId(Lib.generateArtifactIdAsInt(), account.getGuid(), account.getName());
-
+ public void setActive(ArtifactId accountId, boolean active) {
TransactionBuilder tx = newTransaction("Update Account Active");
- tx.setSoleAttributeValue(artId, CoreAttributeTypes.Active, active);
+ tx.setSoleAttributeValue(accountId, CoreAttributeTypes.Active, active);
tx.commit();
}
- private String asString(String uuid, Map<String, String> preferences) {
- PropertyStore settings = new PropertyStore(uuid);
+ private String asString(ArtifactId artId, Map<String, String> preferences) {
+ PropertyStore settings = new PropertyStore(Long.toString(artId.getUuid()));
for (Entry<String, String> entry : preferences.entrySet()) {
settings.put(entry.getKey(), entry.getValue());
}
@@ -187,26 +149,23 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt
}
@Override
- public void setAccountPreferences(Identity<String> account, Map<String, String> preferences) {
- String prefValue = asString(account.getGuid(), preferences);
+ public void setAccountPreferences(ArtifactId accountId, Map<String, String> preferences) {
+ String prefValue = asString(accountId, preferences);
- ArtifactId artId = OrcsUtil.newArtifactId(Lib.generateArtifactIdAsInt(), account.getGuid(), "N/A");
TransactionBuilder tx = newTransaction("User - Save Settings");
- tx.setSoleAttributeFromString(artId, CoreAttributeTypes.UserSettings, prefValue);
+ tx.setSoleAttributeFromString(accountId, CoreAttributeTypes.UserSettings, prefValue);
tx.commit();
}
@Override
- public void deleteAccount(Identifiable<String> account) {
- ArtifactId artId = OrcsUtil.newArtifactId(Lib.generateArtifactIdAsInt(), account.getGuid(), account.getName());
-
+ public void deleteAccount(ArtifactId accountId) {
TransactionBuilder tx = newTransaction("Delete User");
- tx.deleteArtifact(artId);
+ tx.deleteArtifact(accountId);
tx.commit();
}
@Override
- public ResultSet<AccountSession> getAccountSessionById(long accountId) {
+ public ResultSet<AccountSession> getAccountSessionById(ArtifactId accountId) {
try {
return sessionStore.getAccountSessionByAccountId(accountId).call();
} catch (Exception ex) {
@@ -225,8 +184,8 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt
@Override
public AccountSession createAccountSession(String sessionToken, Account account, String remoteAddress, String accessDetails) {
- AccountSession session =
- getFactory().newAccountSession(account.getId(), sessionToken, remoteAddress, accessDetails);
+ ArtifactId artId = TokenFactory.createArtifactId(account.getId());
+ AccountSession session = getFactory().newAccountSession(artId, sessionToken, remoteAddress, accessDetails);
try {
sessionStore.createAccountSession(Collections.singleton(session)).call();
return session;
@@ -260,30 +219,23 @@ public class OrcsAccountStorage extends AbstractOrcsStorage implements AccountSt
@Override
public ResultSet<Account> get() {
ResultSet<ArtifactReadable> results =
- newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(SystemUser.Anonymous.getGuid()).getResults();
+ newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(SystemUser.Anonymous.getUuid()).getResults();
return getFactory().newAccountResultSet(results);
}
};
}
@Override
- public void setAccountWebPreferences(String guid, String preferences) {
- ArtifactId artId = OrcsUtil.newArtifactId(1, guid, "name");
+ public void setAccountWebPreferences(ArtifactId artifactId, String preferences) {
TransactionBuilder tx = newTransaction("User - Save Web Preferences");
- tx.setSoleAttributeFromString(artId, CoreAttributeTypes.WebPreferences, preferences);
+ tx.setSoleAttributeFromString(artifactId, CoreAttributeTypes.WebPreferences, preferences);
tx.commit();
}
@Override
- public AccountWebPreferences getAccountWebPreferencesByGuid(String guid) {
- ResultSet<ArtifactReadable> results = newQuery().andIsOfType(CoreArtifactTypes.User).andGuid(guid).getResults();
- return getFactory().newAccountWebPreferences(results.getExactlyOne());
- }
-
- @Override
- public AccountWebPreferences getAccountWebPreferencesById(int accountId) {
+ public AccountWebPreferences getAccountWebPreferencesById(ArtifactId accountId) {
ResultSet<ArtifactReadable> results =
- newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(accountId).getResults();
+ newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(accountId.getUuid()).getResults();
return getFactory().newAccountWebPreferences(results.getExactlyOne());
}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsSubscriptionStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsSubscriptionStorage.java
index 0fe166860e3..10a07aadd37 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsSubscriptionStorage.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/OrcsSubscriptionStorage.java
@@ -17,16 +17,16 @@ import org.eclipse.osee.account.admin.Account;
import org.eclipse.osee.account.admin.Subscription;
import org.eclipse.osee.account.admin.SubscriptionGroup;
import org.eclipse.osee.account.admin.ds.SubscriptionStorage;
+import org.eclipse.osee.account.rest.model.SubscriptionGroupId;
import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.jdk.core.type.ResultSet;
import org.eclipse.osee.framework.jdk.core.type.ResultSets;
-import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.orcs.account.admin.internal.SubscriptionUtil.ActiveDelegate;
import org.eclipse.osee.orcs.data.ArtifactReadable;
import org.eclipse.osee.orcs.transaction.TransactionBuilder;
-import org.eclipse.osee.orcs.utility.OrcsUtil;
/**
* @author Roberto E. Escobar
@@ -34,10 +34,9 @@ import org.eclipse.osee.orcs.utility.OrcsUtil;
public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements SubscriptionStorage {
@Override
- public ResultSet<Subscription> getSubscriptionsByAccountLocalId(long accountId) {
- int intAccountId = Long.valueOf(accountId).intValue();
+ public ResultSet<Subscription> getSubscriptionsByAccountId(ArtifactId accountId) {
ResultSet<ArtifactReadable> accountResults =
- newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(intAccountId).getResults();
+ newQuery().andIsOfType(CoreArtifactTypes.User).andUuid(accountId.getUuid()).getResults();
ArtifactReadable account = accountResults.getExactlyOne();
ResultSet<ArtifactReadable> allGroups = newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).getResults();
@@ -50,9 +49,9 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs
}
@Override
- public void updateSubscription(long accountId, long groupId, boolean activate) {
- int intAccountId = Long.valueOf(accountId).intValue();
- int intGroupId = Long.valueOf(groupId).intValue();
+ public void updateSubscription(Subscription subscription, boolean activate) {
+ Long intAccountId = subscription.getAccountId().getUuid();
+ Long intGroupId = subscription.getGroupId().getUuid();
ArtifactReadable account = newQuery().andUuid(intAccountId).getResults().getExactlyOne();
ArtifactReadable group =
@@ -71,8 +70,8 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs
}
@Override
- public Subscription getSubscription(String subscriptionUuid) {
- return SubscriptionUtil.fromEncodedUuid(subscriptionUuid, new LazyActiveDelegate());
+ public Subscription getSubscriptionByEncodedId(String encodedId) {
+ return SubscriptionUtil.fromEncodedUuid(encodedId, new LazyActiveDelegate());
}
private class LazyActiveDelegate implements ActiveDelegate {
@@ -81,10 +80,10 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs
private volatile boolean isActive;
@Override
- public boolean isActive(long accountId, long groupId) {
+ public boolean isActive(ArtifactId accountId, SubscriptionGroupId groupId) {
if (wasRun.compareAndSet(false, true)) {
- int intAccountId = Long.valueOf(accountId).intValue();
- int intGroupId = Long.valueOf(groupId).intValue();
+ int intAccountId = Long.valueOf(accountId.getUuid()).intValue();
+ int intGroupId = Long.valueOf(groupId.getUuid()).intValue();
ArtifactReadable account = newQuery().andUuid(intAccountId).getResults().getExactlyOne();
ArtifactReadable group = newQuery().andUuid(intGroupId).getResults().getExactlyOne();
@@ -100,31 +99,9 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs
return getFactory().newAccountSubscriptionGroupResultSet(results);
}
- @Override
- public ResultSet<SubscriptionGroup> getSubscriptionGroupByLocalId(long groupId) {
- int intGroupId = Long.valueOf(groupId).intValue();
- ResultSet<ArtifactReadable> results =
- newQuery().andUuid(intGroupId).andIsOfType(CoreArtifactTypes.SubscriptionGroup).getResults();
- return getFactory().newAccountSubscriptionGroupResultSet(results);
- }
-
- @Override
- public ResultSet<SubscriptionGroup> getSubscriptionGroupByName(String name) {
- ResultSet<ArtifactReadable> results =
- newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andNameEquals(name).getResults();
- return getFactory().newAccountSubscriptionGroupResultSet(results);
- }
-
- @Override
- public ResultSet<SubscriptionGroup> getSubscriptionGroupByGuid(String guid) {
- ResultSet<ArtifactReadable> results =
- newQuery().andGuid(guid).andIsOfType(CoreArtifactTypes.SubscriptionGroup).getResults();
- return getFactory().newAccountSubscriptionGroupResultSet(results);
- }
-
@SuppressWarnings("unchecked")
@Override
- public SubscriptionGroup createSubscriptionGroup(String name) {
+ public SubscriptionGroupId createSubscriptionGroup(String name) {
String comment = String.format("Create subscription group [%s]", name);
TransactionBuilder tx = newTransaction(comment);
@@ -132,40 +109,52 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs
tx.commit();
ArtifactReadable groupArt = newQuery().andIds(artId).getResults().getExactlyOne();
- return getFactory().newAccountSubscriptionGroup(groupArt);
+ return new SubscriptionGroupId(groupArt.getUuid());
}
@Override
- public void deleteSubscriptionGroup(SubscriptionGroup group) {
- ArtifactId artId = OrcsUtil.newArtifactId(Lib.generateArtifactIdAsInt(), group.getGuid(), group.getName());
-
- String comment = String.format("Delete subscription group [%s]", group.getName());
- TransactionBuilder tx = newTransaction(comment);
- tx.deleteArtifact(artId);
- tx.commit();
+ public boolean deleteSubscriptionGroup(SubscriptionGroupId subscriptionId) {
+ boolean toReturn = false;
+
+ SubscriptionGroup subscriptionGroup = getSubscriptionGroupById(subscriptionId);
+
+ if (subscriptionGroup != null) {
+ ArtifactId subscriptionAsArtId = TokenFactory.createArtifactId(subscriptionId.getUuid());
+ String comment = String.format("Delete subscription group [%s]", subscriptionGroup.getName());
+ TransactionBuilder tx = newTransaction(comment);
+ tx.deleteArtifact(subscriptionAsArtId);
+ tx.commit();
+ toReturn = true;
+ }
+ return toReturn;
}
@Override
- public ResultSet<Account> getSubscriptionGroupMembersByLocalId(long groupId) {
- int intGroupId = Long.valueOf(groupId).intValue();
+ public SubscriptionGroup getSubscriptionGroupById(SubscriptionGroupId groupId) {
ResultSet<ArtifactReadable> results =
- newQuery().andIsOfType(CoreArtifactTypes.User).andRelatedToLocalIds(CoreRelationTypes.Users_Artifact,
- intGroupId).getResults();
- return getFactory().newAccountResultSet(results);
+ newQuery().andUuid(groupId.getUuid()).andIsOfType(CoreArtifactTypes.SubscriptionGroup).getResults();
+ return getFactory().newAccountSubscriptionGroupResultSet(results).getExactlyOne();
+ }
+
+ @Override
+ public boolean subscriptionGroupNameExists(String groupName) {
+ int count = newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andNameEquals(groupName).getCount();
+ return count > 0;
}
@Override
- public ResultSet<Account> getSubscriptionGroupMembersByName(String name) {
+ public ResultSet<Account> getSubscriptionMembersById(SubscriptionGroupId groupId) {
+ int intGroupId = Long.valueOf(groupId.getUuid()).intValue();
ResultSet<ArtifactReadable> results =
- newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andNameEquals(name).getResults();
- ArtifactReadable group = results.getOneOrNull();
- return getMembers(group);
+ newQuery().andIsOfType(CoreArtifactTypes.User).andRelatedToLocalIds(CoreRelationTypes.Users_Artifact,
+ intGroupId).getResults();
+ return getFactory().newAccountResultSet(results);
}
@Override
- public ResultSet<Account> getSubscriptionGroupMembersByGuid(String guid) {
+ public ResultSet<Account> getMembersOfSubscriptionGroupById(SubscriptionGroupId subscriptionId) {
ResultSet<ArtifactReadable> results =
- newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andGuid(guid).getResults();
+ newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andUuid(subscriptionId.getUuid()).getResults();
ArtifactReadable group = results.getOneOrNull();
return getMembers(group);
}
@@ -180,10 +169,4 @@ public class OrcsSubscriptionStorage extends AbstractOrcsStorage implements Subs
}
return toReturn;
}
-
- @Override
- public boolean subscriptionGroupNameExists(String groupName) {
- int count = newQuery().andIsOfType(CoreArtifactTypes.SubscriptionGroup).andNameEquals(groupName).getCount();
- return count > 0;
- }
}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtil.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtil.java
index 10f4ea06f32..395e230a428 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtil.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/SubscriptionUtil.java
@@ -11,6 +11,9 @@
package org.eclipse.osee.orcs.account.admin.internal;
import org.eclipse.osee.account.admin.Subscription;
+import org.eclipse.osee.account.rest.model.SubscriptionGroupId;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.jdk.core.type.NamedIdentity;
import org.eclipse.osee.framework.jdk.core.util.EncryptUtility;
import org.eclipse.osee.orcs.data.ArtifactReadable;
@@ -24,11 +27,11 @@ public final class SubscriptionUtil {
public static interface ActiveDelegate {
- boolean isActive(long accountId, long groupId);
+ boolean isActive(ArtifactId accountId, SubscriptionGroupId groupId);
}
- public static String toEncodedUuid(long accountId, String accountDisplayName, long groupId, String subscriptionName) {
- String rawData = String.format("%s:%s:%s:%s", accountId, accountDisplayName, groupId, subscriptionName);
+ public static String toEncodedUuid(ArtifactId accountId, String accountDisplayName, SubscriptionGroupId groupId, String subscriptionName) {
+ String rawData = String.format("%s:%s:%s:%s", accountId.getUuid(), accountDisplayName, groupId, subscriptionName);
return EncryptUtility.encrypt(rawData, SUBSCRIPTION_SECRET);
}
@@ -37,31 +40,36 @@ public final class SubscriptionUtil {
String[] data = decrypted.split(":");
int index = 0;
int accountId = Integer.parseInt(data[index++]);
+ ArtifactId artId = TokenFactory.createArtifactId(Long.valueOf(accountId));
+
String accountDisplayName = data[index++];
int groupId = Integer.parseInt(data[index++]);
+ SubscriptionGroupId subscriptionId = new SubscriptionGroupId((long) groupId);
String subscriptionName = data[index++];
- return new DelegatingActiveSubscriptionImpl(subscriptionUuid, accountId, accountDisplayName, groupId,
+ return new DelegatingActiveSubscriptionImpl(subscriptionUuid, artId, accountDisplayName, subscriptionId,
subscriptionName, delegate);
}
- public static Subscription fromData(long accountId, String accountDisplayName, long groupId, String subscriptionName, boolean isActive) {
+ public static Subscription fromData(ArtifactId accountId, String accountDisplayName, SubscriptionGroupId groupId, String subscriptionName, boolean isActive) {
String encodedUuid = toEncodedUuid(accountId, accountDisplayName, groupId, subscriptionName);
return new SubscriptionImpl(encodedUuid, accountId, accountDisplayName, groupId, subscriptionName, isActive);
}
public static Subscription fromArtifactData(ArtifactReadable account, ArtifactReadable subscription, boolean isActive) {
int accountId = account.getLocalId();
+ ArtifactId artId = TokenFactory.createArtifactId(Long.valueOf(accountId));
String accountName = account.getName();
int groupId = subscription.getLocalId();
+ SubscriptionGroupId subcriptionId = new SubscriptionGroupId((long) groupId);
String subscriptionName = subscription.getName();
- return fromData(accountId, accountName, groupId, subscriptionName, isActive);
+ return fromData(artId, accountName, subcriptionId, subscriptionName, isActive);
}
private static final class DelegatingActiveSubscriptionImpl extends SubscriptionImpl {
private final ActiveDelegate provider;
- private DelegatingActiveSubscriptionImpl(String encodedUuid, long accountId, String accountDisplayName, long groupId, String subscriptionName, ActiveDelegate provider) {
+ private DelegatingActiveSubscriptionImpl(String encodedUuid, ArtifactId accountId, String accountDisplayName, SubscriptionGroupId groupId, String subscriptionName, ActiveDelegate provider) {
super(encodedUuid, accountId, accountDisplayName, groupId, subscriptionName, false);
this.provider = provider;
}
@@ -72,14 +80,14 @@ public final class SubscriptionUtil {
}
}
- private static class SubscriptionImpl extends NamedIdentity<String>implements Subscription {
+ private static class SubscriptionImpl extends NamedIdentity<String> implements Subscription {
- private final long accountId;
+ private final ArtifactId accountId;
private final String accountDisplayName;
- private final long groupId;
+ private final SubscriptionGroupId groupId;
private final boolean active;
- private SubscriptionImpl(String encodedUuid, long accountId, String accountDisplayName, long groupId, String subscriptionName, boolean active) {
+ private SubscriptionImpl(String encodedUuid, ArtifactId accountId, String accountDisplayName, SubscriptionGroupId groupId, String subscriptionName, boolean active) {
super(encodedUuid, subscriptionName);
this.accountId = accountId;
this.accountDisplayName = accountDisplayName;
@@ -88,7 +96,7 @@ public final class SubscriptionUtil {
}
@Override
- public long getAccountId() {
+ public ArtifactId getAccountId() {
return accountId;
}
@@ -98,7 +106,7 @@ public final class SubscriptionUtil {
}
@Override
- public long getGroupId() {
+ public SubscriptionGroupId getGroupId() {
return groupId;
}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientArtifact.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientArtifact.java
index 566030af7c4..12eb1f75ee3 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientArtifact.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientArtifact.java
@@ -10,10 +10,6 @@
*******************************************************************************/
package org.eclipse.osee.orcs.account.admin.internal.oauth;
-import com.google.common.io.InputSupplier;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.reflect.TypeToken;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.util.Collections;
@@ -24,11 +20,15 @@ import org.eclipse.osee.framework.jdk.core.type.BaseIdentity;
import org.eclipse.osee.framework.jdk.core.util.Strings;
import org.eclipse.osee.jaxrs.server.security.OAuthClient;
import org.eclipse.osee.orcs.data.ArtifactReadable;
+import com.google.common.io.InputSupplier;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.reflect.TypeToken;
/**
* @author Roberto E. Escobar
*/
-public class ClientArtifact extends BaseIdentity<String>implements OAuthClient, InputSupplier<InputStream> {
+public class ClientArtifact extends BaseIdentity<String> implements OAuthClient, InputSupplier<InputStream> {
private final GsonBuilder builder;
private final ArtifactReadable artifact;
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientStorage.java
index 947abf1584a..385a2517b46 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientStorage.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/ClientStorage.java
@@ -19,16 +19,13 @@ import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUT
import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_CLIENT_LOGO_URI;
import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_CLIENT_PROPERTIES;
import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_CLIENT_WEBSITE_URI;
-import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_TYPES_ARTIFACT;
-import com.google.common.io.InputSupplier;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import static org.eclipse.osee.orcs.account.admin.internal.oauth.OAuthTypes.OAUTH_TYPES;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import org.eclipse.osee.framework.core.data.ArtifactId;
import org.eclipse.osee.framework.core.data.IOseeBranch;
-import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.core.enums.CoreAttributeTypes;
import org.eclipse.osee.framework.core.enums.SystemUser;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
@@ -43,7 +40,9 @@ import org.eclipse.osee.orcs.search.QueryBuilder;
import org.eclipse.osee.orcs.search.QueryFactory;
import org.eclipse.osee.orcs.transaction.TransactionBuilder;
import org.eclipse.osee.orcs.transaction.TransactionFactory;
-import org.eclipse.osee.orcs.utility.OrcsUtil;
+import com.google.common.io.InputSupplier;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
/**
* @author Roberto E. Escobar
@@ -109,19 +108,24 @@ public class ClientStorage {
return newQuery().andIsOfType(OAUTH_CLIENT).andGuid(guid).getResults();
}
- public boolean exists(String guid) {
- return newQuery().andIsOfType(OAUTH_CLIENT).andGuid(guid).getCount() > 0;
+ public ResultSet<ArtifactReadable> getClientByClientUuid(Long uuid) {
+ return newQuery().andIsOfType(OAUTH_CLIENT).andUuid(uuid).getResults();
+ }
+
+ public boolean exists(Long uuid) {
+ return newQuery().andIsOfType(OAUTH_CLIENT).andUuid(uuid).getCount() > 0;
}
- public void insert(OseePrincipal principal, OAuthClient data) {
+ public ArtifactId insert(OseePrincipal principal, OAuthClient data) {
TransactionBuilder tx = newTransaction(principal, "Create OAuth Client");
ArtifactId artId = tx.createArtifact(OAUTH_CLIENT, data.getApplicationName(), data.getGuid());
txSetClient(tx, artId, data);
tx.commit();
+ return artId;
}
public void update(OseePrincipal principal, OAuthClient data) {
- ArtifactId artId = OrcsUtil.newArtifactId(data.getClientUuid(), data.getGuid(), data.getApplicationName());
+ ArtifactId artId = TokenFactory.createArtifactId(data.getClientUuid());
TransactionBuilder tx = newTransaction(principal, "Update OAuth Client");
tx.setName(artId, data.getApplicationName());
@@ -134,9 +138,9 @@ public class ClientStorage {
tx.setSoleAttributeFromString(artId, CoreAttributeTypes.Description, data.getApplicationDescription());
tx.setSoleAttributeFromString(artId, OAUTH_CLIENT_WEBSITE_URI, data.getApplicationWebUri());
tx.setSoleAttributeFromString(artId, OAUTH_CLIENT_LOGO_URI, data.getApplicationLogoUri());
-
+
tx.setSoleAttributeValue(artId, OAUTH_CLIENT_IS_CONFIDENTIAL, data.isConfidential());
-
+
tx.setAttributesFromStrings(artId, OAUTH_CLIENT_AUTHORIZED_AUDIENCE, data.getRegisteredAudiences());
tx.setAttributesFromStrings(artId, OAUTH_CLIENT_AUTHORIZED_GRANT_TYPE, data.getAllowedGrantTypes());
tx.setAttributesFromStrings(artId, OAUTH_CLIENT_AUTHORIZED_REDIRECT_URI, data.getRedirectUris());
@@ -159,25 +163,20 @@ public class ClientStorage {
}
public void delete(OseePrincipal principal, OAuthClient data) {
- ArtifactId artId = OrcsUtil.newArtifactId(data.getClientUuid(), data.getGuid(), data.getApplicationName());
+ ArtifactId artId = TokenFactory.createArtifactId(data.getClientUuid());
TransactionBuilder tx = newTransaction(principal, "Delete OAuth Client");
tx.deleteArtifact(artId);
tx.commit();
}
- @SuppressWarnings("unchecked")
private ResultSet<ArtifactReadable> getOAuthTypesDefinition() throws OseeCoreException {
- return newQuery().andIds(OAUTH_TYPES_ARTIFACT).getResults();
+ return newQuery().andUuid(OAUTH_TYPES.getUuid()).andTypeEquals(OAUTH_TYPES.getArtifactType()).getResults();
}
public void storeTypes(InputSupplier<? extends InputStream> resource) {
TransactionBuilder tx = newTransaction(null, "Initialize OAuth Type Definitions");
-
- ArtifactId artifactId = OAUTH_TYPES_ARTIFACT;
- if (!typesExist()) {
- tx.createArtifact(CoreArtifactTypes.OseeTypeDefinition, artifactId.getName(), artifactId.getGuid());
- }
+ ArtifactId artifactId = tx.createArtifact(OAUTH_TYPES);
InputStream stream = null;
try {
stream = resource.getInput();
@@ -188,6 +187,7 @@ public class ClientStorage {
Lib.close(stream);
}
tx.commit();
+
reloadTypes();
}
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/JdbcJaxRsOAuthStorage.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/JdbcJaxRsOAuthStorage.java
index 92330e5c58a..5a9c95faec6 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/JdbcJaxRsOAuthStorage.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/JdbcJaxRsOAuthStorage.java
@@ -11,6 +11,8 @@
package org.eclipse.osee.orcs.account.admin.internal.oauth;
import java.util.List;
+import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.TokenFactory;
import org.eclipse.osee.framework.jdk.core.type.OseePrincipal;
import org.eclipse.osee.jaxrs.server.security.JaxRsOAuthStorage;
import org.eclipse.osee.jaxrs.server.security.OAuthClient;
@@ -107,45 +109,47 @@ public class JdbcJaxRsOAuthStorage implements JaxRsOAuthStorage {
}
@Override
- public void storeClient(OseePrincipal principal, OAuthClient client) {
+ public ArtifactId storeClient(OseePrincipal principal, OAuthClient client) {
+ ArtifactId clientArtId;
ClientStorage clientStorage = getClientStorage();
- boolean exists = clientStorage.exists(client.getGuid());
+ boolean exists = clientStorage.exists(client.getClientUuid());
if (exists) {
clientStorage.update(principal, client);
+ clientArtId = TokenFactory.createArtifactId(client.getClientUuid());
} else {
- clientStorage.insert(principal, client);
+ clientArtId = clientStorage.insert(principal, client);
}
- ArtifactReadable artifact = clientStorage.getClientByClientGuid(client.getGuid()).getExactlyOne();
-
- long clientId = client.getClientUuid();
+ long clientId = clientArtId.getUuid();
+ ArtifactReadable artifact = clientStorage.getClientByClientUuid(clientId).getExactlyOne();
long applicationId = artifact.getLocalId();
- OAuthClientCredential credential = asCredential(client, applicationId);
+ OAuthClientCredential credential = asCredential(clientId, client, applicationId);
if (credentialStorage.getByClientIdAndApplicationId(clientId, applicationId) != null) {
credentialStorage.update(credential);
} else {
credentialStorage.insert(credential);
}
+ return clientArtId;
}
- OAuthClientCredential asCredential(OAuthClient client, long applicationId) {
- long clientId = client.getClientUuid();
+ OAuthClientCredential asCredential(Long clientUuid, OAuthClient client, Long applicationId) {
long subjectId = client.getSubjectId();
String clientKey = client.getClientId();
String clientSecret = client.getClientSecret();
List<String> clientCerts = client.getApplicationCertificates();
- return credentialStorage.newCredential(clientId, applicationId, subjectId, clientKey, clientSecret, clientCerts);
+ return credentialStorage.newCredential(clientUuid, applicationId, subjectId, clientKey, clientSecret,
+ clientCerts);
}
@Override
public void removeClient(OseePrincipal principal, OAuthClient client) {
getClientStorage().delete(principal, client);
- OAuthClientCredential credential = asCredential(client, -1L);
+ OAuthClientCredential credential = asCredential(client.getClientUuid(), client, -1L);
credentialStorage.delete(credential);
}
@@ -170,6 +174,20 @@ public class JdbcJaxRsOAuthStorage implements JaxRsOAuthStorage {
}
@Override
+ public OAuthClient getClientByClientUuid(Long uuid) {
+ OAuthClient client = null;
+ ClientStorage clientStorage = getClientStorage();
+ ArtifactReadable artifact = clientStorage.getClientByClientUuid(uuid).getOneOrNull();
+ if (artifact != null) {
+ Integer applicationId = artifact.getLocalId();
+
+ OAuthClientCredential credential = credentialStorage.getByApplicationId(applicationId);
+ client = clientStorage.newClient(artifact, credential);
+ }
+ return client;
+ }
+
+ @Override
public OAuthClient getClientByClientKey(String clientKey) {
OAuthClientCredential credential = credentialStorage.getByClientKey(clientKey);
OAuthClient client = null;
diff --git a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/OAuthTypes.java b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/OAuthTypes.java
index 33384075171..88e30e83aca 100644
--- a/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/OAuthTypes.java
+++ b/plugins/org.eclipse.osee.orcs.account.admin/src/org/eclipse/osee/orcs/account/admin/internal/oauth/OAuthTypes.java
@@ -10,11 +10,11 @@
*******************************************************************************/
package org.eclipse.osee.orcs.account.admin.internal.oauth;
-import org.eclipse.osee.framework.core.data.ArtifactId;
+import org.eclipse.osee.framework.core.data.IArtifactToken;
import org.eclipse.osee.framework.core.data.IArtifactType;
import org.eclipse.osee.framework.core.data.IAttributeType;
import org.eclipse.osee.framework.core.data.TokenFactory;
-import org.eclipse.osee.orcs.utility.OrcsUtil;
+import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
/**
* @author Roberto E. Escobar
@@ -30,17 +30,17 @@ public final class OAuthTypes {
public static final IAttributeType OAUTH_CLIENT_WEBSITE_URI = TokenFactory.createAttributeType(0x6C96C4E7AA77D058L, "Website URL");
public static final IAttributeType OAUTH_CLIENT_LOGO_URI = TokenFactory.createAttributeType(0x6CDB5B52A133AFB1L, "Logo URL");
-
+
public static final IAttributeType OAUTH_CLIENT_IS_CONFIDENTIAL = TokenFactory.createAttributeType(0x0774F815D1F9E731L, "Is Confidential");
public static final IAttributeType OAUTH_CLIENT_PROPERTIES = TokenFactory.createAttributeType(0x4E2EA052F480510AL, "Properties");
-
+
public static final IAttributeType OAUTH_CLIENT_AUTHORIZED_GRANT_TYPE = TokenFactory.createAttributeType(0x1ADA826121357000L, "Authorized Grant Type");
public static final IAttributeType OAUTH_CLIENT_AUTHORIZED_REDIRECT_URI = TokenFactory.createAttributeType(0x4B4665B8E1002F28L, "Authorized Redirect URI");
public static final IAttributeType OAUTH_CLIENT_AUTHORIZED_SCOPE = TokenFactory.createAttributeType(0x315964489A850F7AL, "Authorized Scope");
public static final IAttributeType OAUTH_CLIENT_AUTHORIZED_AUDIENCE = TokenFactory.createAttributeType(0x635EBFA0D4A82E22L, "Authorized Audience");
- // @formatter:on
- public static final ArtifactId OAUTH_TYPES_ARTIFACT =
- OrcsUtil.newArtifactId(77964317L, "AmgrOMuL6U7uL9hBWCAA", "OAuthTypes");
+ public static final IArtifactToken OAUTH_TYPES = TokenFactory.createArtifactToken(7067755L, "OAuthTypes", CoreArtifactTypes.OseeTypeDefinition);
+
+ // @formatter:on
}

Back to the top