-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SEBSERV-452 applied ExamPrivilege and FeaturePrivilege to UserInfo fo…
…r future privilege improvements
- Loading branch information
Showing
14 changed files
with
357 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
src/main/java/ch/ethz/seb/sebserver/gbl/model/user/EntityPrivilege.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* Copyright (c) 2023 ETH Zürich, Educational Development and Technology (LET) | ||
* | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
package ch.ethz.seb.sebserver.gbl.model.user; | ||
|
||
|
||
|
||
import java.util.Objects; | ||
|
||
import ch.ethz.seb.sebserver.gbl.api.EntityType; | ||
import ch.ethz.seb.sebserver.gbl.api.authorization.PrivilegeType; | ||
import ch.ethz.seb.sebserver.gbl.model.Domain.*; | ||
import com.fasterxml.jackson.annotation.JsonCreator; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class EntityPrivilege { | ||
|
||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_ID) | ||
public final Long id; | ||
|
||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_ENTITY_TYPE) | ||
public final EntityType entityType; | ||
|
||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_ENTITY_ID) | ||
public final Long entityId; | ||
|
||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_USER_UUID) | ||
public final String userUUID; | ||
|
||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_PRIVILEGE_TYPE) | ||
public final PrivilegeType privilegeType; | ||
|
||
@JsonCreator | ||
public EntityPrivilege( | ||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_ID) final Long id, | ||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_ENTITY_TYPE) final EntityType entityType, | ||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_ENTITY_ID) final Long entityId, | ||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_USER_UUID) final String userUUID, | ||
@JsonProperty(ENTITY_PRIVILEGE.ATTR_PRIVILEGE_TYPE) final PrivilegeType privilegeType) { | ||
|
||
this.id = id; | ||
this.entityType = entityType; | ||
this.entityId = entityId; | ||
this.userUUID = userUUID; | ||
this.privilegeType = privilegeType; | ||
} | ||
|
||
public Long getId() { | ||
return this.id; | ||
} | ||
|
||
public EntityType getEntityType() { | ||
return this.entityType; | ||
} | ||
|
||
public Long getEntityId() { | ||
return this.entityId; | ||
} | ||
|
||
public String getUserUUID() { | ||
return this.userUUID; | ||
} | ||
|
||
public PrivilegeType getPrivilegeType() { | ||
return this.privilegeType; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(this.id); | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object obj) { | ||
if (this == obj) | ||
return true; | ||
if (obj == null) | ||
return false; | ||
if (getClass() != obj.getClass()) | ||
return false; | ||
final EntityPrivilege other = (EntityPrivilege) obj; | ||
return Objects.equals(this.id, other.id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
final StringBuilder builder = new StringBuilder(); | ||
builder.append("EntityPrivilege [id="); | ||
builder.append(this.id); | ||
builder.append(", entityType="); | ||
builder.append(this.entityType); | ||
builder.append(", entityId="); | ||
builder.append(this.entityId); | ||
builder.append(", userUUID="); | ||
builder.append(this.userUUID); | ||
builder.append(", privilegeType="); | ||
builder.append(this.privilegeType); | ||
builder.append("]"); | ||
return builder.toString(); | ||
} | ||
|
||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/ch/ethz/seb/sebserver/gbl/model/user/FeaturePrivilege.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package ch.ethz.seb.sebserver.gbl.model.user; | ||
|
||
import java.util.Objects; | ||
|
||
import ch.ethz.seb.sebserver.gbl.model.Domain.*; | ||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class FeaturePrivilege { | ||
|
||
@JsonProperty(FEATURE_PRIVILEGE.ATTR_ID) | ||
public final Long id; | ||
@JsonProperty(FEATURE_PRIVILEGE.ATTR_FEATURE_ID) | ||
public final Long featureId; | ||
|
||
@JsonProperty(FEATURE_PRIVILEGE.ATTR_USER_UUID) | ||
public final String userUUID; | ||
|
||
public FeaturePrivilege( | ||
@JsonProperty(FEATURE_PRIVILEGE.ATTR_ID) final Long id, | ||
@JsonProperty(FEATURE_PRIVILEGE.ATTR_FEATURE_ID) final Long featureId, | ||
@JsonProperty(FEATURE_PRIVILEGE.ATTR_USER_UUID) final String userUUID) { | ||
|
||
this.id = id; | ||
this.featureId = featureId; | ||
this.userUUID = userUUID; | ||
} | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public Long getFeatureId() { | ||
return featureId; | ||
} | ||
|
||
public String getUserUUID() { | ||
return userUUID; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
final FeaturePrivilege that = (FeaturePrivilege) o; | ||
return Objects.equals(id, that.id); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(id); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "FeaturePrivilege{" + | ||
"id=" + id + | ||
", featureId=" + featureId + | ||
", userUUID='" + userUUID + '\'' + | ||
'}'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.