fix partey tags
This commit is contained in:
parent
67a66e3cb9
commit
cd05e008ae
@ -79,6 +79,11 @@ public class BorrowItemManager implements UserDataProvider {
|
||||
return borrowItemRepository.findById(id).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply slots.
|
||||
*
|
||||
* @param borrowItem the borrow item
|
||||
*/
|
||||
public void applySlots(BorrowItem borrowItem) {
|
||||
if (borrowItem != null) {
|
||||
switch (borrowItem.getAvailability()) {
|
||||
@ -103,11 +108,11 @@ public class BorrowItemManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @param search the search
|
||||
* @param search the search
|
||||
* @return the page
|
||||
*/
|
||||
public Page<BorrowItem> get(int page, int size, String sortBy, boolean descending,
|
||||
@ -127,12 +132,12 @@ public class BorrowItemManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the for user.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param userId the user id
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @param search the search
|
||||
* @param search the search
|
||||
* @return the for user
|
||||
*/
|
||||
public Page<BorrowItem> getForUser(Long userId, int page, int size, String sortBy,
|
||||
|
@ -68,10 +68,10 @@ public class BorrowRequestManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the for user.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param userId the user id
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the for user
|
||||
*/
|
||||
@ -82,15 +82,15 @@ public class BorrowRequestManager implements UserDataProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the for user and stauts.
|
||||
* Gets the for user and status.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @param status the status
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param userId the user id
|
||||
* @param status the status
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the for user and stauts
|
||||
* @return the for user and status
|
||||
*/
|
||||
public Page<BorrowRequest> getForUserAndStatus(Long userId, BorrowRequestStatus status,
|
||||
int page, int size, String sortBy, boolean descending) {
|
||||
@ -103,10 +103,10 @@ public class BorrowRequestManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the for owner.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param userId the user id
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the for owner
|
||||
*/
|
||||
@ -119,11 +119,11 @@ public class BorrowRequestManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the for owner and status.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @param status the status
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param userId the user id
|
||||
* @param status the status
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the for owner and status
|
||||
*/
|
||||
@ -165,7 +165,7 @@ public class BorrowRequestManager implements UserDataProvider {
|
||||
* Creates the code.
|
||||
*
|
||||
* @param borrowRequest the borrow request
|
||||
* @param issuer the issuer
|
||||
* @param issuer the issuer
|
||||
* @return the signed JWT
|
||||
* @throws JOSEException the JOSE exception
|
||||
*/
|
||||
@ -222,7 +222,7 @@ public class BorrowRequestManager implements UserDataProvider {
|
||||
*
|
||||
* @param jwt the jwt
|
||||
* @return true, if successful
|
||||
* @throws JOSEException the JOSE exception
|
||||
* @throws JOSEException the JOSE exception
|
||||
* @throws ParseException the parse exception
|
||||
*/
|
||||
public boolean verify(SignedJWT jwt) throws JOSEException, ParseException {
|
||||
|
@ -46,11 +46,12 @@ public class BorrowItemController extends BaseController {
|
||||
/**
|
||||
* Gets the borrow items.
|
||||
*
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParameter the sort parameter
|
||||
* @param descParameter the desc parameter
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParameter the sort parameter
|
||||
* @param descParameter the desc parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @param ownerParameter the owner parameter
|
||||
* @return the borrow items
|
||||
*/
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@ -95,9 +96,10 @@ public class BorrowItemController extends BaseController {
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete borrow item.
|
||||
* Gets the borrow item.
|
||||
*
|
||||
* @param id the id
|
||||
* @return the borrow item
|
||||
*/
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping("/{id}")
|
||||
|
@ -70,6 +70,7 @@ public class BorrowRequestController extends BaseController {
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParameter the sort parameter
|
||||
* @param descParameter the desc parameter
|
||||
* @param ownerParameter the owner parameter
|
||||
* @return the borrow requests
|
||||
*/
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@ -211,7 +212,7 @@ public class BorrowRequestController extends BaseController {
|
||||
/**
|
||||
* Gets the code.
|
||||
*
|
||||
* @param id the id
|
||||
* @param id the id
|
||||
* @param request the request
|
||||
* @return the code
|
||||
*/
|
||||
@ -249,8 +250,8 @@ public class BorrowRequestController extends BaseController {
|
||||
* Verfiy.
|
||||
*
|
||||
* @param serialized the serialized
|
||||
* @param request the request
|
||||
* @param response the response
|
||||
* @param request the request
|
||||
* @param response the response
|
||||
* @return the object
|
||||
*/
|
||||
@PostMapping("verify")
|
||||
|
@ -239,6 +239,8 @@ public class BorrowItem implements UserData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the availability.
|
||||
*
|
||||
* @return the availability
|
||||
*/
|
||||
public BorrowItemAvailability getAvailability() {
|
||||
@ -246,13 +248,17 @@ public class BorrowItem implements UserData {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param availability the availability to set
|
||||
* Sets the availability.
|
||||
*
|
||||
* @param availability the new availability
|
||||
*/
|
||||
public void setAvailability(BorrowItemAvailability availability) {
|
||||
this.availability = availability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the slots.
|
||||
*
|
||||
* @return the slots
|
||||
*/
|
||||
public List<? extends BorrowItemSlot> getSlots() {
|
||||
@ -260,7 +266,9 @@ public class BorrowItem implements UserData {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param slots the slots to set
|
||||
* Sets the slots.
|
||||
*
|
||||
* @param slots the new slots
|
||||
*/
|
||||
public void setSlots(List<? extends BorrowItemSlot> slots) {
|
||||
this.slots = slots;
|
||||
|
@ -22,6 +22,8 @@ public class BorrowItemManualSlot extends BorrowItemSlot {
|
||||
private Instant end;
|
||||
|
||||
/**
|
||||
* Gets the start.
|
||||
*
|
||||
* @return the start
|
||||
*/
|
||||
public Instant getStart() {
|
||||
@ -29,13 +31,17 @@ public class BorrowItemManualSlot extends BorrowItemSlot {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param start the start to set
|
||||
* Sets the start.
|
||||
*
|
||||
* @param start the new start
|
||||
*/
|
||||
public void setStart(Instant start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the end.
|
||||
*
|
||||
* @return the end
|
||||
*/
|
||||
public Instant getEnd() {
|
||||
@ -43,7 +49,9 @@ public class BorrowItemManualSlot extends BorrowItemSlot {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param end the end to set
|
||||
* Sets the end.
|
||||
*
|
||||
* @param end the new end
|
||||
*/
|
||||
public void setEnd(Instant end) {
|
||||
this.end = end;
|
||||
|
@ -31,56 +31,72 @@ public class BorrowItemPeriodSlot extends BorrowItemSlot {
|
||||
private LocalTime endTime;
|
||||
|
||||
/**
|
||||
* @return the startDay
|
||||
* Gets the start day.
|
||||
*
|
||||
* @return the start day
|
||||
*/
|
||||
public DayOfWeek getStartDay() {
|
||||
return startDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param startDay the startDay to set
|
||||
* Sets the start day.
|
||||
*
|
||||
* @param startDay the new start day
|
||||
*/
|
||||
public void setStartDay(DayOfWeek startDay) {
|
||||
this.startDay = startDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the startTime
|
||||
* Gets the start time.
|
||||
*
|
||||
* @return the start time
|
||||
*/
|
||||
public LocalTime getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param startTime the startTime to set
|
||||
* Sets the start time.
|
||||
*
|
||||
* @param startTime the new start time
|
||||
*/
|
||||
public void setStartTime(LocalTime startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the endDay
|
||||
* Gets the end day.
|
||||
*
|
||||
* @return the end day
|
||||
*/
|
||||
public DayOfWeek getEndDay() {
|
||||
return endDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param endDay the endDay to set
|
||||
* Sets the end day.
|
||||
*
|
||||
* @param endDay the new end day
|
||||
*/
|
||||
public void setEndDay(DayOfWeek endDay) {
|
||||
this.endDay = endDay;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the endTime
|
||||
* Gets the end time.
|
||||
*
|
||||
* @return the end time
|
||||
*/
|
||||
public LocalTime getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param endTime the endTime to set
|
||||
* Sets the end time.
|
||||
*
|
||||
* @param endTime the new end time
|
||||
*/
|
||||
public void setEndTime(LocalTime endTime) {
|
||||
this.endTime = endTime;
|
||||
|
@ -36,6 +36,8 @@ public abstract class BorrowItemSlot {
|
||||
private Long item;
|
||||
|
||||
/**
|
||||
* Gets the id.
|
||||
*
|
||||
* @return the id
|
||||
*/
|
||||
public Long getId() {
|
||||
@ -43,13 +45,17 @@ public abstract class BorrowItemSlot {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id the id to set
|
||||
* Sets the id.
|
||||
*
|
||||
* @param id the new id
|
||||
*/
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the item.
|
||||
*
|
||||
* @return the item
|
||||
*/
|
||||
public Long getItem() {
|
||||
@ -57,7 +63,9 @@ public abstract class BorrowItemSlot {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param item the item to set
|
||||
* Sets the item.
|
||||
*
|
||||
* @param item the new item
|
||||
*/
|
||||
public void setItem(Long item) {
|
||||
this.item = item;
|
||||
|
@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository;
|
||||
import de.bstly.we.borrow.model.BorrowItemManualSlot;
|
||||
|
||||
/**
|
||||
* The Interface BorrowItemRepository.
|
||||
* The Interface BorrowItemManualSlotRepository.
|
||||
*/
|
||||
@Repository
|
||||
public interface BorrowItemManualSlotRepository extends JpaRepository<BorrowItemManualSlot, Long>,
|
||||
|
@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository;
|
||||
import de.bstly.we.borrow.model.BorrowItemPeriodSlot;
|
||||
|
||||
/**
|
||||
* The Interface BorrowItemRepository.
|
||||
* The Interface BorrowItemPeriodSlotRepository.
|
||||
*/
|
||||
@Repository
|
||||
public interface BorrowItemPeriodSlotRepository extends JpaRepository<BorrowItemPeriodSlot, Long>,
|
||||
|
@ -10,7 +10,7 @@ import org.springframework.data.repository.NoRepositoryBean;
|
||||
import de.bstly.we.borrow.model.BorrowItemSlot;
|
||||
|
||||
/**
|
||||
* The Interface BorrowItemRepository.
|
||||
* The Interface BorrowItemSlotRepository.
|
||||
*/
|
||||
@NoRepositoryBean
|
||||
public interface BorrowItemSlotRepository
|
||||
|
@ -24,9 +24,8 @@ public interface BorrowRequestRepository
|
||||
/**
|
||||
* Find all by owner.
|
||||
*
|
||||
* @param owner the owner
|
||||
* @param pageable the pageable
|
||||
* @return the page
|
||||
* @param owner the owner
|
||||
* @return the iterable
|
||||
*/
|
||||
@Query("SELECT request FROM BorrowRequest request INNER JOIN BorrowItem item ON request.item = item.id WHERE item.owner = :owner")
|
||||
Iterable<BorrowRequest> findAllByOwner(@Param("owner") Long owner);
|
||||
@ -34,7 +33,7 @@ public interface BorrowRequestRepository
|
||||
/**
|
||||
* Find all by owner.
|
||||
*
|
||||
* @param owner the owner
|
||||
* @param owner the owner
|
||||
* @param pageable the pageable
|
||||
* @return the page
|
||||
*/
|
||||
@ -44,8 +43,8 @@ public interface BorrowRequestRepository
|
||||
/**
|
||||
* Find all by owner and status.
|
||||
*
|
||||
* @param owner the owner
|
||||
* @param status the status
|
||||
* @param owner the owner
|
||||
* @param status the status
|
||||
* @param pageable the pageable
|
||||
* @return the page
|
||||
*/
|
||||
|
@ -38,7 +38,6 @@ public class UserDataManagementController extends BaseController {
|
||||
* Gets the for user.
|
||||
*
|
||||
* @param username the username
|
||||
* @return
|
||||
* @return the for user
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@ -68,7 +67,7 @@ public class UserDataManagementController extends BaseController {
|
||||
* Purge by username.
|
||||
*
|
||||
* @param username the username
|
||||
* @param dry the dry
|
||||
* @param dry the dry
|
||||
*/
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@PostMapping("/purge/{username}")
|
||||
|
@ -63,8 +63,8 @@ public class InviteManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param search the search
|
||||
* @return the page
|
||||
*/
|
||||
@ -89,14 +89,14 @@ public class InviteManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the by owner.
|
||||
*
|
||||
* @param owner the owner
|
||||
* @param item the item
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param owner the owner
|
||||
* @param quota the quota
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @param search the search
|
||||
* @param redeemed the redeemed
|
||||
* @param search the search
|
||||
* @param redeemed the redeemed
|
||||
* @return the by owner
|
||||
*/
|
||||
public Page<Invite> getByOwner(Long owner, String quota, int page, int size, String sortBy,
|
||||
@ -129,11 +129,11 @@ public class InviteManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the others.
|
||||
*
|
||||
* @param owner the owner
|
||||
* @param item the item
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param search the search
|
||||
* @param owner the owner
|
||||
* @param quota the quota
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param search the search
|
||||
* @param redeemed the redeemed
|
||||
* @return the others
|
||||
*/
|
||||
|
@ -44,10 +44,11 @@ public class InviteMappingManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by item.
|
||||
* Gets the by item and quota.
|
||||
*
|
||||
* @param item the item
|
||||
* @return the by item
|
||||
* @param quota the quota
|
||||
* @return the by item and quota
|
||||
*/
|
||||
public InviteMapping getByItemAndQuota(int item, String quota) {
|
||||
return inviteMappingRepository
|
||||
@ -58,9 +59,9 @@ public class InviteMappingManager {
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the page
|
||||
*/
|
||||
@ -72,9 +73,9 @@ public class InviteMappingManager {
|
||||
/**
|
||||
* Creates the.
|
||||
*
|
||||
* @param quota the quota
|
||||
* @param item the item
|
||||
* @param starts the starts
|
||||
* @param quota the quota
|
||||
* @param item the item
|
||||
* @param starts the starts
|
||||
* @param expires the expires
|
||||
* @return the invite mapping
|
||||
*/
|
||||
|
@ -104,6 +104,12 @@ public class InviteController extends BaseController {
|
||||
return invite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the permissions.
|
||||
*
|
||||
* @param code the code
|
||||
* @return the permissions
|
||||
*/
|
||||
@GetMapping("/{code}/permissions")
|
||||
public List<Permission> getPermissions(@PathVariable("code") String code) {
|
||||
Invite invite = inviteManager.getByCode(code);
|
||||
@ -115,6 +121,12 @@ public class InviteController extends BaseController {
|
||||
invite.getStarts(), invite.getExpires());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the quotas.
|
||||
*
|
||||
* @param code the code
|
||||
* @return the quotas
|
||||
*/
|
||||
@GetMapping("/{code}/quotas")
|
||||
public List<Quota> getQuotas(@PathVariable("code") String code) {
|
||||
Invite invite = inviteManager.getByCode(code);
|
||||
@ -213,12 +225,12 @@ public class InviteController extends BaseController {
|
||||
/**
|
||||
* Gets the invites.
|
||||
*
|
||||
* @param quotaParameter the quota parameter
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParamater the sort paramater
|
||||
* @param descParameter the desc parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @param quotaParameter the quota parameter
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param sortParamater the sort paramater
|
||||
* @param descParameter the desc parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @param redeemedParameter the redeemed parameter
|
||||
* @return the invites
|
||||
*/
|
||||
@ -241,10 +253,10 @@ public class InviteController extends BaseController {
|
||||
/**
|
||||
* Gets the other invites.
|
||||
*
|
||||
* @param quota the quota
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @param quota the quota
|
||||
* @param pageParameter the page parameter
|
||||
* @param sizeParameter the size parameter
|
||||
* @param searchParameter the search parameter
|
||||
* @param redeemedParameter the redeemed parameter
|
||||
* @return the other invites
|
||||
*/
|
||||
@ -279,7 +291,7 @@ public class InviteController extends BaseController {
|
||||
/**
|
||||
* Creates the invite.
|
||||
*
|
||||
* @param quota the quota
|
||||
* @param quota the quota
|
||||
* @param inviteModel the invite model
|
||||
* @return the invite
|
||||
*/
|
||||
|
@ -44,8 +44,8 @@ public class InviteManagingController extends BaseController {
|
||||
/**
|
||||
* Gets the invites.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param search the search
|
||||
* @return the invites
|
||||
*/
|
||||
|
@ -112,6 +112,8 @@ public class Invite implements UserData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the quota.
|
||||
*
|
||||
* @return the quota
|
||||
*/
|
||||
public String getQuota() {
|
||||
@ -119,7 +121,9 @@ public class Invite implements UserData {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param quota the quota to set
|
||||
* Sets the quota.
|
||||
*
|
||||
* @param quota the new quota
|
||||
*/
|
||||
public void setQuota(String quota) {
|
||||
this.quota = quota;
|
||||
@ -234,6 +238,8 @@ public class Invite implements UserData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
@ -241,7 +247,9 @@ public class Invite implements UserData {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url the url to set
|
||||
* Sets the url.
|
||||
*
|
||||
* @param url the new url
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
|
@ -139,6 +139,8 @@ public class InviteMapping {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the url.
|
||||
*
|
||||
* @return the url
|
||||
*/
|
||||
public String getUrl() {
|
||||
@ -146,7 +148,9 @@ public class InviteMapping {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url the url to set
|
||||
* Sets the url.
|
||||
*
|
||||
* @param url the new url
|
||||
*/
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
|
@ -59,7 +59,7 @@ public class JwtKeyManager {
|
||||
/**
|
||||
* Gets the jwk set.
|
||||
*
|
||||
* @param name the name
|
||||
* @param name the name
|
||||
* @param createDefault the create default
|
||||
* @return the jwk set
|
||||
*/
|
||||
@ -91,7 +91,7 @@ public class JwtKeyManager {
|
||||
/**
|
||||
* Gets the latest.
|
||||
*
|
||||
* @param name the name
|
||||
* @param name the name
|
||||
* @param createDefault the create default
|
||||
* @return the latest
|
||||
*/
|
||||
@ -140,6 +140,13 @@ public class JwtKeyManager {
|
||||
return jwtKeyRepository.findOne(qJwtKey.keyID.eq(keyID)).orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the by created.
|
||||
*
|
||||
* @param name the name
|
||||
* @param created the created
|
||||
* @return the by created
|
||||
*/
|
||||
@Transactional
|
||||
public JwtKey getByCreated(String name, Instant created) {
|
||||
return jwtKeyRepository
|
||||
@ -229,7 +236,7 @@ public class JwtKeyManager {
|
||||
/**
|
||||
* Gets the jws algorithm.
|
||||
*
|
||||
* @param name the name
|
||||
* @param name the name
|
||||
* @param createDefault the create default
|
||||
* @return the jws algorithm
|
||||
*/
|
||||
|
@ -24,8 +24,7 @@ import de.bstly.we.jwt.model.JwtKey;
|
||||
import de.bstly.we.model.User;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
* The Class JwtUserManager.
|
||||
*/
|
||||
@Component
|
||||
public class JwtUserManager {
|
||||
@ -37,6 +36,16 @@ public class JwtUserManager {
|
||||
|
||||
public static final String JWT_USER_DATA_KEY_NAME = "user";
|
||||
|
||||
/**
|
||||
* Creates the signed jwt.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @param data the data
|
||||
* @param issuer the issuer
|
||||
* @param lifetime the lifetime
|
||||
* @return the signed JWT
|
||||
* @throws JOSEException the JOSE exception
|
||||
*/
|
||||
public SignedJWT createSignedJwt(Long userId, Object data, String issuer, Long lifetime)
|
||||
throws JOSEException {
|
||||
User user = userManager.get(userId);
|
||||
@ -72,6 +81,14 @@ public class JwtUserManager {
|
||||
return jwt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify.
|
||||
*
|
||||
* @param jwt the jwt
|
||||
* @return true, if successful
|
||||
* @throws JOSEException the JOSE exception
|
||||
* @throws ParseException the parse exception
|
||||
*/
|
||||
public boolean verify(SignedJWT jwt) throws JOSEException, ParseException {
|
||||
if (jwt.getHeader() == null || !StringUtils.hasText(jwt.getHeader().getKeyID())) {
|
||||
throw new KeySourceException("No KeyID provided!");
|
||||
|
@ -27,8 +27,7 @@ import de.bstly.we.controller.support.EntityResponseStatusException;
|
||||
import de.bstly.we.jwt.businesslogic.JwtUserManager;
|
||||
|
||||
/**
|
||||
* @author Lurkars
|
||||
*
|
||||
* The Class JwtUserDataController.
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/jwt/user")
|
||||
@ -40,6 +39,12 @@ public class JwtUserDataController extends BaseController {
|
||||
@Value("${bstly.we.jwtUserIssuer:}")
|
||||
private String jwtUserIssuer;
|
||||
|
||||
/**
|
||||
* Creates the signed jwt auth.
|
||||
*
|
||||
* @param request the request
|
||||
* @return the string
|
||||
*/
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@GetMapping("/auth")
|
||||
public String createSignedJwtAuth(HttpServletRequest request) {
|
||||
@ -62,6 +67,13 @@ public class JwtUserDataController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the signed jwt.
|
||||
*
|
||||
* @param data the data
|
||||
* @param request the request
|
||||
* @return the string
|
||||
*/
|
||||
@PreAuthorize("isAuthenticated()")
|
||||
@PostMapping("/create")
|
||||
public String createSignedJwt(@RequestBody Object data, HttpServletRequest request) {
|
||||
@ -84,6 +96,14 @@ public class JwtUserDataController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Verfiy.
|
||||
*
|
||||
* @param serialized the serialized
|
||||
* @param request the request
|
||||
* @param response the response
|
||||
* @return the object
|
||||
*/
|
||||
@PostMapping("verify")
|
||||
public Object verfiy(@RequestBody String serialized, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
|
@ -72,6 +72,9 @@ public class OidcTokenManager implements SmartInitializingSingleton {
|
||||
* @see org.springframework.beans.factory.SmartInitializingSingleton#
|
||||
* afterSingletonsInstantiated()
|
||||
*/
|
||||
/*
|
||||
* @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated()
|
||||
*/
|
||||
/*
|
||||
* @see org.springframework.beans.factory.SmartInitializingSingleton#
|
||||
* afterSingletonsInstantiated()
|
||||
@ -119,7 +122,7 @@ public class OidcTokenManager implements SmartInitializingSingleton {
|
||||
*
|
||||
* @param client the client
|
||||
* @param userId the user id
|
||||
* @param nonce the nonce
|
||||
* @param nonce the nonce
|
||||
* @param scopes the scopes
|
||||
* @param issuer the issuer
|
||||
* @return the oidc token
|
||||
|
@ -40,9 +40,9 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the all.
|
||||
*
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the all
|
||||
*/
|
||||
@ -60,11 +60,8 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
* @return the all by user id
|
||||
*/
|
||||
public List<ParteyUserTag> getAllByUserId(Long userId) {
|
||||
User user = userManager.get(userId);
|
||||
Assert.notNull(user, "invalid userId: '"
|
||||
+ userId
|
||||
+ "'!");
|
||||
return getAllForUsername(user.getUsername());
|
||||
return Lists
|
||||
.newArrayList(parteyUserTagRepository.findAll(qParteyUserTag.target.eq(userId)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,16 +77,22 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the non expired by user id.
|
||||
*
|
||||
* @param userId the user id
|
||||
* @param userId the user id
|
||||
* @param upcoming the upcoming
|
||||
* @return the non expired by user id
|
||||
*/
|
||||
public List<ParteyUserTag> getNonExpiredByUserId(Long userId, boolean upcoming) {
|
||||
User user = userManager.get(userId);
|
||||
Assert.notNull(user, "invalid userId: '"
|
||||
+ userId
|
||||
+ "'!");
|
||||
return getNonExpiredForUsername(user.getUsername(), upcoming);
|
||||
BooleanBuilder query = new BooleanBuilder();
|
||||
|
||||
query.and(qParteyUserTag.target.eq(userId));
|
||||
query.and(qParteyUserTag.expires.isNull().or(qParteyUserTag.expires.after(Instant.now())));
|
||||
|
||||
if (!upcoming) {
|
||||
query.and(
|
||||
qParteyUserTag.starts.isNull().or(qParteyUserTag.starts.before(Instant.now())));
|
||||
}
|
||||
|
||||
return Lists.newArrayList(parteyUserTagRepository.findAll(query.getValue()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -99,8 +102,11 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
* @return the all for username
|
||||
*/
|
||||
public List<ParteyUserTag> getAllForUsername(String username) {
|
||||
return Lists.newArrayList(parteyUserTagRepository
|
||||
.findAll(qParteyUserTag.username.equalsIgnoreCase(username)));
|
||||
User user = userManager.getByUsername(username);
|
||||
Assert.notNull(user, "invalid username: '"
|
||||
+ username
|
||||
+ "'!");
|
||||
return getAllByUserId(user.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -110,6 +116,7 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
* @return the non expired for username
|
||||
*/
|
||||
public List<ParteyUserTag> getNonExpiredForUsername(String username) {
|
||||
|
||||
return getNonExpiredForUsername(username, false);
|
||||
}
|
||||
|
||||
@ -121,18 +128,11 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
* @return the non expired for username
|
||||
*/
|
||||
public List<ParteyUserTag> getNonExpiredForUsername(String username, boolean upcoming) {
|
||||
|
||||
BooleanBuilder query = new BooleanBuilder();
|
||||
|
||||
query.and(qParteyUserTag.username.equalsIgnoreCase(username));
|
||||
query.and(qParteyUserTag.expires.isNull().or(qParteyUserTag.expires.after(Instant.now())));
|
||||
|
||||
if (!upcoming) {
|
||||
query.and(
|
||||
qParteyUserTag.starts.isNull().or(qParteyUserTag.starts.before(Instant.now())));
|
||||
}
|
||||
|
||||
return Lists.newArrayList(parteyUserTagRepository.findAll(query.getValue()));
|
||||
User user = userManager.getByUsername(username);
|
||||
Assert.notNull(user, "invalid username: '"
|
||||
+ username
|
||||
+ "'!");
|
||||
return getNonExpiredByUserId(user.getId(), upcoming);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,18 +151,18 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
* @param parteyUserTag the partey user tag
|
||||
*/
|
||||
public void delete(ParteyUserTag parteyUserTag) {
|
||||
parteyUserTagRepository.deleteById(
|
||||
new ParteyUserTagId(parteyUserTag.getUsername(), parteyUserTag.getTag()));
|
||||
parteyUserTagRepository
|
||||
.deleteById(new ParteyUserTagId(parteyUserTag.getTarget(), parteyUserTag.getTag()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all for target.
|
||||
*
|
||||
* @param username the username
|
||||
* @param target the target
|
||||
*/
|
||||
public void deleteAllForTarget(String username) {
|
||||
parteyUserTagRepository.deleteAll(parteyUserTagRepository
|
||||
.findAll(qParteyUserTag.username.equalsIgnoreCase(username)));
|
||||
public void deleteAllForTarget(Long target) {
|
||||
parteyUserTagRepository
|
||||
.deleteAll(parteyUserTagRepository.findAll(qParteyUserTag.target.eq(target)));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -187,11 +187,7 @@ public class ParteyUserTagManager implements UserDataProvider {
|
||||
*/
|
||||
@Override
|
||||
public void purgeUserData(Long userId) {
|
||||
User user = userManager.get(userId);
|
||||
Assert.notNull(user, "invalid userId: '"
|
||||
+ userId
|
||||
+ "'!");
|
||||
deleteAllForTarget(user.getUsername());
|
||||
deleteAllForTarget(userId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
@ -56,7 +57,7 @@ public class UserTagManagementController extends BaseController {
|
||||
@RequestParam("desc") Optional<Boolean> descParameter) {
|
||||
|
||||
Page<ParteyUserTag> page = parteyUserTagManager.getAll(pageParameter.orElse(0),
|
||||
sizeParameter.orElse(10), sortParameter.orElse("username"),
|
||||
sizeParameter.orElse(10), sortParameter.orElse("target"),
|
||||
descParameter.orElse(false));
|
||||
|
||||
return page;
|
||||
@ -128,11 +129,21 @@ public class UserTagManagementController extends BaseController {
|
||||
@PreAuthorize("hasRole('ROLE_ADMIN')")
|
||||
@PostMapping
|
||||
public ParteyUserTag createOrUpdateParteyUserTag(@RequestBody ParteyUserTag parteyUserTag) {
|
||||
User user = userManager.getByUsername(parteyUserTag.getUsername());
|
||||
User user = null;
|
||||
|
||||
if (parteyUserTag.getTarget() != null && !parteyUserTag.getTarget().equals(0L)) {
|
||||
user = userManager.get(parteyUserTag.getTarget());
|
||||
} else if (StringUtils.hasText(parteyUserTag.getUsername())) {
|
||||
user = userManager.getByUsername(parteyUserTag.getUsername());
|
||||
}
|
||||
|
||||
if (user == null) {
|
||||
throw new EntityResponseStatusException(HttpStatus.CONFLICT);
|
||||
}
|
||||
|
||||
parteyUserTag.setTarget(user.getId());
|
||||
parteyUserTag.setUsername(user.getUsername());
|
||||
|
||||
return parteyUserTagManager.save(parteyUserTag);
|
||||
}
|
||||
|
||||
|
@ -24,30 +24,32 @@ import de.bstly.we.partey.model.ParteyUserTag.ParteyUserTagId;
|
||||
public class ParteyUserTag implements UserData {
|
||||
|
||||
@Id
|
||||
private String username;
|
||||
private Long target;
|
||||
@Id
|
||||
private String tag;
|
||||
@Column(name = "starts", nullable = true)
|
||||
private Instant starts;
|
||||
@Column(name = "expires", nullable = true)
|
||||
private Instant expires;
|
||||
@Column(name = "username", nullable = false)
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* Gets the username.
|
||||
* Gets the target.
|
||||
*
|
||||
* @return the username
|
||||
* @return the target
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
public Long getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username.
|
||||
* Sets the target.
|
||||
*
|
||||
* @param username the new username
|
||||
* @param target the new target
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
public void setTarget(Long target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,43 +106,69 @@ public class ParteyUserTag implements UserData {
|
||||
this.expires = expires;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username.
|
||||
*
|
||||
* @return the username
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username.
|
||||
*
|
||||
* @param username the new username
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Class ParteyUserTagId.
|
||||
*/
|
||||
public static class ParteyUserTagId implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String username;
|
||||
private Long target;
|
||||
private String tag;
|
||||
|
||||
/**
|
||||
* Instantiates a new partey user tag id.
|
||||
*/
|
||||
public ParteyUserTagId() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username
|
||||
* @param tag
|
||||
* Instantiates a new partey user tag id.
|
||||
*
|
||||
* @param target the target
|
||||
* @param tag the tag
|
||||
*/
|
||||
public ParteyUserTagId(String username, String tag) {
|
||||
public ParteyUserTagId(Long target, String tag) {
|
||||
super();
|
||||
this.username = username;
|
||||
this.target = target;
|
||||
this.tag = tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the username.
|
||||
* Gets the target.
|
||||
*
|
||||
* @return the username
|
||||
* @return the target
|
||||
*/
|
||||
public String getUsername() {
|
||||
return username;
|
||||
public Long getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username.
|
||||
* Sets the target.
|
||||
*
|
||||
* @param username the new username
|
||||
* @param target the new target
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
public void setTarget(Long target) {
|
||||
this.target = target;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,16 +64,16 @@ public class TimeslotManager implements UserDataProvider {
|
||||
/**
|
||||
* Gets the.
|
||||
*
|
||||
* @param owner the owner
|
||||
* @param owner the owner
|
||||
* @param invertOwner the invert owner
|
||||
* @param after the after
|
||||
* @param type the type
|
||||
* @param visibility the visibility
|
||||
* @param search the search
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @param after the after
|
||||
* @param type the type
|
||||
* @param visibility the visibility
|
||||
* @param search the search
|
||||
* @param page the page
|
||||
* @param size the size
|
||||
* @param sortBy the sort by
|
||||
* @param descending the descending
|
||||
* @return the page
|
||||
*/
|
||||
public Page<Timeslot> get(Long owner, boolean invertOwner, Instant after, TimeslotType type,
|
||||
|
Loading…
Reference in New Issue
Block a user