fix permission calculation
This commit is contained in:
parent
b876bad3e7
commit
c6f8365e54
@ -285,10 +285,6 @@ public class PermissionManager implements UserDataProvider {
|
||||
permissionsExpires = permissionMapping.getExpires();
|
||||
}
|
||||
|
||||
if (permissionMapping.isLifetimeRound()) {
|
||||
permissionStarts = InstantHelper.truncate(permissionStarts, permissionMapping.getLifetimeUnit());
|
||||
}
|
||||
|
||||
if (permissionsExpires == null) {
|
||||
permissionsExpires = InstantHelper.plus(permissionStarts == null ? Instant.now() : permissionStarts,
|
||||
permissionMapping.getLifetime(), permissionMapping.getLifetimeUnit());
|
||||
|
@ -14,14 +14,11 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
|
||||
import de.bstly.we.partey.api.controller.model.MapDetailsData;
|
||||
import de.bstly.we.partey.api.controller.support.DebugLogger;
|
||||
import de.bstly.we.partey.api.security.ParteyApiAuthentication;
|
||||
import de.bstly.we.partey.businesslogic.ParteyMapManager;
|
||||
import de.bstly.we.partey.businesslogic.model.Room;
|
||||
import de.bstly.we.partey.model.GameRoomPolicyTypes;
|
||||
|
||||
/**
|
||||
* The Class MapController.
|
||||
@ -51,19 +48,13 @@ public class MapController extends DebugLogger {
|
||||
debugPrintRequest(request);
|
||||
|
||||
MapDetailsData mapData = new MapDetailsData();
|
||||
mapData.setTags(Lists.newArrayList());
|
||||
mapData.setPolicy_type(GameRoomPolicyTypes.UNKNOWN);
|
||||
|
||||
Room room = parteyMapManager.parseRoom(playUri, request);
|
||||
if (room.isAuthenticationMandatory()) {
|
||||
mapData.setAuthenticationMandatory(true);
|
||||
}
|
||||
mapData.setMapUrl(room.getMapUrl());
|
||||
|
||||
if (room.getTags() != null) {
|
||||
mapData.setTags(room.getTags());
|
||||
}
|
||||
|
||||
if (room.getPolicyType() != null) {
|
||||
mapData.setPolicy_type(room.getPolicyType());
|
||||
}
|
||||
mapData.setExpireOn("");
|
||||
|
||||
debugPrintResponse(request, Optional.of(mapData));
|
||||
|
||||
|
@ -7,139 +7,55 @@ import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.bstly.we.partey.model.GameRoomPolicyTypes;
|
||||
|
||||
/**
|
||||
* The Class MapDetailsData.
|
||||
*/
|
||||
public class MapDetailsData {
|
||||
|
||||
private String mapUrl = "";
|
||||
private GameRoomPolicyTypes policy_type = GameRoomPolicyTypes.ANONYMOUS_POLICY;
|
||||
private List<String> tags = Lists.newArrayList();
|
||||
private boolean authenticationMandatory;
|
||||
private String roomSlug;
|
||||
private String contactPage;
|
||||
private String group;
|
||||
private List<Object> mucRooms = Lists.newArrayList();
|
||||
private String contactPage;
|
||||
private String iframeAuthentication;
|
||||
private String expireOn;
|
||||
private boolean canReport = true;
|
||||
private String loadingCowebsiteLogo;
|
||||
private String miniLogo;
|
||||
private String loadingLogo;
|
||||
private String loginSceneLogo;
|
||||
private boolean showPoweredBy = false;
|
||||
private String loadingCowebsiteLogo;
|
||||
private boolean canReport = true;
|
||||
private Object thirdParty;
|
||||
|
||||
/**
|
||||
* Gets the map url.
|
||||
*
|
||||
* @return the map url
|
||||
* @return the mapUrl
|
||||
*/
|
||||
public String getMapUrl() {
|
||||
return mapUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the map url.
|
||||
*
|
||||
* @param mapUrl the new map url
|
||||
* @param mapUrl the mapUrl to set
|
||||
*/
|
||||
public void setMapUrl(String mapUrl) {
|
||||
this.mapUrl = mapUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the policy type.
|
||||
*
|
||||
* @return the policy type
|
||||
*/
|
||||
public GameRoomPolicyTypes getPolicy_type() {
|
||||
return policy_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the policy type.
|
||||
*
|
||||
* @param policy_type the new policy type
|
||||
*/
|
||||
public void setPolicy_type(GameRoomPolicyTypes policy_type) {
|
||||
this.policy_type = policy_type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tags.
|
||||
*
|
||||
* @return the tags
|
||||
*/
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tags.
|
||||
*
|
||||
* @param tags the new tags
|
||||
*/
|
||||
public void setTags(List<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is authentication mandatory.
|
||||
*
|
||||
* @return true, if is authentication mandatory
|
||||
* @return the authenticationMandatory
|
||||
*/
|
||||
public boolean isAuthenticationMandatory() {
|
||||
return authenticationMandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the authentication mandatory.
|
||||
*
|
||||
* @param authenticationMandatory the new authentication mandatory
|
||||
* @param authenticationMandatory the authenticationMandatory to set
|
||||
*/
|
||||
public void setAuthenticationMandatory(boolean authenticationMandatory) {
|
||||
this.authenticationMandatory = authenticationMandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the room slug.
|
||||
*
|
||||
* @return the room slug
|
||||
*/
|
||||
public String getRoomSlug() {
|
||||
return roomSlug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the room slug.
|
||||
*
|
||||
* @param roomSlug the new room slug
|
||||
*/
|
||||
public void setRoomSlug(String roomSlug) {
|
||||
this.roomSlug = roomSlug;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the contact page.
|
||||
*
|
||||
* @return the contact page
|
||||
*/
|
||||
public String getContactPage() {
|
||||
return contactPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the contact page.
|
||||
*
|
||||
* @param contactPage the new contact page
|
||||
*/
|
||||
public void setContactPage(String contactPage) {
|
||||
this.contactPage = contactPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the group.
|
||||
*
|
||||
* @return the group
|
||||
*/
|
||||
public String getGroup() {
|
||||
@ -147,138 +63,164 @@ public class MapDetailsData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the group.
|
||||
*
|
||||
* @param group the new group
|
||||
* @param group the group to set
|
||||
*/
|
||||
public void setGroup(String group) {
|
||||
this.group = group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the iframe authentication.
|
||||
*
|
||||
* @return the iframe authentication
|
||||
* @return the mucRooms
|
||||
*/
|
||||
public List<Object> getMucRooms() {
|
||||
return mucRooms;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mucRooms the mucRooms to set
|
||||
*/
|
||||
public void setMucRooms(List<Object> mucRooms) {
|
||||
this.mucRooms = mucRooms;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the contactPage
|
||||
*/
|
||||
public String getContactPage() {
|
||||
return contactPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contactPage the contactPage to set
|
||||
*/
|
||||
public void setContactPage(String contactPage) {
|
||||
this.contactPage = contactPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the iframeAuthentication
|
||||
*/
|
||||
public String getIframeAuthentication() {
|
||||
return iframeAuthentication;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the iframe authentication.
|
||||
*
|
||||
* @param iframeAuthentication the new iframe authentication
|
||||
* @param iframeAuthentication the iframeAuthentication to set
|
||||
*/
|
||||
public void setIframeAuthentication(String iframeAuthentication) {
|
||||
this.iframeAuthentication = iframeAuthentication;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the mini logo.
|
||||
*
|
||||
* @return the mini logo
|
||||
* @return the expireOn
|
||||
*/
|
||||
public String getMiniLogo() {
|
||||
return miniLogo;
|
||||
public String getExpireOn() {
|
||||
return expireOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the mini logo.
|
||||
*
|
||||
* @param miniLogo the new mini logo
|
||||
* @param expireOn the expireOn to set
|
||||
*/
|
||||
public void setMiniLogo(String miniLogo) {
|
||||
this.miniLogo = miniLogo;
|
||||
public void setExpireOn(String expireOn) {
|
||||
this.expireOn = expireOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the loading logo.
|
||||
*
|
||||
* @return the loading logo
|
||||
*/
|
||||
public String getLoadingLogo() {
|
||||
return loadingLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the loading logo.
|
||||
*
|
||||
* @param loadingLogo the new loading logo
|
||||
*/
|
||||
public void setLoadingLogo(String loadingLogo) {
|
||||
this.loadingLogo = loadingLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the login scene logo.
|
||||
*
|
||||
* @return the login scene logo
|
||||
*/
|
||||
public String getLoginSceneLogo() {
|
||||
return loginSceneLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the login scene logo.
|
||||
*
|
||||
* @param loginSceneLogo the new login scene logo
|
||||
*/
|
||||
public void setLoginSceneLogo(String loginSceneLogo) {
|
||||
this.loginSceneLogo = loginSceneLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is show powered by.
|
||||
*
|
||||
* @return true, if is show powered by
|
||||
*/
|
||||
public boolean isShowPoweredBy() {
|
||||
return showPoweredBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the show powered by.
|
||||
*
|
||||
* @param showPoweredBy the new show powered by
|
||||
*/
|
||||
public void setShowPoweredBy(boolean showPoweredBy) {
|
||||
this.showPoweredBy = showPoweredBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the loading cowebsite logo.
|
||||
*
|
||||
* @return the loading cowebsite logo
|
||||
*/
|
||||
public String getLoadingCowebsiteLogo() {
|
||||
return loadingCowebsiteLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the loading cowebsite logo.
|
||||
*
|
||||
* @param loadingCowebsiteLogo the new loading cowebsite logo
|
||||
*/
|
||||
public void setLoadingCowebsiteLogo(String loadingCowebsiteLogo) {
|
||||
this.loadingCowebsiteLogo = loadingCowebsiteLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is can report.
|
||||
*
|
||||
* @return true, if is can report
|
||||
* @return the canReport
|
||||
*/
|
||||
public boolean isCanReport() {
|
||||
return canReport;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the can report.
|
||||
*
|
||||
* @param canReport the new can report
|
||||
* @param canReport the canReport to set
|
||||
*/
|
||||
public void setCanReport(boolean canReport) {
|
||||
this.canReport = canReport;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loadingCowebsiteLogo
|
||||
*/
|
||||
public String getLoadingCowebsiteLogo() {
|
||||
return loadingCowebsiteLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loadingCowebsiteLogo the loadingCowebsiteLogo to set
|
||||
*/
|
||||
public void setLoadingCowebsiteLogo(String loadingCowebsiteLogo) {
|
||||
this.loadingCowebsiteLogo = loadingCowebsiteLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the miniLogo
|
||||
*/
|
||||
public String getMiniLogo() {
|
||||
return miniLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param miniLogo the miniLogo to set
|
||||
*/
|
||||
public void setMiniLogo(String miniLogo) {
|
||||
this.miniLogo = miniLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loadingLogo
|
||||
*/
|
||||
public String getLoadingLogo() {
|
||||
return loadingLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loadingLogo the loadingLogo to set
|
||||
*/
|
||||
public void setLoadingLogo(String loadingLogo) {
|
||||
this.loadingLogo = loadingLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the loginSceneLogo
|
||||
*/
|
||||
public String getLoginSceneLogo() {
|
||||
return loginSceneLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param loginSceneLogo the loginSceneLogo to set
|
||||
*/
|
||||
public void setLoginSceneLogo(String loginSceneLogo) {
|
||||
this.loginSceneLogo = loginSceneLogo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the showPoweredBy
|
||||
*/
|
||||
public boolean isShowPoweredBy() {
|
||||
return showPoweredBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param showPoweredBy the showPoweredBy to set
|
||||
*/
|
||||
public void setShowPoweredBy(boolean showPoweredBy) {
|
||||
this.showPoweredBy = showPoweredBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the thirdParty
|
||||
*/
|
||||
public Object getThirdParty() {
|
||||
return thirdParty;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param thirdParty the thirdParty to set
|
||||
*/
|
||||
public void setThirdParty(Object thirdParty) {
|
||||
this.thirdParty = thirdParty;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,6 +20,9 @@ public class MemberData {
|
||||
private List<Object> messages = Lists.newArrayList();
|
||||
private boolean anonymous;
|
||||
private String userRoomToken;
|
||||
private String jabberId;
|
||||
private String jabberPassword;
|
||||
private List<Object> mucRooms = Lists.newArrayList();
|
||||
|
||||
/**
|
||||
* Gets the email.
|
||||
@ -165,4 +168,46 @@ public class MemberData {
|
||||
this.userRoomToken = userRoomToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the jabberId
|
||||
*/
|
||||
public String getJabberId() {
|
||||
return jabberId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jabberId the jabberId to set
|
||||
*/
|
||||
public void setJabberId(String jabberId) {
|
||||
this.jabberId = jabberId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the jabberPassword
|
||||
*/
|
||||
public String getJabberPassword() {
|
||||
return jabberPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param jabberPassword the jabberPassword to set
|
||||
*/
|
||||
public void setJabberPassword(String jabberPassword) {
|
||||
this.jabberPassword = jabberPassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mucRooms
|
||||
*/
|
||||
public List<Object> getMucRooms() {
|
||||
return mucRooms;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mucRooms the mucRooms to set
|
||||
*/
|
||||
public void setMucRooms(List<Object> mucRooms) {
|
||||
this.mucRooms = mucRooms;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -20,10 +20,7 @@ import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.server.ResponseStatusException;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
|
||||
import de.bstly.we.partey.businesslogic.model.Room;
|
||||
import de.bstly.we.partey.model.GameRoomPolicyTypes;
|
||||
import de.bstly.we.partey.model.ParteyMap;
|
||||
import de.bstly.we.partey.repository.ParteyMapRepository;
|
||||
|
||||
@ -38,6 +35,8 @@ public class ParteyMapManager {
|
||||
|
||||
@Value("${we.bstly.partey.mapUrl:http://localhost/}")
|
||||
private String internalMapUri;
|
||||
@Value("${we.bstly.partey.startRoom:}")
|
||||
private String startRoom;
|
||||
|
||||
private Pattern internalMapUriPattern = Pattern.compile("\\/@\\/(.+)");
|
||||
private Pattern externalMapUriPattern = Pattern.compile("\\/_\\/[^/]+\\/(.+)");
|
||||
@ -96,8 +95,6 @@ public class ParteyMapManager {
|
||||
*/
|
||||
public Room parseRoom(String url, HttpServletRequest request) {
|
||||
Room room = new Room();
|
||||
room.setPolicyType(GameRoomPolicyTypes.UNKNOWN);
|
||||
room.setTags(Lists.newArrayList());
|
||||
room.setUrl(url);
|
||||
URI uri;
|
||||
try {
|
||||
@ -110,7 +107,7 @@ public class ParteyMapManager {
|
||||
Matcher externalMatcher = externalMapUriPattern.matcher(uri.getPath());
|
||||
|
||||
if (internalMatcher.matches()) {
|
||||
room.setPolicyType(GameRoomPolicyTypes.MEMBERS_ONLY_POLICY);
|
||||
room.setAuthenticationMandatory(true);
|
||||
room.setMapId(internalMatcher.group(1));
|
||||
room.setMapUrl(internalMapUri + room.getMapId());
|
||||
} else if (externalMatcher.matches()) {
|
||||
@ -120,20 +117,13 @@ public class ParteyMapManager {
|
||||
} else {
|
||||
room.setMapUrl(request.getScheme() + "://" + room.getMapId());
|
||||
}
|
||||
} else if (StringUtils.hasText(startRoom)) {
|
||||
room.setMapId(startRoom);
|
||||
room.setMapUrl(internalMapUri + room.getMapId());
|
||||
} else {
|
||||
throw new ResponseStatusException(HttpStatus.CONFLICT, "invalid playUri");
|
||||
}
|
||||
|
||||
ParteyMap parteyMap = get(room.getMapId());
|
||||
if (parteyMap != null) {
|
||||
if (parteyMap.getPolicyType() != null) {
|
||||
room.setPolicyType(parteyMap.getPolicyType());
|
||||
}
|
||||
if (parteyMap.getTags() != null) {
|
||||
room.setTags(parteyMap.getTags());
|
||||
}
|
||||
}
|
||||
|
||||
return room;
|
||||
}
|
||||
|
||||
|
@ -3,12 +3,6 @@
|
||||
*/
|
||||
package de.bstly.we.partey.businesslogic.model;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import de.bstly.we.partey.model.GameRoomPolicyTypes;
|
||||
|
||||
/**
|
||||
* The Class Room.
|
||||
*/
|
||||
@ -17,8 +11,7 @@ public class Room {
|
||||
private String url;
|
||||
private String mapId;
|
||||
private String mapUrl;
|
||||
private GameRoomPolicyTypes policyType;
|
||||
private List<String> tags = Lists.newArrayList();
|
||||
private boolean authenticationMandatory;
|
||||
|
||||
/**
|
||||
* Gets the url.
|
||||
@ -75,39 +68,17 @@ public class Room {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the policy type.
|
||||
*
|
||||
* @return the policy type
|
||||
* @return the authenticationMandatory
|
||||
*/
|
||||
public GameRoomPolicyTypes getPolicyType() {
|
||||
return policyType;
|
||||
public boolean isAuthenticationMandatory() {
|
||||
return authenticationMandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the policy type.
|
||||
*
|
||||
* @param policyType the new policy type
|
||||
* @param authenticationMandatory the authenticationMandatory to set
|
||||
*/
|
||||
public void setPolicyType(GameRoomPolicyTypes policyType) {
|
||||
this.policyType = policyType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the tags.
|
||||
*
|
||||
* @return the tags
|
||||
*/
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tags.
|
||||
*
|
||||
* @param tags the new tags
|
||||
*/
|
||||
public void setTags(List<String> tags) {
|
||||
this.tags = tags;
|
||||
public void setAuthenticationMandatory(boolean authenticationMandatory) {
|
||||
this.authenticationMandatory = authenticationMandatory;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user