@@ -179,7 +179,7 @@ public Response addUser(@PathParam("vaultId") UUID vaultId, @PathParam("userId")
179179 var vault = vaultRepo .findById (vaultId ); // should always be found, since @VaultRole filter would have triggered
180180 var user = userRepo .findByIdOptional (userId ).orElseThrow (NotFoundException ::new );
181181 var usedSeats = effectiveVaultAccessRepo .countSeatOccupyingUsers ();
182- if (usedSeats < license .getSeats () // free seats available
182+ if (usedSeats < license .getEntitlements (). seats () // free seats available
183183 || effectiveVaultAccessRepo .isUserOccupyingSeat (userId )) { // or user already sitting
184184 return addAuthority (vault , user , role );
185185 } else {
@@ -206,7 +206,7 @@ public Response addGroup(@PathParam("vaultId") UUID vaultId, @PathParam("groupId
206206 var group = groupRepo .findByIdOptional (groupId ).orElseThrow (NotFoundException ::new );
207207
208208 //usersInGroup - usersInGroupAndPartOfAtLeastOneVault + usersOfAtLeastOneVault
209- if (userRepo .countEffectiveGroupUsers (groupId ) - effectiveVaultAccessRepo .countSeatOccupyingUsersOfGroup (groupId ) + effectiveVaultAccessRepo .countSeatOccupyingUsers () > license .getSeats ()) {
209+ if (userRepo .countEffectiveGroupUsers (groupId ) - effectiveVaultAccessRepo .countSeatOccupyingUsersOfGroup (groupId ) + effectiveVaultAccessRepo .countSeatOccupyingUsers () > license .getEntitlements (). seats ()) {
210210 throw new PaymentRequiredException ("Adding this group would exceed available license seats." );
211211 }
212212
@@ -286,16 +286,24 @@ public Response legacyUnlock(@PathParam("vaultId") UUID vaultId, @PathParam("dev
286286 }
287287
288288 var accessTokenSeats = effectiveVaultAccessRepo .countSeatOccupyingUsersWithAccessToken ();
289- if (accessTokenSeats > license .getSeats ()) {
289+ if (accessTokenSeats > license .getEntitlements (). seats ()) {
290290 throw new PaymentRequiredException ("Number of effective vault users exceeds available license seats" );
291291 }
292292 var ipAddress = request .remoteAddress ().hostAddress ();
293293 try {
294294 var access = legacyAccessTokenRepo .unlock (vaultId , deviceId , jwt .getSubject ());
295295 eventLogger .logVaultKeyRetrieved (jwt .getSubject (), vaultId , VaultKeyRetrievedEvent .Result .SUCCESS , ipAddress , deviceId );
296- var subscriptionStateHeaderName = "Hub-Subscription-State" ;
297- var subscriptionStateHeaderValue = license .isSet () ? "ACTIVE" : "INACTIVE" ; // license expiration is not checked here, because it is checked in the ActiveLicense filter
298- return Response .ok (access .getJwe ()).header (subscriptionStateHeaderName , subscriptionStateHeaderValue ).build ();
296+ var response = Response .ok (access .getJwe ());
297+ var iosLicense = license .getEntitlements ().iosLicense ();
298+ var androidLicense = license .getEntitlements ().androidLicense ();
299+ if (iosLicense != null ) {
300+ response = response .header ("Hub-Subscription-State" , "ACTIVE" ); // license expiration is not checked here, because it is checked in the ActiveLicense filter
301+ response = response .header ("Hub-iOS-License" , iosLicense );
302+ }
303+ if (androidLicense != null ) {
304+ response = response .header ("Hub-Android-License" , androidLicense );
305+ }
306+ return response .build ();
299307 } catch (NoResultException e ) {
300308 eventLogger .logVaultKeyRetrieved (jwt .getSubject (), vaultId , VaultKeyRetrievedEvent .Result .UNAUTHORIZED , ipAddress , deviceId );
301309 throw new ForbiddenException ("Access to this device not granted." );
@@ -322,7 +330,7 @@ public Response unlock(@PathParam("vaultId") UUID vaultId, @QueryParam("evenIfAr
322330 }
323331
324332 var accessTokenSeats = effectiveVaultAccessRepo .countSeatOccupyingUsersWithAccessToken ();
325- if (accessTokenSeats > license .getSeats ()) {
333+ if (accessTokenSeats > license .getEntitlements (). seats ()) {
326334 throw new PaymentRequiredException ("Number of effective vault users exceeds available license seats" );
327335 }
328336
@@ -335,9 +343,17 @@ public Response unlock(@PathParam("vaultId") UUID vaultId, @QueryParam("evenIfAr
335343 var access = accessTokenRepo .unlock (vaultId , jwt .getSubject ());
336344 if (access != null ) {
337345 eventLogger .logVaultKeyRetrieved (jwt .getSubject (), vaultId , VaultKeyRetrievedEvent .Result .SUCCESS , ipAddress , deviceId );
338- var subscriptionStateHeaderName = "Hub-Subscription-State" ;
339- var subscriptionStateHeaderValue = license .isSet () ? "ACTIVE" : "INACTIVE" ; // license expiration is not checked here, because it is checked in the ActiveLicense filter
340- return Response .ok (access .getVaultKey (), MediaType .TEXT_PLAIN_TYPE ).header (subscriptionStateHeaderName , subscriptionStateHeaderValue ).build ();
346+ var response = Response .ok (access .getVaultKey (), MediaType .TEXT_PLAIN_TYPE );
347+ var iosLicense = license .getEntitlements ().iosLicense ();
348+ var androidLicense = license .getEntitlements ().androidLicense ();
349+ if (iosLicense != null ) {
350+ response = response .header ("Hub-Subscription-State" , "ACTIVE" ); // license expiration is not checked here, because it is checked in the ActiveLicense filter
351+ response = response .header ("Hub-iOS-License" , iosLicense );
352+ }
353+ if (androidLicense != null ) {
354+ response = response .header ("Hub-Android-License" , androidLicense );
355+ }
356+ return response .build ();
341357 } else if (vaultRepo .findById (vaultId ) == null ) {
342358 throw new NotFoundException ("No such vault." );
343359 } else {
@@ -364,7 +380,7 @@ public Response grantAccess(@PathParam("vaultId") UUID vaultId, @NotEmpty Map<St
364380 long occupiedSeats = effectiveVaultAccessRepo .countSeatOccupyingUsers ();
365381 long usersWithoutSeat = tokens .size () - effectiveVaultAccessRepo .countSeatsOccupiedByUsers (tokens .keySet ().stream ().toList ());
366382
367- if (occupiedSeats + usersWithoutSeat > license .getSeats ()) {
383+ if (occupiedSeats + usersWithoutSeat > license .getEntitlements (). seats ()) {
368384 throw new PaymentRequiredException ("Number of effective vault users greater than or equal to the available license seats" );
369385 }
370386
@@ -419,7 +435,7 @@ public Response createOrUpdate(@PathParam("vaultId") UUID vaultId, @Valid @NotNu
419435 } else {
420436 //if license is exceeded block vault creation, independent if the user is already sitting
421437 var usedSeats = effectiveVaultAccessRepo .countSeatOccupyingUsers ();
422- if (usedSeats > license .getSeats ()) {
438+ if (usedSeats > license .getEntitlements (). seats ()) {
423439 throw new PaymentRequiredException ("Number of effective vault users exceeds available license seats" );
424440 }
425441 // create new vault:
0 commit comments