Skip to content

Commit

Permalink
RANGER-4225: Possible Jackson serialization issue due to not comply w…
Browse files Browse the repository at this point in the history
…ith Java bean standards
  • Loading branch information
sercanCyberVision committed Jul 11, 2024
1 parent 9e9ec52 commit f84dd02
Show file tree
Hide file tree
Showing 180 changed files with 1,130 additions and 838 deletions.
13 changes: 10 additions & 3 deletions agents-common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,12 @@
<version>${commons.configuration.version}</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>${codehaus.jackson.version}</version>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>${fasterxml.jackson.version}</version>
</dependency>


<dependency>
<groupId>org.apache.ranger</groupId>
<artifactId>ranger-plugins-cred</artifactId>
Expand Down Expand Up @@ -148,6 +150,11 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${fasterxml.jackson.version}</version>
</dependency>
<!-- To be added for JDK15 and above
<dependency>
<groupId>org.graalvm.js</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public ClientResponse run() {
} else if(response == null) {
throw new Exception("unknown error during createRole. roleName=" + request.getName());
} else {
ret = response.getEntity(RangerRole.class);
ret = JsonUtilsV2.readResponse(response, RangerRole.class);
}

if(LOG.isDebugEnabled()) {
Expand Down Expand Up @@ -444,7 +444,7 @@ public ClientResponse run() {

throw new Exception("HTTP " + response.getStatus() + " Error: " + resp.getMessage());
} else {
ret = response.getEntity(RangerRole.class);
ret = JsonUtilsV2.readResponse(response, RangerRole.class);
}
} else {
throw new Exception("unknown error during getPrincipalsForRole. roleName=" + roleName);
Expand Down Expand Up @@ -804,7 +804,7 @@ public ClientResponse run() {
}
ret = null;
} else if (response.getStatus() == HttpServletResponse.SC_OK) {
ret = response.getEntity(RangerUserStore.class);
ret = JsonUtilsV2.readResponse(response, RangerUserStore.class);
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
ret = null;
LOG.error("Error getting UserStore; service not found. secureMode=" + isSecureMode + ", user=" + user
Expand Down Expand Up @@ -879,7 +879,7 @@ public ServiceGdsInfo getGdsInfoIfUpdated(long lastKnownVersion, long lastActiva
LOG.debug("No change in GdsInfo: secureMode={}, user={}, response={}, serviceName={}, lastKnownGdsVersion={}, lastActivationTimeInMillis={}",
isSecureMode, user, resp, serviceName, lastKnownVersion, lastActivationTimeInMillis);
} else if (response.getStatus() == HttpServletResponse.SC_OK) {
ret = response.getEntity(ServiceGdsInfo.class);
ret = JsonUtilsV2.readResponse(response, ServiceGdsInfo.class);
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
ret = null;

Expand Down Expand Up @@ -931,7 +931,7 @@ private ServicePolicies getServicePoliciesIfUpdatedWithCred(final long lastKnown
ret = null;
} else if (response.getStatus() == HttpServletResponse.SC_OK) {
setCookieReceivedFromCredSession(response);
ret = response.getEntity(ServicePolicies.class);
ret = JsonUtilsV2.readResponse(response, ServicePolicies.class);
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
policyDownloadSessionId = null;
ret = null;
Expand Down Expand Up @@ -982,7 +982,7 @@ private ServicePolicies getServicePoliciesIfUpdatedWithCookie(final long lastKno
ret = null;
} else if (response.getStatus() == HttpServletResponse.SC_OK) {
checkAndResetSessionCookie(response);
ret = response.getEntity(ServicePolicies.class);
ret = JsonUtilsV2.readResponse(response, ServicePolicies.class);
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
policyDownloadSessionId = null;
isValidPolicyDownloadSessionCookie = false;
Expand Down Expand Up @@ -1112,7 +1112,7 @@ private ServiceTags getServiceTagsIfUpdatedWithCred(final long lastKnownVersion,
ret = null;
} else if (response.getStatus() == HttpServletResponse.SC_OK) {
setCookieReceivedFromTagDownloadSession(response);
ret = response.getEntity(ServiceTags.class);
ret = JsonUtilsV2.readResponse(response, ServiceTags.class);
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
tagDownloadSessionId = null;
ret = null;
Expand Down Expand Up @@ -1167,7 +1167,7 @@ private ServiceTags getServiceTagsIfUpdatedWithCookie(final long lastKnownVersio
ret = null;
} else if (response.getStatus() == HttpServletResponse.SC_OK) {
checkAndResetTagDownloadSessionCookie(response);
ret = response.getEntity(ServiceTags.class);
ret = JsonUtilsV2.readResponse(response, ServiceTags.class);
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
tagDownloadSessionId = null;
isValidTagDownloadSessionCookie = false;
Expand Down Expand Up @@ -1294,7 +1294,7 @@ private RangerRoles getRolesIfUpdatedWithCred(final long lastKnownRoleVersion, f
ret = null;
} else if (response.getStatus() == HttpServletResponse.SC_OK) {
setCookieReceivedFromRoleDownloadSession(response);
ret = response.getEntity(RangerRoles.class);
ret = JsonUtilsV2.readResponse(response, RangerRoles.class);
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
roleDownloadSessionId = null;
ret = null;
Expand Down Expand Up @@ -1350,7 +1350,7 @@ private RangerRoles getRolesIfUpdatedWithCookie(final long lastKnownRoleVersion,
ret = null;
} else if (response.getStatus() == HttpServletResponse.SC_OK) {
checkAndResetRoleDownloadSessionCookie(response);
ret = response.getEntity(RangerRoles.class);
ret = JsonUtilsV2.readResponse(response, RangerRoles.class);
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
roleDownloadSessionId = null;
isValidRoleDownloadSessionCookie = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
import java.util.List;
import java.util.ArrayList;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.ranger.authorization.utils.StringUtil;
import org.apache.ranger.plugin.util.JsonUtilsV2;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;


@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class GrantRevokeData implements java.io.Serializable {
private static final long serialVersionUID = 1L;
Expand Down Expand Up @@ -162,7 +162,7 @@ public String toString() {
}

@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class PermMap implements java.io.Serializable {
private List<String> userList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,20 @@

import java.util.List;

import com.fasterxml.jackson.annotation.JsonInclude;
import org.apache.ranger.authorization.utils.StringUtil;
import org.apache.ranger.plugin.util.JsonUtilsV2;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.sun.jersey.api.client.ClientResponse;


@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public class RESTResponse implements java.io.Serializable {
private static final Logger LOG = LoggerFactory.getLogger(RESTResponse.class);
Expand Down Expand Up @@ -140,7 +140,7 @@ public String toString() {
}

@JsonAutoDetect(getterVisibility = Visibility.NONE, setterVisibility = Visibility.NONE, fieldVisibility = Visibility.ANY)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
public static class Message implements java.io.Serializable {
private String name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import org.apache.ranger.plugin.model.RangerValiditySchedule;
import org.apache.ranger.plugin.policyevaluator.RangerValidityScheduleEvaluator;
import org.apache.ranger.plugin.policyresourcematcher.RangerPolicyResourceMatcher;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnore;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -41,7 +41,7 @@
import java.util.Map;

@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown=true)

// This class needs above annotations for policy-engine unit tests involving RangerTagForEval objects that are initialized
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,7 @@
import org.apache.ranger.admin.client.datatype.RESTResponse;
import org.apache.ranger.audit.provider.MiscUtil;
import org.apache.ranger.authorization.utils.JsonUtils;
import org.apache.ranger.plugin.util.RangerPerfTracer;
import org.apache.ranger.plugin.util.DownloadTrigger;
import org.apache.ranger.plugin.util.RangerRESTClient;
import org.apache.ranger.plugin.util.RangerUserStore;
import org.apache.ranger.plugin.util.RangerServiceNotFoundException;
import org.apache.ranger.plugin.util.RangerRESTUtils;
import org.apache.ranger.plugin.util.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -412,7 +407,7 @@ public ClientResponse run() {
}
ret = null;
} else if (response.getStatus() == HttpServletResponse.SC_OK) {
ret = response.getEntity(RangerUserStore.class);
ret = JsonUtilsV2.readResponse(response, RangerUserStore.class);
} else if (response.getStatus() == HttpServletResponse.SC_NOT_FOUND) {
ret = null;
LOG.error("Error getting UserStore; service not found. secureMode=" + isSecureMode + ", user=" + user
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import java.util.List;
import java.util.Map;

import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

@JsonAutoDetect(fieldVisibility=Visibility.ANY)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown=true)
public class AuditFilter {
public enum AccessResult { DENIED, ALLOWED, NOT_DETERMINED }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
package org.apache.ranger.plugin.model;

import org.apache.ranger.plugin.util.RangerUserStoreUtil;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.HashMap;
import java.util.Map;

@JsonAutoDetect(fieldVisibility=JsonAutoDetect.Visibility.ANY)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown=true)
public class GroupInfo extends RangerBaseModelObject implements java.io.Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
import java.util.Set;

import org.apache.ranger.authorization.utils.StringUtil;
import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonAutoDetect.Visibility;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

@JsonAutoDetect(getterVisibility=Visibility.NONE, setterVisibility=Visibility.NONE, fieldVisibility=Visibility.ANY)
@JsonSerialize(include=JsonSerialize.Inclusion.NON_EMPTY )
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown=true)
public class RangerBaseModelObject implements java.io.Serializable {
private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

package org.apache.ranger.plugin.model;

import org.codehaus.jackson.annotate.JsonAutoDetect;
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
Expand All @@ -30,7 +30,7 @@

public class RangerDatasetHeader {
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.ANY)
@JsonSerialize(include = JsonSerialize.Inclusion.NON_EMPTY)
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@JsonIgnoreProperties(ignoreUnknown = true)
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
Expand Down
Loading

0 comments on commit f84dd02

Please sign in to comment.