fix partey tags

This commit is contained in:
_Bastler 2021-10-28 13:20:22 +02:00
parent 67a66e3cb9
commit cd05e008ae
28 changed files with 336 additions and 183 deletions

View File

@ -79,6 +79,11 @@ public class BorrowItemManager implements UserDataProvider {
return borrowItemRepository.findById(id).orElse(null); return borrowItemRepository.findById(id).orElse(null);
} }
/**
* Apply slots.
*
* @param borrowItem the borrow item
*/
public void applySlots(BorrowItem borrowItem) { public void applySlots(BorrowItem borrowItem) {
if (borrowItem != null) { if (borrowItem != null) {
switch (borrowItem.getAvailability()) { switch (borrowItem.getAvailability()) {
@ -103,11 +108,11 @@ public class BorrowItemManager implements UserDataProvider {
/** /**
* Gets the. * Gets the.
* *
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @param search the search * @param search the search
* @return the page * @return the page
*/ */
public Page<BorrowItem> get(int page, int size, String sortBy, boolean descending, 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. * Gets the for user.
* *
* @param userId the user id * @param userId the user id
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @param search the search * @param search the search
* @return the for user * @return the for user
*/ */
public Page<BorrowItem> getForUser(Long userId, int page, int size, String sortBy, public Page<BorrowItem> getForUser(Long userId, int page, int size, String sortBy,

View File

@ -68,10 +68,10 @@ public class BorrowRequestManager implements UserDataProvider {
/** /**
* Gets the for user. * Gets the for user.
* *
* @param userId the user id * @param userId the user id
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @return the for user * @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 userId the user id
* @param status the status * @param status the status
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @return the for user and stauts * @return the for user and status
*/ */
public Page<BorrowRequest> getForUserAndStatus(Long userId, BorrowRequestStatus status, public Page<BorrowRequest> getForUserAndStatus(Long userId, BorrowRequestStatus status,
int page, int size, String sortBy, boolean descending) { int page, int size, String sortBy, boolean descending) {
@ -103,10 +103,10 @@ public class BorrowRequestManager implements UserDataProvider {
/** /**
* Gets the for owner. * Gets the for owner.
* *
* @param userId the user id * @param userId the user id
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @return the for owner * @return the for owner
*/ */
@ -119,11 +119,11 @@ public class BorrowRequestManager implements UserDataProvider {
/** /**
* Gets the for owner and status. * Gets the for owner and status.
* *
* @param userId the user id * @param userId the user id
* @param status the status * @param status the status
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @return the for owner and status * @return the for owner and status
*/ */
@ -165,7 +165,7 @@ public class BorrowRequestManager implements UserDataProvider {
* Creates the code. * Creates the code.
* *
* @param borrowRequest the borrow request * @param borrowRequest the borrow request
* @param issuer the issuer * @param issuer the issuer
* @return the signed JWT * @return the signed JWT
* @throws JOSEException the JOSE exception * @throws JOSEException the JOSE exception
*/ */
@ -222,7 +222,7 @@ public class BorrowRequestManager implements UserDataProvider {
* *
* @param jwt the jwt * @param jwt the jwt
* @return true, if successful * @return true, if successful
* @throws JOSEException the JOSE exception * @throws JOSEException the JOSE exception
* @throws ParseException the parse exception * @throws ParseException the parse exception
*/ */
public boolean verify(SignedJWT jwt) throws JOSEException, ParseException { public boolean verify(SignedJWT jwt) throws JOSEException, ParseException {

View File

@ -46,11 +46,12 @@ public class BorrowItemController extends BaseController {
/** /**
* Gets the borrow items. * Gets the borrow items.
* *
* @param pageParameter the page parameter * @param pageParameter the page parameter
* @param sizeParameter the size parameter * @param sizeParameter the size parameter
* @param sortParameter the sort parameter * @param sortParameter the sort parameter
* @param descParameter the desc parameter * @param descParameter the desc parameter
* @param searchParameter the search parameter * @param searchParameter the search parameter
* @param ownerParameter the owner parameter
* @return the borrow items * @return the borrow items
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@ -95,9 +96,10 @@ public class BorrowItemController extends BaseController {
} }
/** /**
* Delete borrow item. * Gets the borrow item.
* *
* @param id the id * @param id the id
* @return the borrow item
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@GetMapping("/{id}") @GetMapping("/{id}")

View File

@ -70,6 +70,7 @@ public class BorrowRequestController extends BaseController {
* @param sizeParameter the size parameter * @param sizeParameter the size parameter
* @param sortParameter the sort parameter * @param sortParameter the sort parameter
* @param descParameter the desc parameter * @param descParameter the desc parameter
* @param ownerParameter the owner parameter
* @return the borrow requests * @return the borrow requests
*/ */
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@ -211,7 +212,7 @@ public class BorrowRequestController extends BaseController {
/** /**
* Gets the code. * Gets the code.
* *
* @param id the id * @param id the id
* @param request the request * @param request the request
* @return the code * @return the code
*/ */
@ -249,8 +250,8 @@ public class BorrowRequestController extends BaseController {
* Verfiy. * Verfiy.
* *
* @param serialized the serialized * @param serialized the serialized
* @param request the request * @param request the request
* @param response the response * @param response the response
* @return the object * @return the object
*/ */
@PostMapping("verify") @PostMapping("verify")

View File

@ -239,6 +239,8 @@ public class BorrowItem implements UserData {
} }
/** /**
* Gets the availability.
*
* @return the availability * @return the availability
*/ */
public BorrowItemAvailability getAvailability() { 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) { public void setAvailability(BorrowItemAvailability availability) {
this.availability = availability; this.availability = availability;
} }
/** /**
* Gets the slots.
*
* @return the slots * @return the slots
*/ */
public List<? extends BorrowItemSlot> getSlots() { 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) { public void setSlots(List<? extends BorrowItemSlot> slots) {
this.slots = slots; this.slots = slots;

View File

@ -22,6 +22,8 @@ public class BorrowItemManualSlot extends BorrowItemSlot {
private Instant end; private Instant end;
/** /**
* Gets the start.
*
* @return the start * @return the start
*/ */
public Instant getStart() { 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) { public void setStart(Instant start) {
this.start = start; this.start = start;
} }
/** /**
* Gets the end.
*
* @return the end * @return the end
*/ */
public Instant getEnd() { 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) { public void setEnd(Instant end) {
this.end = end; this.end = end;

View File

@ -31,56 +31,72 @@ public class BorrowItemPeriodSlot extends BorrowItemSlot {
private LocalTime endTime; private LocalTime endTime;
/** /**
* @return the startDay * Gets the start day.
*
* @return the start day
*/ */
public DayOfWeek getStartDay() { public DayOfWeek getStartDay() {
return startDay; return startDay;
} }
/** /**
* @param startDay the startDay to set * Sets the start day.
*
* @param startDay the new start day
*/ */
public void setStartDay(DayOfWeek startDay) { public void setStartDay(DayOfWeek startDay) {
this.startDay = startDay; this.startDay = startDay;
} }
/** /**
* @return the startTime * Gets the start time.
*
* @return the start time
*/ */
public LocalTime getStartTime() { public LocalTime getStartTime() {
return startTime; return startTime;
} }
/** /**
* @param startTime the startTime to set * Sets the start time.
*
* @param startTime the new start time
*/ */
public void setStartTime(LocalTime startTime) { public void setStartTime(LocalTime startTime) {
this.startTime = startTime; this.startTime = startTime;
} }
/** /**
* @return the endDay * Gets the end day.
*
* @return the end day
*/ */
public DayOfWeek getEndDay() { public DayOfWeek getEndDay() {
return endDay; return endDay;
} }
/** /**
* @param endDay the endDay to set * Sets the end day.
*
* @param endDay the new end day
*/ */
public void setEndDay(DayOfWeek endDay) { public void setEndDay(DayOfWeek endDay) {
this.endDay = endDay; this.endDay = endDay;
} }
/** /**
* @return the endTime * Gets the end time.
*
* @return the end time
*/ */
public LocalTime getEndTime() { public LocalTime getEndTime() {
return endTime; return endTime;
} }
/** /**
* @param endTime the endTime to set * Sets the end time.
*
* @param endTime the new end time
*/ */
public void setEndTime(LocalTime endTime) { public void setEndTime(LocalTime endTime) {
this.endTime = endTime; this.endTime = endTime;

View File

@ -36,6 +36,8 @@ public abstract class BorrowItemSlot {
private Long item; private Long item;
/** /**
* Gets the id.
*
* @return the id * @return the id
*/ */
public Long getId() { 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) { public void setId(Long id) {
this.id = id; this.id = id;
} }
/** /**
* Gets the item.
*
* @return the item * @return the item
*/ */
public Long getItem() { 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) { public void setItem(Long item) {
this.item = item; this.item = item;

View File

@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.borrow.model.BorrowItemManualSlot; import de.bstly.we.borrow.model.BorrowItemManualSlot;
/** /**
* The Interface BorrowItemRepository. * The Interface BorrowItemManualSlotRepository.
*/ */
@Repository @Repository
public interface BorrowItemManualSlotRepository extends JpaRepository<BorrowItemManualSlot, Long>, public interface BorrowItemManualSlotRepository extends JpaRepository<BorrowItemManualSlot, Long>,

View File

@ -10,7 +10,7 @@ import org.springframework.stereotype.Repository;
import de.bstly.we.borrow.model.BorrowItemPeriodSlot; import de.bstly.we.borrow.model.BorrowItemPeriodSlot;
/** /**
* The Interface BorrowItemRepository. * The Interface BorrowItemPeriodSlotRepository.
*/ */
@Repository @Repository
public interface BorrowItemPeriodSlotRepository extends JpaRepository<BorrowItemPeriodSlot, Long>, public interface BorrowItemPeriodSlotRepository extends JpaRepository<BorrowItemPeriodSlot, Long>,

View File

@ -10,7 +10,7 @@ import org.springframework.data.repository.NoRepositoryBean;
import de.bstly.we.borrow.model.BorrowItemSlot; import de.bstly.we.borrow.model.BorrowItemSlot;
/** /**
* The Interface BorrowItemRepository. * The Interface BorrowItemSlotRepository.
*/ */
@NoRepositoryBean @NoRepositoryBean
public interface BorrowItemSlotRepository public interface BorrowItemSlotRepository

View File

@ -24,9 +24,8 @@ public interface BorrowRequestRepository
/** /**
* Find all by owner. * Find all by owner.
* *
* @param owner the owner * @param owner the owner
* @param pageable the pageable * @return the iterable
* @return the page
*/ */
@Query("SELECT request FROM BorrowRequest request INNER JOIN BorrowItem item ON request.item = item.id WHERE item.owner = :owner") @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); Iterable<BorrowRequest> findAllByOwner(@Param("owner") Long owner);
@ -34,7 +33,7 @@ public interface BorrowRequestRepository
/** /**
* Find all by owner. * Find all by owner.
* *
* @param owner the owner * @param owner the owner
* @param pageable the pageable * @param pageable the pageable
* @return the page * @return the page
*/ */
@ -44,8 +43,8 @@ public interface BorrowRequestRepository
/** /**
* Find all by owner and status. * Find all by owner and status.
* *
* @param owner the owner * @param owner the owner
* @param status the status * @param status the status
* @param pageable the pageable * @param pageable the pageable
* @return the page * @return the page
*/ */

View File

@ -38,7 +38,6 @@ public class UserDataManagementController extends BaseController {
* Gets the for user. * Gets the for user.
* *
* @param username the username * @param username the username
* @return
* @return the for user * @return the for user
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@ -68,7 +67,7 @@ public class UserDataManagementController extends BaseController {
* Purge by username. * Purge by username.
* *
* @param username the username * @param username the username
* @param dry the dry * @param dry the dry
*/ */
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping("/purge/{username}") @PostMapping("/purge/{username}")

View File

@ -63,8 +63,8 @@ public class InviteManager implements UserDataProvider {
/** /**
* Gets the. * Gets the.
* *
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param search the search * @param search the search
* @return the page * @return the page
*/ */
@ -89,14 +89,14 @@ public class InviteManager implements UserDataProvider {
/** /**
* Gets the by owner. * Gets the by owner.
* *
* @param owner the owner * @param owner the owner
* @param item the item * @param quota the quota
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @param search the search * @param search the search
* @param redeemed the redeemed * @param redeemed the redeemed
* @return the by owner * @return the by owner
*/ */
public Page<Invite> getByOwner(Long owner, String quota, int page, int size, String sortBy, 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. * Gets the others.
* *
* @param owner the owner * @param owner the owner
* @param item the item * @param quota the quota
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param search the search * @param search the search
* @param redeemed the redeemed * @param redeemed the redeemed
* @return the others * @return the others
*/ */

View File

@ -44,10 +44,11 @@ public class InviteMappingManager {
} }
/** /**
* Gets the by item. * Gets the by item and quota.
* *
* @param item the item * @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) { public InviteMapping getByItemAndQuota(int item, String quota) {
return inviteMappingRepository return inviteMappingRepository
@ -58,9 +59,9 @@ public class InviteMappingManager {
/** /**
* Gets the. * Gets the.
* *
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @return the page * @return the page
*/ */
@ -72,9 +73,9 @@ public class InviteMappingManager {
/** /**
* Creates the. * Creates the.
* *
* @param quota the quota * @param quota the quota
* @param item the item * @param item the item
* @param starts the starts * @param starts the starts
* @param expires the expires * @param expires the expires
* @return the invite mapping * @return the invite mapping
*/ */

View File

@ -104,6 +104,12 @@ public class InviteController extends BaseController {
return invite; return invite;
} }
/**
* Gets the permissions.
*
* @param code the code
* @return the permissions
*/
@GetMapping("/{code}/permissions") @GetMapping("/{code}/permissions")
public List<Permission> getPermissions(@PathVariable("code") String code) { public List<Permission> getPermissions(@PathVariable("code") String code) {
Invite invite = inviteManager.getByCode(code); Invite invite = inviteManager.getByCode(code);
@ -115,6 +121,12 @@ public class InviteController extends BaseController {
invite.getStarts(), invite.getExpires()); invite.getStarts(), invite.getExpires());
} }
/**
* Gets the quotas.
*
* @param code the code
* @return the quotas
*/
@GetMapping("/{code}/quotas") @GetMapping("/{code}/quotas")
public List<Quota> getQuotas(@PathVariable("code") String code) { public List<Quota> getQuotas(@PathVariable("code") String code) {
Invite invite = inviteManager.getByCode(code); Invite invite = inviteManager.getByCode(code);
@ -213,12 +225,12 @@ public class InviteController extends BaseController {
/** /**
* Gets the invites. * Gets the invites.
* *
* @param quotaParameter the quota parameter * @param quotaParameter the quota parameter
* @param pageParameter the page parameter * @param pageParameter the page parameter
* @param sizeParameter the size parameter * @param sizeParameter the size parameter
* @param sortParamater the sort paramater * @param sortParamater the sort paramater
* @param descParameter the desc parameter * @param descParameter the desc parameter
* @param searchParameter the search parameter * @param searchParameter the search parameter
* @param redeemedParameter the redeemed parameter * @param redeemedParameter the redeemed parameter
* @return the invites * @return the invites
*/ */
@ -241,10 +253,10 @@ public class InviteController extends BaseController {
/** /**
* Gets the other invites. * Gets the other invites.
* *
* @param quota the quota * @param quota the quota
* @param pageParameter the page parameter * @param pageParameter the page parameter
* @param sizeParameter the size parameter * @param sizeParameter the size parameter
* @param searchParameter the search parameter * @param searchParameter the search parameter
* @param redeemedParameter the redeemed parameter * @param redeemedParameter the redeemed parameter
* @return the other invites * @return the other invites
*/ */
@ -279,7 +291,7 @@ public class InviteController extends BaseController {
/** /**
* Creates the invite. * Creates the invite.
* *
* @param quota the quota * @param quota the quota
* @param inviteModel the invite model * @param inviteModel the invite model
* @return the invite * @return the invite
*/ */

View File

@ -44,8 +44,8 @@ public class InviteManagingController extends BaseController {
/** /**
* Gets the invites. * Gets the invites.
* *
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param search the search * @param search the search
* @return the invites * @return the invites
*/ */

View File

@ -112,6 +112,8 @@ public class Invite implements UserData {
} }
/** /**
* Gets the quota.
*
* @return the quota * @return the quota
*/ */
public String getQuota() { 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) { public void setQuota(String quota) {
this.quota = quota; this.quota = quota;
@ -234,6 +238,8 @@ public class Invite implements UserData {
} }
/** /**
* Gets the url.
*
* @return the url * @return the url
*/ */
public String getUrl() { 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) { public void setUrl(String url) {
this.url = url; this.url = url;

View File

@ -139,6 +139,8 @@ public class InviteMapping {
} }
/** /**
* Gets the url.
*
* @return the url * @return the url
*/ */
public String getUrl() { 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) { public void setUrl(String url) {
this.url = url; this.url = url;

View File

@ -59,7 +59,7 @@ public class JwtKeyManager {
/** /**
* Gets the jwk set. * Gets the jwk set.
* *
* @param name the name * @param name the name
* @param createDefault the create default * @param createDefault the create default
* @return the jwk set * @return the jwk set
*/ */
@ -91,7 +91,7 @@ public class JwtKeyManager {
/** /**
* Gets the latest. * Gets the latest.
* *
* @param name the name * @param name the name
* @param createDefault the create default * @param createDefault the create default
* @return the latest * @return the latest
*/ */
@ -140,6 +140,13 @@ public class JwtKeyManager {
return jwtKeyRepository.findOne(qJwtKey.keyID.eq(keyID)).orElse(null); 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 @Transactional
public JwtKey getByCreated(String name, Instant created) { public JwtKey getByCreated(String name, Instant created) {
return jwtKeyRepository return jwtKeyRepository
@ -229,7 +236,7 @@ public class JwtKeyManager {
/** /**
* Gets the jws algorithm. * Gets the jws algorithm.
* *
* @param name the name * @param name the name
* @param createDefault the create default * @param createDefault the create default
* @return the jws algorithm * @return the jws algorithm
*/ */

View File

@ -24,8 +24,7 @@ import de.bstly.we.jwt.model.JwtKey;
import de.bstly.we.model.User; import de.bstly.we.model.User;
/** /**
* @author Lurkars * The Class JwtUserManager.
*
*/ */
@Component @Component
public class JwtUserManager { public class JwtUserManager {
@ -37,6 +36,16 @@ public class JwtUserManager {
public static final String JWT_USER_DATA_KEY_NAME = "user"; 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) public SignedJWT createSignedJwt(Long userId, Object data, String issuer, Long lifetime)
throws JOSEException { throws JOSEException {
User user = userManager.get(userId); User user = userManager.get(userId);
@ -72,6 +81,14 @@ public class JwtUserManager {
return jwt; 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 { public boolean verify(SignedJWT jwt) throws JOSEException, ParseException {
if (jwt.getHeader() == null || !StringUtils.hasText(jwt.getHeader().getKeyID())) { if (jwt.getHeader() == null || !StringUtils.hasText(jwt.getHeader().getKeyID())) {
throw new KeySourceException("No KeyID provided!"); throw new KeySourceException("No KeyID provided!");

View File

@ -27,8 +27,7 @@ import de.bstly.we.controller.support.EntityResponseStatusException;
import de.bstly.we.jwt.businesslogic.JwtUserManager; import de.bstly.we.jwt.businesslogic.JwtUserManager;
/** /**
* @author Lurkars * The Class JwtUserDataController.
*
*/ */
@RestController @RestController
@RequestMapping("/jwt/user") @RequestMapping("/jwt/user")
@ -40,6 +39,12 @@ public class JwtUserDataController extends BaseController {
@Value("${bstly.we.jwtUserIssuer:}") @Value("${bstly.we.jwtUserIssuer:}")
private String jwtUserIssuer; private String jwtUserIssuer;
/**
* Creates the signed jwt auth.
*
* @param request the request
* @return the string
*/
@PreAuthorize("isAuthenticated()") @PreAuthorize("isAuthenticated()")
@GetMapping("/auth") @GetMapping("/auth")
public String createSignedJwtAuth(HttpServletRequest request) { 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()") @PreAuthorize("isAuthenticated()")
@PostMapping("/create") @PostMapping("/create")
public String createSignedJwt(@RequestBody Object data, HttpServletRequest request) { 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") @PostMapping("verify")
public Object verfiy(@RequestBody String serialized, HttpServletRequest request, public Object verfiy(@RequestBody String serialized, HttpServletRequest request,
HttpServletResponse response) { HttpServletResponse response) {

View File

@ -72,6 +72,9 @@ public class OidcTokenManager implements SmartInitializingSingleton {
* @see org.springframework.beans.factory.SmartInitializingSingleton# * @see org.springframework.beans.factory.SmartInitializingSingleton#
* afterSingletonsInstantiated() * afterSingletonsInstantiated()
*/ */
/*
* @see org.springframework.beans.factory.SmartInitializingSingleton#afterSingletonsInstantiated()
*/
/* /*
* @see org.springframework.beans.factory.SmartInitializingSingleton# * @see org.springframework.beans.factory.SmartInitializingSingleton#
* afterSingletonsInstantiated() * afterSingletonsInstantiated()
@ -119,7 +122,7 @@ public class OidcTokenManager implements SmartInitializingSingleton {
* *
* @param client the client * @param client the client
* @param userId the user id * @param userId the user id
* @param nonce the nonce * @param nonce the nonce
* @param scopes the scopes * @param scopes the scopes
* @param issuer the issuer * @param issuer the issuer
* @return the oidc token * @return the oidc token

View File

@ -40,9 +40,9 @@ public class ParteyUserTagManager implements UserDataProvider {
/** /**
* Gets the all. * Gets the all.
* *
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @return the all * @return the all
*/ */
@ -60,11 +60,8 @@ public class ParteyUserTagManager implements UserDataProvider {
* @return the all by user id * @return the all by user id
*/ */
public List<ParteyUserTag> getAllByUserId(Long userId) { public List<ParteyUserTag> getAllByUserId(Long userId) {
User user = userManager.get(userId); return Lists
Assert.notNull(user, "invalid userId: '" .newArrayList(parteyUserTagRepository.findAll(qParteyUserTag.target.eq(userId)));
+ userId
+ "'!");
return getAllForUsername(user.getUsername());
} }
/** /**
@ -80,16 +77,22 @@ public class ParteyUserTagManager implements UserDataProvider {
/** /**
* Gets the non expired by user id. * Gets the non expired by user id.
* *
* @param userId the user id * @param userId the user id
* @param upcoming the upcoming * @param upcoming the upcoming
* @return the non expired by user id * @return the non expired by user id
*/ */
public List<ParteyUserTag> getNonExpiredByUserId(Long userId, boolean upcoming) { public List<ParteyUserTag> getNonExpiredByUserId(Long userId, boolean upcoming) {
User user = userManager.get(userId); BooleanBuilder query = new BooleanBuilder();
Assert.notNull(user, "invalid userId: '"
+ userId query.and(qParteyUserTag.target.eq(userId));
+ "'!"); query.and(qParteyUserTag.expires.isNull().or(qParteyUserTag.expires.after(Instant.now())));
return getNonExpiredForUsername(user.getUsername(), upcoming);
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 * @return the all for username
*/ */
public List<ParteyUserTag> getAllForUsername(String username) { public List<ParteyUserTag> getAllForUsername(String username) {
return Lists.newArrayList(parteyUserTagRepository User user = userManager.getByUsername(username);
.findAll(qParteyUserTag.username.equalsIgnoreCase(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 * @return the non expired for username
*/ */
public List<ParteyUserTag> getNonExpiredForUsername(String username) { public List<ParteyUserTag> getNonExpiredForUsername(String username) {
return getNonExpiredForUsername(username, false); return getNonExpiredForUsername(username, false);
} }
@ -121,18 +128,11 @@ public class ParteyUserTagManager implements UserDataProvider {
* @return the non expired for username * @return the non expired for username
*/ */
public List<ParteyUserTag> getNonExpiredForUsername(String username, boolean upcoming) { public List<ParteyUserTag> getNonExpiredForUsername(String username, boolean upcoming) {
User user = userManager.getByUsername(username);
BooleanBuilder query = new BooleanBuilder(); Assert.notNull(user, "invalid username: '"
+ username
query.and(qParteyUserTag.username.equalsIgnoreCase(username)); + "'!");
query.and(qParteyUserTag.expires.isNull().or(qParteyUserTag.expires.after(Instant.now()))); return getNonExpiredByUserId(user.getId(), upcoming);
if (!upcoming) {
query.and(
qParteyUserTag.starts.isNull().or(qParteyUserTag.starts.before(Instant.now())));
}
return Lists.newArrayList(parteyUserTagRepository.findAll(query.getValue()));
} }
/** /**
@ -151,18 +151,18 @@ public class ParteyUserTagManager implements UserDataProvider {
* @param parteyUserTag the partey user tag * @param parteyUserTag the partey user tag
*/ */
public void delete(ParteyUserTag parteyUserTag) { public void delete(ParteyUserTag parteyUserTag) {
parteyUserTagRepository.deleteById( parteyUserTagRepository
new ParteyUserTagId(parteyUserTag.getUsername(), parteyUserTag.getTag())); .deleteById(new ParteyUserTagId(parteyUserTag.getTarget(), parteyUserTag.getTag()));
} }
/** /**
* Delete all for target. * Delete all for target.
* *
* @param username the username * @param target the target
*/ */
public void deleteAllForTarget(String username) { public void deleteAllForTarget(Long target) {
parteyUserTagRepository.deleteAll(parteyUserTagRepository parteyUserTagRepository
.findAll(qParteyUserTag.username.equalsIgnoreCase(username))); .deleteAll(parteyUserTagRepository.findAll(qParteyUserTag.target.eq(target)));
} }
/* /*
@ -187,11 +187,7 @@ public class ParteyUserTagManager implements UserDataProvider {
*/ */
@Override @Override
public void purgeUserData(Long userId) { public void purgeUserData(Long userId) {
User user = userManager.get(userId); deleteAllForTarget(userId);
Assert.notNull(user, "invalid userId: '"
+ userId
+ "'!");
deleteAllForTarget(user.getUsername());
} }
} }

View File

@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.security.access.prepost.PreAuthorize; 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.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
@ -56,7 +57,7 @@ public class UserTagManagementController extends BaseController {
@RequestParam("desc") Optional<Boolean> descParameter) { @RequestParam("desc") Optional<Boolean> descParameter) {
Page<ParteyUserTag> page = parteyUserTagManager.getAll(pageParameter.orElse(0), Page<ParteyUserTag> page = parteyUserTagManager.getAll(pageParameter.orElse(0),
sizeParameter.orElse(10), sortParameter.orElse("username"), sizeParameter.orElse(10), sortParameter.orElse("target"),
descParameter.orElse(false)); descParameter.orElse(false));
return page; return page;
@ -128,11 +129,21 @@ public class UserTagManagementController extends BaseController {
@PreAuthorize("hasRole('ROLE_ADMIN')") @PreAuthorize("hasRole('ROLE_ADMIN')")
@PostMapping @PostMapping
public ParteyUserTag createOrUpdateParteyUserTag(@RequestBody ParteyUserTag parteyUserTag) { 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) { if (user == null) {
throw new EntityResponseStatusException(HttpStatus.CONFLICT); throw new EntityResponseStatusException(HttpStatus.CONFLICT);
} }
parteyUserTag.setTarget(user.getId());
parteyUserTag.setUsername(user.getUsername());
return parteyUserTagManager.save(parteyUserTag); return parteyUserTagManager.save(parteyUserTag);
} }

View File

@ -24,30 +24,32 @@ import de.bstly.we.partey.model.ParteyUserTag.ParteyUserTagId;
public class ParteyUserTag implements UserData { public class ParteyUserTag implements UserData {
@Id @Id
private String username; private Long target;
@Id @Id
private String tag; private String tag;
@Column(name = "starts", nullable = true) @Column(name = "starts", nullable = true)
private Instant starts; private Instant starts;
@Column(name = "expires", nullable = true) @Column(name = "expires", nullable = true)
private Instant expires; 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() { public Long getTarget() {
return username; return target;
} }
/** /**
* Sets the username. * Sets the target.
* *
* @param username the new username * @param target the new target
*/ */
public void setUsername(String username) { public void setTarget(Long target) {
this.username = username; this.target = target;
} }
/** /**
@ -104,43 +106,69 @@ public class ParteyUserTag implements UserData {
this.expires = expires; 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 { public static class ParteyUserTagId implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String username; private Long target;
private String tag; private String tag;
/**
* Instantiates a new partey user tag id.
*/
public ParteyUserTagId() { public ParteyUserTagId() {
super(); super();
} }
/** /**
* @param username * Instantiates a new partey user tag id.
* @param tag *
* @param target the target
* @param tag the tag
*/ */
public ParteyUserTagId(String username, String tag) { public ParteyUserTagId(Long target, String tag) {
super(); super();
this.username = username; this.target = target;
this.tag = tag; this.tag = tag;
} }
/** /**
* Gets the username. * Gets the target.
* *
* @return the username * @return the target
*/ */
public String getUsername() { public Long getTarget() {
return username; return target;
} }
/** /**
* Sets the username. * Sets the target.
* *
* @param username the new username * @param target the new target
*/ */
public void setUsername(String username) { public void setTarget(Long target) {
this.username = username; this.target = target;
} }
/** /**

View File

@ -64,16 +64,16 @@ public class TimeslotManager implements UserDataProvider {
/** /**
* Gets the. * Gets the.
* *
* @param owner the owner * @param owner the owner
* @param invertOwner the invert owner * @param invertOwner the invert owner
* @param after the after * @param after the after
* @param type the type * @param type the type
* @param visibility the visibility * @param visibility the visibility
* @param search the search * @param search the search
* @param page the page * @param page the page
* @param size the size * @param size the size
* @param sortBy the sort by * @param sortBy the sort by
* @param descending the descending * @param descending the descending
* @return the page * @return the page
*/ */
public Page<Timeslot> get(Long owner, boolean invertOwner, Instant after, TimeslotType type, public Page<Timeslot> get(Long owner, boolean invertOwner, Instant after, TimeslotType type,

View File

@ -12,7 +12,7 @@
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version> <java.version>11</java.version>
<revision>1.3.1-SNAPSHOT</revision> <revision>1.3.2-SNAPSHOT</revision>
</properties> </properties>
<parent> <parent>