private Set<Integer> getPIIs(List<PIICategoryValidity> piiCategoryValidities) { Set<Integer> piis = new HashSet<>(); for (PIICategoryValidity piiCategoryValidity : piiCategoryValidities) { piis.add(piiCategoryValidity.getId()); } return piis; }
private List<ClaimMetaData> getClaimsFromPIICategoryValidity(List<PIICategoryValidity> piiCategories) { List<ClaimMetaData> claimMetaDataList = new ArrayList<>(); for (PIICategoryValidity piiCategoryValidity : piiCategories) { if (isConsentForClaimValid(piiCategoryValidity)) { ClaimMetaData claimMetaData = new ClaimMetaData(); claimMetaData.setClaimUri(piiCategoryValidity.getName()); claimMetaData.setDisplayName(piiCategoryValidity.getDisplayName()); claimMetaDataList.add(claimMetaData); } } return claimMetaDataList; }
protected boolean isConsentForClaimValid(PIICategoryValidity piiCategoryValidity) { String consentValidity = piiCategoryValidity.getValidity(); if (isDebugEnabled()) { String message = String.format("Validity time for PII category: %s is %s.", piiCategoryValidity.getName(), validTime); logDebug(message); if (isDebugEnabled()) { String message = String.format("Cannot parse timestamp: %s. for PII category %s.", consentValidity, piiCategoryValidity.getName()); logDebug(message);
@Override public void addReceipt(ReceiptInput receiptInput) throws ConsentManagementException { JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate(); try { jdbcTemplate.withTransaction(template -> { revokeActiveReceipts(receiptInput); addReceiptInfo(receiptInput); receiptInput.getServices().forEach(rethrowConsumer(receiptServiceInput -> { int receiptToSPAssocId = addReceiptSPAssociation(receiptInput.getConsentReceiptId(), receiptServiceInput); receiptServiceInput.getPurposes().forEach(rethrowConsumer(receiptPurposeInput -> { int spToPurposeAssocId = addSpToPurposeAssociation(receiptToSPAssocId, receiptPurposeInput); receiptPurposeInput.getPurposeCategoryId().forEach(rethrowConsumer(id -> addSpPurposeToPurposeCategoryAssociation(spToPurposeAssocId, id))); receiptPurposeInput.getPiiCategory().forEach(rethrowConsumer(piiCategoryValidity -> addSpPurposeToPiiCategoryAssociation(spToPurposeAssocId, piiCategoryValidity.getId(), piiCategoryValidity.getValidity()))); })); })); if (receiptInput.getProperties() != null) { addReceiptProperties(receiptInput.getConsentReceiptId(), receiptInput.getProperties()); } return null; }); } catch (TransactionException e) { throw ConsentUtils.handleServerException(ErrorMessages.ERROR_CODE_ADD_CONSENT_RECEIPT, receiptInput.getPiiPrincipalId(), e); } }
private List<PIICategoryValidity> getPIICategoryInfoOfPurpose(int serviceToPurposeId, String consentReceiptId, ReceiptContext receiptContext) throws ConsentManagementServerException { JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate(); try { return jdbcTemplate.withTransaction(template -> template.executeQuery(GET_PII_CAT_SQL, ((resultSet, rowNumber) -> { String name = resultSet.getString(1); boolean isSensitive = resultSet.getInt(2) == 1; String validity = resultSet.getString(3); int id = resultSet.getInt(4); String displayName = resultSet.getString(5); if (isSensitive) { receiptContext.getSecretPIICategory().addSecretCategory(name); } return new PIICategoryValidity(name, validity, id, displayName); }), preparedStatement -> preparedStatement.setInt(1, serviceToPurposeId))); } catch (TransactionException e) { throw ConsentUtils.handleServerException(ErrorMessages.ERROR_CODE_RETRIEVE_RECEIPT_INFO, consentReceiptId, e); } }
protected boolean isConsentForClaimValid(PIICategoryValidity piiCategoryValidity) { String consentValidity = piiCategoryValidity.getValidity(); if (isDebugEnabled()) { String message = String.format("Validity time for PII category: %s is %s.", piiCategoryValidity.getName(), validTime); logDebug(message); if (isDebugEnabled()) { String message = String.format("Cannot parse timestamp: %s. for PII category %s.", consentValidity, piiCategoryValidity.getName()); logDebug(message);
for (int categoryIndex = 0; categoryIndex < piiCategories.length(); categoryIndex++) { JSONObject piiCategory = (JSONObject) piiCategories.get(categoryIndex); PIICategoryValidity piiCategoryValidity = new PIICategoryValidity(piiCategory.getInt("piiCategoryId"), FrameworkConstants.Consent.INFINITE_TERMINATION); piiCategoryValidities.add(piiCategoryValidity);
purposeDTO.setPiiCategory(consentPurpose.getPiiCategory().stream().map(piiCategoryValidity -> { PiiCategoryDTO piiCategoryDTO = new PiiCategoryDTO(); piiCategoryDTO.setPiiCategory(piiCategoryValidity.getName()); piiCategoryDTO.setValidity(piiCategoryValidity.getValidity()); return piiCategoryDTO; }).collect(Collectors.toList()));
private Set<Integer> getPIIs(List<PIICategoryValidity> piiCategoryValidities) { Set<Integer> piis = new HashSet<>(); for (PIICategoryValidity piiCategoryValidity : piiCategoryValidities) { piis.add(piiCategoryValidity.getId()); } return piis; }
for (int categoryIndex = 0; categoryIndex < piiCategories.length(); categoryIndex++) { JSONObject piiCategory = (JSONObject) piiCategories.get(categoryIndex); PIICategoryValidity piiCategoryValidity = new PIICategoryValidity(piiCategory.getInt("piiCategoryId"), FrameworkConstants.Consent.INFINITE_TERMINATION); piiCategoryValidities.add(piiCategoryValidity);
private List<ClaimMetaData> getClaimsFromPIICategoryValidity(List<PIICategoryValidity> piiCategories) { List<ClaimMetaData> claimMetaDataList = new ArrayList<>(); for (PIICategoryValidity piiCategoryValidity : piiCategories) { if (isConsentForClaimValid(piiCategoryValidity)) { ClaimMetaData claimMetaData = new ClaimMetaData(); claimMetaData.setClaimUri(piiCategoryValidity.getName()); claimMetaData.setDisplayName(piiCategoryValidity.getDisplayName()); claimMetaDataList.add(claimMetaData); } } return claimMetaDataList; }
/** * If the consent is not given for a PII * * @param keySet * @param receipt * @return * @throws ConsentUtilityServiceException */ public Set<String> filterPIIsFromReceipt(Set<String> keySet, ReceiptInput receipt) throws ConsentUtilityServiceException { if (keySet == null || receipt == null) { throw new ConsentUtilityServiceException("Key set and receipt should not be null"); } List<ReceiptServiceInput> services = receipt.getServices(); Set<String> consentedPIIs = new HashSet<>(); for (ReceiptServiceInput service : services) { List<ReceiptPurposeInput> purposes = service.getPurposes(); for (ReceiptPurposeInput consentPurpose : purposes) { List<PIICategoryValidity> piiCategories = consentPurpose.getPiiCategory(); for (PIICategoryValidity piiCategory : piiCategories) { consentedPIIs.add(getPIIName(consentPurpose.getPurposeId(), piiCategory.getId())); } } } keySet.retainAll(consentedPIIs); return keySet; }
private List<PIICategoryValidity> getPiiCategoryValiditiesForClaims(List<ClaimMetaData> claims, String termination) throws SSOConsentServiceException { List<PIICategoryValidity> piiCategoryIds = new ArrayList<>(); for (ClaimMetaData claim : claims) { PIICategory piiCategory; try { piiCategory = getConsentManager().getPIICategoryByName(claim.getClaimUri()); } catch (ConsentManagementClientException e) { if (isInvalidPIICategoryError(e)) { piiCategory = addPIICategoryForClaim(claim); } else { throw new SSOConsentServiceException("Consent PII category error", "Error while retrieving" + " PII category: " + DEFAULT_PURPOSE_CATEGORY, e); } } catch (ConsentManagementException e) { throw new SSOConsentServiceException("Consent PII category error", "Error while retrieving " + "PII category: " + DEFAULT_PURPOSE_CATEGORY, e); } piiCategoryIds.add(new PIICategoryValidity(piiCategory.getId(), termination)); } return piiCategoryIds; }
/** * If the consent is not given for a PII * * @param keySet * @param receipt * @return * @throws ConsentUtilityServiceException */ public Set<String> filterPIIsFromReceipt(Set<String> keySet, ReceiptInput receipt) throws ConsentUtilityServiceException { if (keySet == null || receipt == null) { throw new ConsentUtilityServiceException("Key set and receipt should not be null"); } List<ReceiptServiceInput> services = receipt.getServices(); Set<String> consentedPIIs = new HashSet<>(); for (ReceiptServiceInput service : services) { List<ReceiptPurposeInput> purposes = service.getPurposes(); for (ReceiptPurposeInput consentPurpose : purposes) { List<PIICategoryValidity> piiCategories = consentPurpose.getPiiCategory(); for (PIICategoryValidity piiCategory : piiCategories) { consentedPIIs.add(getPIIName(consentPurpose.getPurposeId(), piiCategory.getId())); } } } keySet.retainAll(consentedPIIs); return keySet; }
private List<PIICategoryValidity> getPiiCategoryValiditiesForClaims(List<ClaimMetaData> claims, String termination) throws SSOConsentServiceException { List<PIICategoryValidity> piiCategoryIds = new ArrayList<>(); for (ClaimMetaData claim : claims) { PIICategory piiCategory; try { piiCategory = getConsentManager().getPIICategoryByName(claim.getClaimUri()); } catch (ConsentManagementClientException e) { if (isInvalidPIICategoryError(e)) { piiCategory = addPIICategoryForClaim(claim); } else { throw new SSOConsentServiceException("Consent PII category error", "Error while retrieving" + " PII category: " + DEFAULT_PURPOSE_CATEGORY, e); } } catch (ConsentManagementException e) { throw new SSOConsentServiceException("Consent PII category error", "Error while retrieving " + "PII category: " + DEFAULT_PURPOSE_CATEGORY, e); } piiCategoryIds.add(new PIICategoryValidity(piiCategory.getId(), termination)); } return piiCategoryIds; }
(piiCategoryValidity.getId())));