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);
|
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()) {
|
||||||
|
@ -82,7 +82,7 @@ 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
|
||||||
@ -90,7 +90,7 @@ public class BorrowRequestManager implements UserDataProvider {
|
|||||||
* @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) {
|
||||||
|
@ -51,6 +51,7 @@ public class BorrowItemController extends BaseController {
|
|||||||
* @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}")
|
||||||
|
@ -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()")
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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>,
|
||||||
|
@ -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>,
|
||||||
|
@ -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
|
||||||
|
@ -25,8 +25,7 @@ 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);
|
||||||
|
@ -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')")
|
||||||
|
@ -90,7 +90,7 @@ 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
|
||||||
@ -130,7 +130,7 @@ 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
|
||||||
|
@ -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
|
||||||
|
@ -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);
|
||||||
|
@ -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;
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
@ -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!");
|
||||||
|
@ -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) {
|
||||||
|
@ -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()
|
||||||
|
@ -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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -85,11 +82,17 @@ public class ParteyUserTagManager implements UserDataProvider {
|
|||||||
* @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());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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,27 +106,6 @@ public class ParteyUserTag implements UserData {
|
|||||||
this.expires = expires;
|
this.expires = expires;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ParteyUserTagId implements Serializable {
|
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private String username;
|
|
||||||
private String tag;
|
|
||||||
|
|
||||||
public ParteyUserTagId() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param username
|
|
||||||
* @param tag
|
|
||||||
*/
|
|
||||||
public ParteyUserTagId(String username, String tag) {
|
|
||||||
super();
|
|
||||||
this.username = username;
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the username.
|
* Gets the username.
|
||||||
*
|
*
|
||||||
@ -143,6 +124,53 @@ public class ParteyUserTag implements UserData {
|
|||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class ParteyUserTagId.
|
||||||
|
*/
|
||||||
|
public static class ParteyUserTagId implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private Long target;
|
||||||
|
private String tag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new partey user tag id.
|
||||||
|
*/
|
||||||
|
public ParteyUserTagId() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new partey user tag id.
|
||||||
|
*
|
||||||
|
* @param target the target
|
||||||
|
* @param tag the tag
|
||||||
|
*/
|
||||||
|
public ParteyUserTagId(Long target, String tag) {
|
||||||
|
super();
|
||||||
|
this.target = target;
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the target.
|
||||||
|
*
|
||||||
|
* @return the target
|
||||||
|
*/
|
||||||
|
public Long getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the target.
|
||||||
|
*
|
||||||
|
* @param target the new target
|
||||||
|
*/
|
||||||
|
public void setTarget(Long target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the tag.
|
* Gets the tag.
|
||||||
*
|
*
|
||||||
|
2
pom.xml
2
pom.xml
@ -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>
|
||||||
|
Loading…
Reference in New Issue
Block a user