Skip to content

Commit

Permalink
Updated console registration handling
Browse files Browse the repository at this point in the history
  • Loading branch information
richturner committed Oct 25, 2018
1 parent f31634f commit 61e219d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
Expand Up @@ -83,10 +83,6 @@ public ConsoleRegistration register(RequestParams requestParams, ConsoleRegistra
!isAuthenticated(), !isAuthenticated(),
true); true);


if (!isAuthenticated()) {
consoleAsset.setAccessPublicRead(true);
}

consoleAsset.setRealmId(getRequestTenant().getId()); consoleAsset.setRealmId(getRequestTenant().getId());
consoleAsset.setParentId(getConsoleParentAssetId(getRequestRealm())); consoleAsset.setParentId(getConsoleParentAssetId(getRequestRealm()));
consoleAsset.setId(consoleRegistration.getId()); consoleAsset.setId(consoleRegistration.getId());
Expand All @@ -96,27 +92,6 @@ public ConsoleRegistration register(RequestParams requestParams, ConsoleRegistra
throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST).entity(new ValidationFailure[] {new ValidationFailure(Asset.AssetTypeFailureReason.ASSET_TYPE_MISMATCH)}).build()); throw new BadRequestException(Response.status(Response.Status.BAD_REQUEST).entity(new ValidationFailure[] {new ValidationFailure(Asset.AssetTypeFailureReason.ASSET_TYPE_MISMATCH)}).build());
} }


// Check authenticated user is already linked to this console; if anonymous request then check console isn't linked to any users
if (isAuthenticated()) {
// Make asset private
consoleAsset.setAccessPublicRead(false);

// RT: Disabled below to allow multiple users to share a console (to support a shared device)
// List<UserAsset> consoleUserAssets = assetStorageService.findUserAssets(getAuthenticatedTenant().getId(),
// null,
// consoleRegistration.getId());
// if (consoleUserAssets.isEmpty()) {
// throw new WebApplicationException(FORBIDDEN);
// }
} else {
List<UserAsset> consoleUserAssets = assetStorageService.findUserAssets(getRequestTenant().getId(),
null,
consoleRegistration.getId());
if (!consoleUserAssets.isEmpty()) {
throw new WebApplicationException(FORBIDDEN);
}
}

ConsoleConfiguration.setConsoleName(consoleAsset, consoleRegistration.getName()); ConsoleConfiguration.setConsoleName(consoleAsset, consoleRegistration.getName());
ConsoleConfiguration.setConsolePlatform(consoleAsset, consoleRegistration.getPlatform()); ConsoleConfiguration.setConsolePlatform(consoleAsset, consoleRegistration.getPlatform());
ConsoleConfiguration.setConsoleVersion(consoleAsset, consoleRegistration.getVersion()); ConsoleConfiguration.setConsoleVersion(consoleAsset, consoleRegistration.getVersion());
Expand Down
Expand Up @@ -41,9 +41,9 @@ public interface ConsoleResource {
* Behind the scenes the console registration is converted into an asset and the {@link ConsoleRegistration} data is * Behind the scenes the console registration is converted into an asset and the {@link ConsoleRegistration} data is
* stored in the appropriate {@link Asset} {@link Attribute}s (see {@link ConsoleConfiguration} for more details). * stored in the appropriate {@link Asset} {@link Attribute}s (see {@link ConsoleConfiguration} for more details).
* <p> * <p>
* This is a public endpoint and allows the registration of anonymous consoles; if there is an authenticated user * This is a public endpoint and allows the registration of consoles anonymously; if there is an authenticated user
* then the console asset will be linked to that user. If multiple users login on the same console then it will be * registering the console then the console asset will be linked to that user. If multiple users login on the same
* associated with each user (i.e. a 1-many relationship). * console then it will be associated with each user (i.e. a 1-many relationship).
*/ */
@POST @POST
@Path("register") @Path("register")
Expand Down

0 comments on commit 61e219d

Please sign in to comment.