From d1dd7e86f9f3e29a4e817c9e477b5370536e6565 Mon Sep 17 00:00:00 2001 From: pujavs <43700552+pujavs@users.noreply.github.com> Date: Fri, 18 Oct 2024 23:43:28 +0530 Subject: [PATCH] feat(config-api): session and token search enhancement (#9844) * fix(config-api): asset mgt endpoint fixes Signed-off-by: pujavs * feat(config-api): asset upload mgt ehancement and fido Signed-off-by: pujavs * feat(config-api): asset upload mgt ehancement and fido Signed-off-by: pujavs * feat(config-api): asset upload mgt ehancement and fido Signed-off-by: pujavs * fix(config-api): asset upload Signed-off-by: pujavs * fix(config-api): lock review comments Signed-off-by: pujavs * feat(config-api): lock code review comments Signed-off-by: pujavs * feat(config-api): lock master renamed to lock server Signed-off-by: pujavs * feat(config-api): lock master renamed to lock server Signed-off-by: pujavs * feat(config-api): lock master renamed to lock server Signed-off-by: pujavs * feat(config-api): lock master renamed to lock server Signed-off-by: pujavs * feat(config-api): fido2 delete functionality Signed-off-by: pujavs * fix(config-api): acr validation Signed-off-by: pujavs * feat(config-api): doc(config-api): IDP schema attribute descriptions #9187 Signed-off-by: pujavs * feat(config-api): sync with main Signed-off-by: pujavs * feat(config-api): uploading assets via API generates 2 entries #9178 Signed-off-by: pujavs * feat(config-api): asset mgt, fido and IDP changes Signed-off-by: pujavs * feat(config-api): fido2 device endpoint Signed-off-by: pujavs * feat(config-api): fido2 endpoint Signed-off-by: pujavs * feat(config-api): fido2 endpoint Signed-off-by: pujavs * feat(config-api): sync with main Signed-off-by: pujavs * feat(config-api): sync with main Signed-off-by: pujavs * feat(config-api): sync with main Signed-off-by: pujavs * feat(config-api): resolved sonar review issues Signed-off-by: pujavs * feat(config-api): sonar review comment fix Signed-off-by: pujavs * feat(config-api): swagger spec Signed-off-by: pujavs * feat(config-api): saml config attribute description Signed-off-by: pujavs * doc(config-api): added SAML attribute description Signed-off-by: pujavs * doc(config-api): added SAML attribute description Signed-off-by: pujavs * feat(config-api): sync with main Signed-off-by: pujavs * fix(jans-lock): code review comment fix isssue#9305 Signed-off-by: pujavs * fix(jans-lock): code review comment fix isssue#9305 Signed-off-by: pujavs * feat(config-api): lock review point Signed-off-by: pujavs * fix(lock): code review comment Signed-off-by: pujavs * fix(lock): code review comment Signed-off-by: pujavs * fix(config-api): sync with main Signed-off-by: pujavs * feat(config-api): lock endpoint fixes and SAML IDP NPE Signed-off-by: pujavs * feat(config-api): asset enhancement Signed-off-by: pujavs * feat(config-api): implement timer for asset mgt to fetch and deploy assets forconfig-api #9403 Signed-off-by: pujavs * fix(config-api): scope validation issue #9426 Signed-off-by: pujavs * fix(config-api): asset delete error fix Signed-off-by: pujavs * feat(config-api): sysnc with main Signed-off-by: pujavs * fix(config-ap): lock audit endpoint parameter declaration error#9460 Signed-off-by: pujavs * feat(config-api): client token functionality Signed-off-by: pujavs * fix(Config-api): lock audit endpoint path param rectification Signed-off-by: pujavs * feat(config-api): clint token endpoint - wip Signed-off-by: pujavs * feat(config-api): clint token endpoint Signed-off-by: pujavs * feat(config-api): client token endpoint Signed-off-by: pujavs * feat(config-api): client token endpoint Signed-off-by: pujavs * feat(config-api): token endpoint Signed-off-by: pujavs * feat(config-api): token endpoint Signed-off-by: pujavs * feat(config-api): token endpoint Signed-off-by: pujavs * feat(config-api): session ednpoint wip Signed-off-by: pujavs * feat(config-api): session ednpoint wip Signed-off-by: pujavs * feat(config-api): session and token endpoint Signed-off-by: pujavs * feat(config-api): session endpoint Signed-off-by: pujavs * feat(config-api): session endpoint Signed-off-by: pujavs * feat(config-api): session and fido2 endpoint Signed-off-by: pujavs * test(config-api): marked session failing test case Signed-off-by: pujavs * feat(config-api): asset mgt dir mapping changes wip Signed-off-by: pujavs * feat(config-api): asset mgt dir changes Signed-off-by: pujavs * feat(config-api): asset mgt changes for dir Signed-off-by: pujavs * feat(config-api): asset mgt endpoint -wip Signed-off-by: pujavs * feat(config-api): asset mgt endpoint Signed-off-by: pujavs * feat(config-api): custom asset mgt wip Signed-off-by: pujavs * feat(config-api): custom asset mgt Signed-off-by: pujavs * feat(config-api): custom asset mgt Signed-off-by: pujavs * feat(config-api): session endpoint changes to remove sessionId Signed-off-by: pujavs * feat(config-api) session endpoint changes to hide id Signed-off-by: pujavs * feat(config-api) session endpoint changes to hide id Signed-off-by: pujavs * feat(config-api): session endpoint mgt Signed-off-by: pujavs * feat(config-api): session enhancement for removing id Signed-off-by: pujavs * feat(config-api): session endpoint changes to remove session id Signed-off-by: pujavs * feat(config-api): session endpoint changes to remove session id Signed-off-by: pujavs * feat(config-api): session endpoint changes to remove session id Signed-off-by: pujavs * feat(config-api): session endpoint changes to remove session id Signed-off-by: pujavs * feat(config-api): search fieldValuePair enhancement Signed-off-by: pujavs * feat(config-api): search fieldValuePair enhancement Signed-off-by: pujavs * feat(config-api): session field filter enhancement - wip Signed-off-by: pujavs * feat(config-api): session field search enhancement wip Signed-off-by: pujavs * feat(config-api): session endpoint search enhancemnt Signed-off-by: pujavs * feat(config-api): session endpoint search enhancemnt Signed-off-by: pujavs * feat(config-api): session endpoint search enhancement Signed-off-by: pujavs * feat(config-api): session and token endpoint enhacement Signed-off-by: pujavs * feat(config-api): session and token search enhancement Signed-off-by: pujavs --------- Signed-off-by: pujavs Co-authored-by: YuriyZ Co-authored-by: Yuriy Movchan Former-commit-id: c20ae82d5248e1bab4aa5b45580a008c8f1c2e9d --- .../docs/jans-config-api-swagger.yaml | 20 +- .../service/Fido2RegistrationService.java | 71 +++--- .../service/auth/SessionService.java | 80 ++++--- .../configapi/service/auth/TokenService.java | 82 ++++--- .../configapi/core/rest/BaseResource.java | 21 +- .../io/jans/configapi/core/util/DataUtil.java | 210 ++++++++++++++++++ .../io/jans/configapi/core/util/Util.java | 119 +++++++++- .../java/io/jans/model/FilterOperator.java | 32 +++ .../java/io/jans/model/FieldFilterData.java | 60 +++++ .../java/io/jans/model/SearchRequest.java | 17 +- 10 files changed, 588 insertions(+), 124 deletions(-) create mode 100644 jans-core/model/src/main/java/io/jans/model/FilterOperator.java create mode 100644 jans-core/service/src/main/java/io/jans/model/FieldFilterData.java diff --git a/jans-config-api/docs/jans-config-api-swagger.yaml b/jans-config-api/docs/jans-config-api-swagger.yaml index 55586dbbf46..a2c7414660f 100644 --- a/jans-config-api/docs/jans-config-api-swagger.yaml +++ b/jans-config-api/docs/jans-config-api-swagger.yaml @@ -9215,13 +9215,13 @@ components: type: string selected: type: boolean - adminCanView: - type: boolean - userCanView: + userCanEdit: type: boolean adminCanEdit: type: boolean - userCanEdit: + adminCanView: + type: boolean + userCanView: type: boolean adminCanAccess: type: boolean @@ -10076,6 +10076,8 @@ components: type: boolean lockMessageConfig: $ref: '#/components/schemas/LockMessageConfig' + fapi: + type: boolean allResponseTypesSupported: uniqueItems: true type: array @@ -10085,8 +10087,6 @@ components: - code - token - id_token - fapi: - type: boolean AuthenticationFilter: required: - baseDn @@ -11194,14 +11194,14 @@ components: type: boolean internal: type: boolean - locationPath: - type: string locationType: type: string enum: - ldap - db - file + locationPath: + type: string baseDn: type: string ScriptError: @@ -11630,10 +11630,10 @@ components: ttl: type: integer format: int32 - persisted: - type: boolean opbrowserState: type: string + persisted: + type: boolean SessionIdAccessMap: type: object properties: diff --git a/jans-config-api/plugins/fido2-plugin/src/main/java/io/jans/configapi/plugin/fido2/service/Fido2RegistrationService.java b/jans-config-api/plugins/fido2-plugin/src/main/java/io/jans/configapi/plugin/fido2/service/Fido2RegistrationService.java index a1cd8256e72..9596415dcc3 100644 --- a/jans-config-api/plugins/fido2-plugin/src/main/java/io/jans/configapi/plugin/fido2/service/Fido2RegistrationService.java +++ b/jans-config-api/plugins/fido2-plugin/src/main/java/io/jans/configapi/plugin/fido2/service/Fido2RegistrationService.java @@ -10,6 +10,7 @@ import io.jans.as.common.service.OrganizationService; import io.jans.as.model.config.StaticConfiguration; import io.jans.configapi.configuration.ConfigurationFactory; +import io.jans.configapi.core.util.DataUtil; import io.jans.configapi.util.ApiConstants; import io.jans.model.SearchRequest; import io.jans.orm.PersistenceEntryManager; @@ -32,7 +33,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -import java.util.Map; /** * @author Yuriy Movchan @@ -86,48 +86,38 @@ public PagedResult searchFido2Registration(SearchRequest if (searchRequest.getFilterAssertionValue() != null && !searchRequest.getFilterAssertionValue().isEmpty()) { for (String assertionValue : searchRequest.getFilterAssertionValue()) { - log.debug(" **** Search Fido2Registration with assertionValue:{}", assertionValue); - if (StringUtils.isNotBlank(assertionValue)) { - String[] targetArray = new String[] { assertionValue }; - - Filter displayNameFilter = Filter.createSubstringFilter("displayName", null, targetArray, null); - Filter descriptionFilter = Filter.createSubstringFilter("jansRegistrationData", null, targetArray, - null); - Filter statusFilter = Filter.createSubstringFilter("jansStatus", null, targetArray, null); - Filter notificationConfFilter = Filter.createSubstringFilter("jansDeviceNotificationConf", null, - targetArray, null); - Filter deviceDataFilter = Filter.createSubstringFilter("jansDeviceData", null, targetArray, null); - Filter personInumFilter = Filter.createSubstringFilter("personInum", null, targetArray, null); - Filter inumFilter = Filter.createSubstringFilter("jansId", null, targetArray, null); - - filters.add(Filter.createORFilter(displayNameFilter, descriptionFilter, statusFilter, - notificationConfFilter, deviceDataFilter, personInumFilter, inumFilter)); - } + log.info(" **** Search Fido2Registration with assertionValue:{}", assertionValue); + + String[] targetArray = new String[] { assertionValue }; + + Filter displayNameFilter = Filter.createSubstringFilter("displayName", null, targetArray, null); + Filter descriptionFilter = Filter.createSubstringFilter("jansRegistrationData", null, targetArray, + null); + Filter statusFilter = Filter.createSubstringFilter("jansStatus", null, targetArray, null); + Filter notificationConfFilter = Filter.createSubstringFilter("jansDeviceNotificationConf", null, + targetArray, null); + Filter deviceDataFilter = Filter.createSubstringFilter("jansDeviceData", null, targetArray, null); + Filter personInumFilter = Filter.createSubstringFilter("personInum", null, targetArray, null); + Filter inumFilter = Filter.createSubstringFilter("jansId", null, targetArray, null); + + filters.add(Filter.createORFilter(displayNameFilter, descriptionFilter, statusFilter, + notificationConfFilter, deviceDataFilter, personInumFilter, inumFilter)); + } searchFilter = Filter.createORFilter(filters); } - log.debug("\n\n\n Fido2Registration pattern searchFilter:{}", searchFilter); + log.debug("Fido2Registration pattern searchFilter:{}", searchFilter); List fieldValueFilters = new ArrayList<>(); - if (searchRequest.getFieldValueMap() != null && !searchRequest.getFieldValueMap().isEmpty()) { - for (Map.Entry entry : searchRequest.getFieldValueMap().entrySet()) { - Filter dataFilter = Filter.createEqualityFilter(entry.getKey(), entry.getValue()); - log.trace("Fido2Registration dataFilter:{}", dataFilter); - fieldValueFilters.add(Filter.createANDFilter(dataFilter)); - } - - if(!filters.isEmpty()) { - searchFilter = Filter.createANDFilter(Filter.createORFilter(filters), - Filter.createANDFilter(fieldValueFilters)); - } - else { - searchFilter = Filter.createANDFilter(fieldValueFilters); - } - + if (searchRequest.getFieldFilterData() != null && !searchRequest.getFieldFilterData().isEmpty()) { + fieldValueFilters = DataUtil.createFilter(searchRequest.getFieldFilterData(), + getDnFido2RegistrationEntry(null), persistenceEntryManager); } - log.debug(" Final - Fido2Registration searchFilter:{}", searchFilter); + fieldValueFilters.add(Filter.createORFilter(filters)); + + log.info(" Final - Fido2Registration searchFilter:{}", searchFilter); return persistenceEntryManager.findPagedEntries(getDnFido2RegistrationEntry(null), Fido2RegistrationEntry.class, searchFilter, null, searchRequest.getSortBy(), SortOrder.getByValue(searchRequest.getSortOrder()), @@ -147,15 +137,16 @@ public List findAllRegisteredByUsername(String username) } String baseDn = getBaseDnForFido2RegistrationEntries(userInum); - log.debug("Find Fido2 Registered by baseDn:{}", baseDn); + log.info("Find Fido2 Registered by baseDn:{}", baseDn); if (persistenceEntryManager.hasBranchesSupport(baseDn) && !containsBranch(baseDn)) { return Collections.emptyList(); } - Filter registeredFilter = Filter.createEqualityFilter("jansStatus", - Fido2RegistrationStatus.registered.getValue()); - log.info("Find Fido2 Registered by registeredFilter:{}", registeredFilter); - return persistenceEntryManager.findEntries(baseDn, Fido2RegistrationEntry.class, registeredFilter); + Filter searchFilter = Filter.createANDFilter(Filter.createEqualityFilter("personInum", userInum), + Filter.createEqualityFilter("jansStatus", Fido2RegistrationStatus.registered.getValue())); + + log.info("Find Fido2 Registered by searchFilter:{}", searchFilter); + return persistenceEntryManager.findEntries(getDnFido2RegistrationEntry(null), Fido2RegistrationEntry.class, searchFilter); } public String getBaseDnForFido2RegistrationEntries(String userInum) { diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/SessionService.java b/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/SessionService.java index 5c18136d2b8..d604bf07c99 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/SessionService.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/SessionService.java @@ -10,6 +10,8 @@ import io.jans.as.common.model.session.SessionIdState; import io.jans.as.model.config.StaticConfiguration; import io.jans.configapi.util.ApiConstants; +import io.jans.configapi.core.util.DataUtil; +import io.jans.model.FieldFilterData; import io.jans.model.SearchRequest; import io.jans.model.token.TokenEntity; import io.jans.model.token.TokenType; @@ -19,7 +21,6 @@ import io.jans.orm.search.filter.Filter; import io.jans.service.CacheService; import io.jans.util.StringHelper; - import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; import jakarta.ws.rs.NotFoundException; @@ -29,7 +30,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.Map; import org.apache.commons.lang.StringUtils; import org.slf4j.Logger; @@ -62,6 +62,15 @@ public String getDnForSession(String sessionId) { return String.format("jansId=%s,%s", sessionId, staticConfiguration.getBaseDn().getSessions()); } + public String getDnForUser(String userInum) { + String peopleDn = staticConfiguration.getBaseDn().getPeople(); + if (StringHelper.isEmpty(userInum)) { + return peopleDn; + } + + return String.format("inum=%s,%s", userInum, peopleDn); + } + public SessionId getSessionBySid(String sid) { if (logger.isInfoEnabled()) { logger.info(SID_MSG, escapeLog(sid)); @@ -113,40 +122,35 @@ public PagedResult searchSession(SearchRequest searchRequest) { if (searchRequest.getFilterAssertionValue() != null && !searchRequest.getFilterAssertionValue().isEmpty()) { for (String assertionValue : searchRequest.getFilterAssertionValue()) { - logger.debug("Session Search with assertionValue:{}", assertionValue); - if (StringUtils.isNotBlank(assertionValue)) { - String[] targetArray = new String[] { assertionValue }; - Filter userFilter = Filter.createSubstringFilter(ApiConstants.JANS_USR_DN, null, targetArray, null); - Filter sidFilter = Filter.createSubstringFilter(ApiConstants.SID, null, targetArray, null); - Filter sessAttrFilter = Filter.createSubstringFilter(ApiConstants.JANS_SESS_ATTR, null, targetArray, - null); - Filter permissionFilter = Filter.createSubstringFilter("jansPermissionGrantedMap", null, - targetArray, null); - Filter idFilter = Filter.createSubstringFilter(ApiConstants.JANSID, null, targetArray, null); - filters.add( - Filter.createORFilter(userFilter, sidFilter, sessAttrFilter, permissionFilter, idFilter)); - } + logger.info("Session Search with assertionValue:{}", assertionValue); + + String[] targetArray = new String[] { assertionValue }; + Filter userFilter = Filter.createSubstringFilter(ApiConstants.JANS_USR_DN, null, targetArray, null); + Filter sidFilter = Filter.createSubstringFilter(ApiConstants.SID, null, targetArray, null); + Filter sessAttrFilter = Filter.createSubstringFilter(ApiConstants.JANS_SESS_ATTR, null, targetArray, + null); + Filter permissionFilter = Filter.createSubstringFilter("jansPermissionGrantedMap", null, targetArray, + null); + Filter idFilter = Filter.createSubstringFilter(ApiConstants.JANSID, null, targetArray, null); + filters.add(Filter.createORFilter(userFilter, sidFilter, sessAttrFilter, permissionFilter, idFilter)); + } searchFilter = Filter.createORFilter(filters); } logger.debug("Session pattern searchFilter:{}", searchFilter); + List fieldValueFilters = new ArrayList<>(); - if (searchRequest.getFieldValueMap() != null && !searchRequest.getFieldValueMap().isEmpty()) { - for (Map.Entry entry : searchRequest.getFieldValueMap().entrySet()) { - Filter dataFilter = Filter.createEqualityFilter(entry.getKey(), entry.getValue()); - logger.trace("Session dataFilter:{}", dataFilter); - fieldValueFilters.add(Filter.createANDFilter(dataFilter)); - } - if (filters.isEmpty()) { - searchFilter = Filter.createANDFilter(fieldValueFilters); - } else { - searchFilter = Filter.createANDFilter(Filter.createORFilter(filters), - Filter.createANDFilter(fieldValueFilters)); - } + if (searchRequest.getFieldFilterData() != null && !searchRequest.getFieldFilterData().isEmpty()) { + List fieldFilterDataList = this.modifyFilter(searchRequest.getFieldFilterData()); + fieldValueFilters = DataUtil.createFilter(fieldFilterDataList, getDnForSession(null), + persistenceEntryManager); } - logger.debug("Session searchFilter:{}", searchFilter); + fieldValueFilters.add(Filter.createORFilter(filters)); + searchFilter = Filter.createANDFilter(fieldValueFilters); + + logger.info("Session searchFilter:{}", searchFilter); PagedResult pagedSessionList = persistenceEntryManager.findPagedEntries(getDnForSession(null), SessionId.class, searchFilter, null, searchRequest.getSortBy(), @@ -283,4 +287,24 @@ private SessionId excludeAttribute(SessionId session) { return session; } + private List modifyFilter(List fieldFilterDataList) { + + logger.debug("modify filter - fieldFilterDataList:{}", fieldFilterDataList); + if (fieldFilterDataList == null || fieldFilterDataList.isEmpty()) { + return fieldFilterDataList; + } + + for (FieldFilterData fieldFilterData : fieldFilterDataList) { + if (fieldFilterData != null && StringUtils.isNotBlank(fieldFilterData.getField())) { + String field = fieldFilterData.getField(); + if ("jansUsrDN".equalsIgnoreCase(field)) { + // get Dn + fieldFilterData.setValue(getDnForUser(fieldFilterData.getValue())); + } + } + } + + return fieldFilterDataList; + } + } diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/TokenService.java b/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/TokenService.java index 0f30c4b7a36..be0e58866dc 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/TokenService.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/service/auth/TokenService.java @@ -1,6 +1,9 @@ package io.jans.configapi.service.auth; import io.jans.as.common.service.OrganizationService; +import io.jans.as.model.config.StaticConfiguration; +import io.jans.configapi.core.util.DataUtil; +import io.jans.model.FieldFilterData; import io.jans.model.SearchRequest; import io.jans.model.token.TokenEntity; import io.jans.orm.PersistenceEntryManager; @@ -30,6 +33,9 @@ public class TokenService { @Inject private OrganizationService organizationService; + @Inject + StaticConfiguration staticConfiguration; + public String getDnForTokenEntity(String tknCde) { String orgDn = organizationService.getDnForOrganization(); if (StringHelper.isEmpty(tknCde)) { @@ -38,6 +44,15 @@ public String getDnForTokenEntity(String tknCde) { return String.format("tknCde=%s,ou=tokens,%s", tknCde, orgDn); } + public String getDnForUser(String userInum) { + String peopleDn = staticConfiguration.getBaseDn().getPeople(); + if (StringHelper.isEmpty(userInum)) { + return peopleDn; + } + + return String.format("inum=%s,%s", userInum, peopleDn); + } + public TokenEntity getTokenEntityByCode(String tknCde) { if (logger.isInfoEnabled()) { logger.info("Get token - tknCde():{}", escapeLog(tknCde)); @@ -60,20 +75,19 @@ public PagedResult searchToken(SearchRequest searchRequest) { logger.trace("Search Token searchRequest.getFilterAssertionValue() :{}", searchRequest.getFilterAssertionValue()); for (String assertionValue : searchRequest.getFilterAssertionValue()) { - logger.debug("Session Search with assertionValue:{}", assertionValue); - if (StringUtils.isNotBlank(assertionValue)) { - String[] targetArray = new String[] { assertionValue }; - Filter grantIdFilter = Filter.createSubstringFilter("grtId", null, targetArray, null); - Filter userIdFilter = Filter.createSubstringFilter("usrId", null, targetArray, null); - Filter userDnFilter = Filter.createSubstringFilter("jansUsrDN", null, targetArray, null); - Filter clientIdFilter = Filter.createSubstringFilter("clnId", null, targetArray, null); - Filter scopeFilter = Filter.createSubstringFilter("scp", null, targetArray, null); - Filter tokenTypeFilter = Filter.createSubstringFilter("tknTyp", null, targetArray, null); - Filter grantTypeFilter = Filter.createSubstringFilter("grtTyp", null, targetArray, null); - Filter inumFilter = Filter.createSubstringFilter("jansId", null, targetArray, null); - filters.add(Filter.createORFilter(grantIdFilter, userIdFilter, userDnFilter, clientIdFilter, - scopeFilter, tokenTypeFilter, grantTypeFilter, inumFilter)); - } + logger.info("Session Search with assertionValue:{}", assertionValue); + String[] targetArray = new String[] { assertionValue }; + Filter grantIdFilter = Filter.createSubstringFilter("grtId", null, targetArray, null); + Filter userIdFilter = Filter.createSubstringFilter("usrId", null, targetArray, null); + Filter userDnFilter = Filter.createSubstringFilter("jansUsrDN", null, targetArray, null); + Filter clientIdFilter = Filter.createSubstringFilter("clnId", null, targetArray, null); + Filter scopeFilter = Filter.createSubstringFilter("scp", null, targetArray, null); + Filter tokenTypeFilter = Filter.createSubstringFilter("tknTyp", null, targetArray, null); + Filter grantTypeFilter = Filter.createSubstringFilter("grtTyp", null, targetArray, null); + Filter inumFilter = Filter.createSubstringFilter("jansId", null, targetArray, null); + filters.add(Filter.createORFilter(grantIdFilter, userIdFilter, userDnFilter, clientIdFilter, + scopeFilter, tokenTypeFilter, grantTypeFilter, inumFilter)); + } searchFilter = Filter.createORFilter(filters); logger.trace("Search Token searchFilter :{}", searchFilter); @@ -81,21 +95,15 @@ public PagedResult searchToken(SearchRequest searchRequest) { logger.debug("Token pattern searchFilter:{}", searchFilter); List fieldValueFilters = new ArrayList<>(); - if (searchRequest.getFieldValueMap() != null && !searchRequest.getFieldValueMap().isEmpty()) { - for (Map.Entry entry : searchRequest.getFieldValueMap().entrySet()) { - Filter dataFilter = Filter.createSubstringFilter(entry.getKey(), null, - new String[] { entry.getValue() }, null); - logger.trace("Token dataFilter:{}", dataFilter); - fieldValueFilters.add(Filter.createANDFilter(dataFilter)); - } - if (filters.isEmpty()) { - searchFilter = Filter.createANDFilter(fieldValueFilters); - } else { - searchFilter = Filter.createANDFilter(Filter.createORFilter(filters), - Filter.createANDFilter(fieldValueFilters)); - } + if (searchRequest.getFieldFilterData() != null && !searchRequest.getFieldFilterData().isEmpty()) { + List fieldFilterDataList = this.modifyFilter(searchRequest.getFieldFilterData()); + fieldValueFilters = DataUtil.createFilter(fieldFilterDataList, getDnForTokenEntity(null), + persistenceEntryManager); } + fieldValueFilters.add(Filter.createORFilter(filters)); + searchFilter = Filter.createANDFilter(fieldValueFilters); + logger.info("Token final searchFilter:{}", searchFilter); return persistenceEntryManager.findPagedEntries(getDnForTokenEntity(null), TokenEntity.class, searchFilter, @@ -138,4 +146,24 @@ public void revokeTokenEntity(String tknCde) { persistenceEntryManager.removeRecursively(tokenEntity.getDn(), TokenEntity.class); } + private List modifyFilter(List fieldFilterDataList) { + + logger.debug("modify filter - fieldFilterDataList:{}", fieldFilterDataList); + if (fieldFilterDataList == null || fieldFilterDataList.isEmpty()) { + return fieldFilterDataList; + } + + for (FieldFilterData fieldFilterData : fieldFilterDataList) { + if (fieldFilterData != null && StringUtils.isNotBlank(fieldFilterData.getField())) { + String field = fieldFilterData.getField(); + if ("jansUsrDN".equalsIgnoreCase(field)) { + // get Dn + fieldFilterData.setValue(getDnForUser(fieldFilterData.getValue())); + } + } + } + + return fieldFilterDataList; + } + } diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/rest/BaseResource.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/rest/BaseResource.java index 0555622108b..00272a375d2 100644 --- a/jans-config-api/shared/src/main/java/io/jans/configapi/core/rest/BaseResource.java +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/rest/BaseResource.java @@ -11,6 +11,7 @@ import io.jans.configapi.core.interceptor.RequestAuditInterceptor; import io.jans.configapi.core.interceptor.RequestInterceptor; import io.jans.configapi.core.model.ApiError; +import io.jans.model.FilterOperator; import io.jans.model.SearchRequest; import io.jans.configapi.core.util.Util; import io.jans.orm.model.SortOrder; @@ -64,10 +65,11 @@ public HttpHeaders getHttpHeaders() { private static Logger log = LoggerFactory.getLogger(BaseResource.class); - public static final String MISSING_ATTRIBUTE_CODE = "OCA001"; - public static final String MISSING_ATTRIBUTE_MESSAGE = "A required attribute is missing."; - public static final String TOKEN_DELIMITER = ","; - public static final String FIELD_VALUE_SEPARATOR = "="; + private static final String MISSING_ATTRIBUTE_CODE = "OCA001"; + private static final String MISSING_ATTRIBUTE_MESSAGE = "A required attribute is missing."; + private static final String TOKEN_DELIMITER = ","; + private static final String FIELD_VALUE_SEPARATOR = "="; + private static final List FIELD_VALUE_SEPARATOR_ARR = FilterOperator.getAllOperatorSign(); public static void checkResourceNotNull(T resource, String objectName) { if (resource == null) { @@ -254,7 +256,11 @@ protected SearchRequest createSearchRequest(String schemas, String filter, Strin if (StringUtils.isEmpty(sortOrder) || !sortOrder.equals(SortOrder.DESCENDING.getValue())) { sortOrder = SortOrder.ASCENDING.getValue(); } - log.debug(" util.getTokens(filter,TOKEN_DELIMITER):{} , util.getFieldValueMap(searchRequest, fieldValuePair, TOKEN_DELIMITER, FIELD_VALUE_SEPARATOR)):{}", util.getTokens(filter, TOKEN_DELIMITER), util.getFieldValueMap(entityClass, fieldValuePair, TOKEN_DELIMITER, FIELD_VALUE_SEPARATOR)); + log.debug( + " util.getTokens(filter,TOKEN_DELIMITER):{} , util.getFieldValueMap(searchRequest, fieldValuePair, TOKEN_DELIMITER, FIELD_VALUE_SEPARATOR)):{}, FIELD_VALUE_SEPARATOR_ARR:{}", + util.getTokens(filter, TOKEN_DELIMITER), + util.getFieldValueMap(entityClass, fieldValuePair, TOKEN_DELIMITER, FIELD_VALUE_SEPARATOR), + FIELD_VALUE_SEPARATOR_ARR); searchRequest.setSchemas(schemas); searchRequest.setAttributes(attrsList); searchRequest.setExcludedAttributes(excludedAttrsList); @@ -265,7 +271,10 @@ protected SearchRequest createSearchRequest(String schemas, String filter, Strin searchRequest.setCount(count); searchRequest.setMaxCount(maximumRecCount); searchRequest.setFilterAssertionValue(util.getTokens(filter, TOKEN_DELIMITER)); - searchRequest.setFieldValueMap((util.getFieldValueMap(entityClass, fieldValuePair, TOKEN_DELIMITER, FIELD_VALUE_SEPARATOR))); + searchRequest.setFieldValueMap( + (util.getFieldValueMap(entityClass, fieldValuePair, TOKEN_DELIMITER, FIELD_VALUE_SEPARATOR))); + searchRequest.setFieldFilterData( + (util.getFieldValueList(entityClass, fieldValuePair, TOKEN_DELIMITER, FIELD_VALUE_SEPARATOR_ARR))); return searchRequest; } diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/util/DataUtil.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/util/DataUtil.java index c58ea277495..9e22dd68f0c 100644 --- a/jans-config-api/shared/src/main/java/io/jans/configapi/core/util/DataUtil.java +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/util/DataUtil.java @@ -1,10 +1,15 @@ package io.jans.configapi.core.util; import io.jans.as.model.json.JsonApplier; +import io.jans.model.FieldFilterData; +import io.jans.model.FilterOperator; +import io.jans.model.attribute.AttributeDataType; +import io.jans.orm.PersistenceEntryManager; import io.jans.orm.exception.MappingException; import io.jans.orm.reflect.property.Getter; import io.jans.orm.reflect.property.Setter; import io.jans.orm.reflect.util.ReflectHelper; +import io.jans.orm.search.filter.Filter; import io.jans.util.StringHelper; import jakarta.enterprise.context.ApplicationScoped; @@ -15,8 +20,10 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -195,4 +202,207 @@ public static boolean isAttributeInExclusion(String className, String attribute, return false; } + public static Map getFieldDataType(Class clazz, List fieldList) { + logger.info("Get FieldDataType - clazz:{}, fieldList:{}", clazz, fieldList); + Map fieldTypeMap = null; + if (clazz == null || fieldList == null || fieldList.isEmpty()) { + return fieldTypeMap; + } + + fieldTypeMap = getFieldTypeMap(clazz); + if (fieldTypeMap.isEmpty()) { + return fieldTypeMap; + } + + fieldTypeMap.keySet().retainAll(fieldList); + + logger.info("Final - fieldList:{} of fieldTypeMap:{} ", fieldList, fieldTypeMap); + return fieldTypeMap; + } + + public static Map getFieldType(Class clazz, List fieldFilterData) { + logger.info("Get field clazz:{}, fieldFilterData:{}", clazz, fieldFilterData); + Map fieldTypeMap = null; + if (clazz == null || fieldFilterData == null || fieldFilterData.isEmpty()) { + return fieldTypeMap; + } + + List fieldList = new ArrayList<>(); + for (FieldFilterData entry : fieldFilterData) { + fieldList.add(entry.getField()); + } + return getFieldDataType(clazz, fieldList); + } + + public static List createFilter(List fieldFilterData, String primaryKey, + PersistenceEntryManager persistenceEntryManager) { + logger.info("Create ORM Filter for fieldFilterData:{}, primaryKey:{}, persistenceEntryManager:{}", + fieldFilterData, primaryKey, persistenceEntryManager); + List filters = new ArrayList<>(); + + if (fieldFilterData == null || fieldFilterData.isEmpty()) { + return filters; + } + + for (FieldFilterData entry : fieldFilterData) { + logger.info("FieldFilterData entry:{}", entry); + String dataType = AttributeDataType.STRING.getValue(); + + if (StringUtils.isNotBlank(entry.getType())) { + dataType = entry.getType(); + } + logger.info( + "entry.getField():{}, dataType:{}, AttributeDataType.STRING.getValue():{}, AttributeDataType.STRING.getValue():{}, AttributeDataType.DATE.getDisplayName():{}", + entry.getField(), dataType, AttributeDataType.STRING.getValue(), + AttributeDataType.STRING.getValue(), AttributeDataType.DATE.getDisplayName()); + + Filter dataFilter = null; + if (AttributeDataType.STRING.getValue().equalsIgnoreCase(dataType)) { + dataFilter = Filter.createEqualityFilter(entry.getField(), entry.getValue()); + } else if (AttributeDataType.BOOLEAN.getValue().equalsIgnoreCase(dataType)) { + dataFilter = Filter.createEqualityFilter(entry.getField(), getBooleanValue(entry.getValue())); + } else if (AttributeDataType.DATE.getDisplayName().equalsIgnoreCase(dataType)) { + dataFilter = createDateFilter(entry, primaryKey, persistenceEntryManager); + } else if ("int".equalsIgnoreCase(dataType) || "integer".equalsIgnoreCase(dataType)) { + dataFilter = createIntegerFilter(entry); + } else { + dataFilter = Filter.createEqualityFilter(entry.getField(), entry.getValue()); + } + filters.add(dataFilter); + logger.info("dataFilter:{}", dataFilter); + + } + logger.info("Final Filters for fieldFilterData - filters:{}", filters); + return filters; + } + + private static boolean getBooleanValue(String strValue) { + logger.info("Get Boolean Value for strValue:{}", strValue); + + boolean value = false; + if (StringUtils.isBlank(strValue) || !strValue.toLowerCase().matches("true|false")) { + return value; + } + + return Boolean.parseBoolean(strValue); + + } + + private static Date getDate(String dateString, String primaryKey, PersistenceEntryManager persistenceEntryManager) { + logger.info("Get Date Value for dateString:{}, primaryKey:{}, persistenceEntryManager:{}", dateString, + primaryKey, persistenceEntryManager); + Date dateValue = null; + if (StringUtils.isBlank(dateString) || StringUtils.isBlank(primaryKey) || persistenceEntryManager == null) { + return dateValue; + } + + dateValue = persistenceEntryManager.decodeTime(primaryKey, dateString); + logger.info(" persistenceEntryManager.decodeTime - dateString:{}, dateValue:{}", dateString, dateValue); + + dateValue = formatStrDate(dateString, null); + logger.info(" formatStrDate - dateValue:{}", dateValue); + + return dateValue; + + } + + private static Date formatStrDate(String dateString, String datePattern) { + logger.debug("Format String Date - dateString:{}: datePattern:{}", dateString, datePattern); + Date date = null; + try { + if (StringUtils.isBlank(dateString)) { + return date; + } + + if (StringUtils.isBlank(datePattern)) { + if (dateString.contains(":")) { + datePattern = "yyyy-MM-dd HH:mm:ss"; + } else { + datePattern = "yyyy-MM-dd"; + } + } + + SimpleDateFormat dateFormat = new SimpleDateFormat(datePattern); + logger.debug("dateFormat:{} ", dateFormat); + + date = dateFormat.parse(dateString); + logger.info("Returning dateFormat:{}, date:{} ", dateFormat, date); + + } catch (Exception ex) { + logger.error("Error while formatting String Date - dateString{" + dateString + "}", ex); + return date; + } + + return date; + } + + private static Filter createDateFilter(FieldFilterData fieldFilterData, String primaryKey, + PersistenceEntryManager persistenceEntryManager) { + logger.info("Create Date Filter for fieldFilterData:{}, primaryKey:{}, persistenceEntryManager:{}", + fieldFilterData, primaryKey, persistenceEntryManager); + + Filter dateFilter = null; + if (fieldFilterData == null) { + return dateFilter; + } + Date dateValue = getDate(fieldFilterData.getValue(), primaryKey, persistenceEntryManager); + + if (FilterOperator.EQUALITY.getSign().equalsIgnoreCase(fieldFilterData.getOperator())) { + dateFilter = Filter.createGreaterOrEqualFilter(fieldFilterData.getField(), dateValue); + + } else if (FilterOperator.GREATER.getSign().equalsIgnoreCase(fieldFilterData.getOperator()) + || FilterOperator.GREATER_OR_EQUAL.getSign().equalsIgnoreCase(fieldFilterData.getOperator())) { + + dateFilter = Filter.createGreaterOrEqualFilter(fieldFilterData.getField(), dateValue); + + } else if (FilterOperator.LESS.getSign().equalsIgnoreCase(fieldFilterData.getOperator()) + || FilterOperator.GREATER_OR_EQUAL.getSign().equalsIgnoreCase(fieldFilterData.getOperator())) { + + dateFilter = Filter.createLessOrEqualFilter(fieldFilterData.getField(), dateValue); + + } + logger.info("Final Date Filter for fieldFilterData:{}, dateFilter:{}", fieldFilterData, dateFilter); + return dateFilter; + } + + private static Filter createIntegerFilter(FieldFilterData fieldFilterData) { + logger.info("Create Integer Filter for fieldFilterData:{}", fieldFilterData); + + Filter dataFilter = null; + if (fieldFilterData == null) { + return dataFilter; + } + + String dataValue = fieldFilterData.getValue(); + Integer intValue = null; + if (StringUtils.isNotBlank(fieldFilterData.getValue())) { + try { + intValue = Integer.parseInt(fieldFilterData.getValue()); + } catch (Exception ex) { + logger.error("Though Data type is numeric but value is not numeric{" + fieldFilterData.getValue() + "}", + ex); + } + + } + logger.info("Create Integer Filter for intValue:{}", intValue); + + if (FilterOperator.EQUALITY.getSign().equalsIgnoreCase(fieldFilterData.getOperator())) { + + dataFilter = Filter.createEqualityFilter(fieldFilterData.getField(), dataValue); + + } else if (FilterOperator.GREATER.getSign().equalsIgnoreCase(fieldFilterData.getOperator()) + || FilterOperator.GREATER_OR_EQUAL.getSign().equalsIgnoreCase(fieldFilterData.getOperator())) { + + dataFilter = Filter.createGreaterOrEqualFilter(fieldFilterData.getField(), dataValue); + + } else if (FilterOperator.LESS.getSign().equalsIgnoreCase(fieldFilterData.getOperator()) + || FilterOperator.GREATER_OR_EQUAL.getSign().equalsIgnoreCase(fieldFilterData.getOperator())) { + + dataFilter = Filter.createLessOrEqualFilter(fieldFilterData.getField(), dataValue); + + } + logger.info("Final Date Filter for fieldFilterData:{}, dataValue:{}", fieldFilterData, dataValue); + return dataFilter; + } + } diff --git a/jans-config-api/shared/src/main/java/io/jans/configapi/core/util/Util.java b/jans-config-api/shared/src/main/java/io/jans/configapi/core/util/Util.java index 1af44b0c39d..ff881b28597 100644 --- a/jans-config-api/shared/src/main/java/io/jans/configapi/core/util/Util.java +++ b/jans-config-api/shared/src/main/java/io/jans/configapi/core/util/Util.java @@ -7,7 +7,7 @@ package io.jans.configapi.core.util; import io.jans.configapi.core.service.ConfService; -import io.jans.model.SearchRequest; +import io.jans.model.FieldFilterData; import io.jans.orm.annotation.AttributeName; import io.jans.orm.annotation.AttributesList; @@ -91,13 +91,17 @@ public Map getFieldValueMap(Class entityClass, String str, St } for (String data : fieldValueList) { - StringTokenizer st = new StringTokenizer(str, fieldValueSeparator); - - if (StringUtils.isNotBlank(data) && st.hasMoreTokens()) { - String[] keyValue = data.split("="); - log.debug("fieldValueMap:{},keyValue:{}, keyValue[0]:{}, keyValue[1]):{}", fieldValueMap, keyValue, - keyValue[0], keyValue[1]); - fieldValueMap.put(keyValue[0], keyValue[1]); + String[] result = data.split(fieldValueSeparator); + + log.debug("fieldValueSeparator:{}, result:{}", fieldValueSeparator, result); + if (result != null && result.length > 0) { + String fieldName = result[0]; + String value = null; + if (result.length > 1) { + value = result[1]; + } + log.info("fieldName:{},value:{}", fieldName, value); + fieldValueMap.put(fieldName, value); } } @@ -108,7 +112,86 @@ public Map getFieldValueMap(Class entityClass, String str, St return fieldValueMap; } - public Map getAttributeData(Class entityClass, Map fieldValueMap) { + public List getFieldValueList(Class entityClass, String str, String tokenizer, + List fieldValueSeparator) { + if (log.isInfoEnabled()) { + log.info(" Get FieldValueList - entityClass:{}, str:{}, tokenizer:{} fieldValueSeparator:{}", + escapeLog(entityClass), escapeLog(str), escapeLog(tokenizer), escapeLog(fieldValueSeparator)); + } + + List fieldFilterDataList = new ArrayList<>(); + + if (StringUtils.isBlank(str)) { + return fieldFilterDataList; + } + + List fieldValueList = getTokens(str, tokenizer); + log.debug("After tokenizing fieldValueList:{}", fieldValueList); + + if (fieldValueList == null || fieldValueList.isEmpty()) { + return fieldFilterDataList; + } + + Map> propertiesAnnotations = getPropertiesAnnotations(entityClass); + Map fieldTypeMap = DataUtil.getFieldTypeMap(entityClass); + + for (String data : fieldValueList) { + if (StringUtils.isNotBlank(data)) { + FieldFilterData fieldFilterData = this.getFieldFilterData(propertiesAnnotations, fieldTypeMap, data, + fieldValueSeparator); + fieldFilterDataList.add(fieldFilterData); + } + } + + log.info("Returning fieldFilterDataList:{}", fieldFilterDataList); + + return fieldFilterDataList; + } + + private FieldFilterData getFieldFilterData(Map> propertiesAnnotations, + Map fieldTypeMap, String dataStr, List fieldValueSeparator) { + log.info("Get FieldFilterData - dataStr:{} , fieldValueSeparator:{}", dataStr, fieldValueSeparator); + + FieldFilterData fieldFilterData = null; + if (StringUtils.isBlank(dataStr) || fieldValueSeparator == null || fieldValueSeparator.isEmpty()) { + return fieldFilterData; + } + for (String separator : fieldValueSeparator) { + if (dataStr.contains(separator)) { + String[] result = dataStr.split(separator); + + log.debug("separator:{}, result:{}", separator, result); + if (result != null && result.length > 0) { + String fieldName = result[0]; + String value = null; + if (result.length > 1) { + value = result[1]; + } + String dbFieldName = getFieldDBName(fieldName, propertiesAnnotations.get(fieldName)); + String fieldType = getFieldDataType(fieldName, fieldTypeMap); + log.debug("fieldName:{}, dbFieldName:{}, fieldType:{}, value:{}, separator:{}", fieldName, + dbFieldName, fieldType, value, separator); + fieldFilterData = new FieldFilterData(dbFieldName, separator, value, fieldType); + + } + } + log.info("Final fieldFilterData:{}", fieldFilterData); + } + return fieldFilterData; + + } + + private String getFieldDataType(String fieldName, Map fieldTypeMap) { + log.info("Get data type for fieldName:{}, fieldTypeMap:{}", fieldName, fieldTypeMap); + String fieldType = "String"; + if (StringUtils.isBlank(fieldName) || fieldTypeMap == null || fieldTypeMap.isEmpty()) { + return fieldType; + } + + return fieldTypeMap.get(fieldName); + } + + private Map getAttributeData(Class entityClass, Map fieldValueMap) { if (log.isInfoEnabled()) { log.info("AttributeData details to be fetched for entityClass:{} with fieldValueMap:{} ", escapeLog(entityClass), escapeLog(fieldValueMap)); @@ -128,7 +211,7 @@ public Map getAttributeData(Class entityClass, Map updatedFieldValueMap = new HashMap<>(); - if (fieldValueMap != null && !fieldValueMap.isEmpty()) { + if (!fieldValueMap.isEmpty()) { for (Map.Entry entry : fieldValueMap.entrySet()) { log.debug("entry.getKey():{}, entry.getValue():{}", entry.getKey(), entry.getValue()); @@ -164,4 +247,20 @@ private String getFieldDBName(String fieldName, List annotations) { log.info("Final DB field fieldName:{} ", fieldName); return fieldName; } + + private Map> getPropertiesAnnotations(Class entityClass) { + log.info("Get propertiesAnnotations for entityClass:{}", entityClass); + + Map> propertiesAnnotations = null; + if (entityClass == null) { + return propertiesAnnotations; + } + + propertiesAnnotations = confService.getPropertiesAnnotations(entityClass, LDAP_ENTRY_PROPERTY_ANNOTATIONS); + log.debug("Properties annotations fetched for theClass:{} are propertiesAnnotations:{}", entityClass, + propertiesAnnotations); + + return propertiesAnnotations; + + } } diff --git a/jans-core/model/src/main/java/io/jans/model/FilterOperator.java b/jans-core/model/src/main/java/io/jans/model/FilterOperator.java new file mode 100644 index 00000000000..7c915883401 --- /dev/null +++ b/jans-core/model/src/main/java/io/jans/model/FilterOperator.java @@ -0,0 +1,32 @@ +/* + * Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. + * + * Copyright (c) 2020, Janssen Project + */ + +package io.jans.model; + +import java.util.List; +import java.util.Arrays; +import java.util.stream.Collectors; + + +public enum FilterOperator { + + EQUALITY("="), LESS("<"), LESS_OR_EQUAL("<="), GREATER(">"), GREATER_OR_EQUAL(">="); + + private String sign; + + FilterOperator(String sign) { + this.sign = sign; + } + + public final String getSign() { + return sign; + } + + public static List getAllOperatorSign(){ + return Arrays.asList(values()).stream().map(FilterOperator::getSign).collect(Collectors.toList()); + } + +} diff --git a/jans-core/service/src/main/java/io/jans/model/FieldFilterData.java b/jans-core/service/src/main/java/io/jans/model/FieldFilterData.java new file mode 100644 index 00000000000..624ec44df15 --- /dev/null +++ b/jans-core/service/src/main/java/io/jans/model/FieldFilterData.java @@ -0,0 +1,60 @@ +package io.jans.model; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class FieldFilterData { + + private String field; + private String operator; + private String value; + private String type; + + public FieldFilterData() {} + + public FieldFilterData(String field, String operator, String value, String type) { + this.field = field; + this.operator = operator; + this.value = value; + this.type = type; + } + + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + + public String getOperator() { + return operator; + } + + public void setOperator(String operator) { + this.operator = operator; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + @Override + public String toString() { + return "FieldFilterData [field:" + field + ", operator:" + operator + ", value:" + value + ", type:" + type + + "]"; + } + +} diff --git a/jans-core/service/src/main/java/io/jans/model/SearchRequest.java b/jans-core/service/src/main/java/io/jans/model/SearchRequest.java index 39643fcb804..6221e346968 100644 --- a/jans-core/service/src/main/java/io/jans/model/SearchRequest.java +++ b/jans-core/service/src/main/java/io/jans/model/SearchRequest.java @@ -24,6 +24,7 @@ public class SearchRequest { private List filterAttributeName; private List filterAssertionValue; private Map fieldValueMap; + private List fieldFilterData; @JsonIgnore private String attributesStr; @@ -159,14 +160,24 @@ public void setFieldValueMap(Map fieldValueMap) { this.fieldValueMap = fieldValueMap; } + public List getFieldFilterData() { + return fieldFilterData; + } + + public void setFieldFilterData(List fieldFilterData) { + this.fieldFilterData = fieldFilterData; + } + @Override public String toString() { return "SearchRequest [entityClass=" + entityClass + ", schemas=" + schemas + ", attributes=" + attributes + ", excludedAttributes=" + excludedAttributes + ", filter=" + filter + ", sortBy=" + sortBy + ", sortOrder=" + sortOrder + ", startIndex=" + startIndex + ", count=" + count + ", maxCount=" + maxCount + ", filterAttributeName=" + filterAttributeName + ", filterAssertionValue=" - + filterAssertionValue + ", fieldValueMap=" + fieldValueMap + ", attributesStr=" + attributesStr - + ", excludedAttributesStr=" + excludedAttributesStr + "]"; + + filterAssertionValue + ", fieldFilterData=" + fieldFilterData + ", attributesStr=" + attributesStr + + ", excludedAttributesStr=" + excludedAttributesStr + + ",fieldValueMap=" + fieldValueMap + + "]"; } - + }