Compare commits

..

86 Commits

Author SHA1 Message Date
Travis CI User
87eca02048 [maven-release-plugin][skip ci] prepare release 7.199.312 2021-03-15 14:04:46 +00:00
evasques
09392a9837 MNT-22040 Copying nodes that contain sys:pendingFixAcl aspect (#188) (#347)
* MNT-22040 - Copying nodes that contain sys:pendingFixAcl aspect
* Increased coverage of unit tests
* Added public method removePendingAclAspect
* Changed the job to use the removePendingAclAspect method instead of
repeating the same set of operations twice
* Changed method setFixedAcls to use sharedAclToReplace property of node
if it has the pendingFixAcl aspect applied instead of using the current
shared ACL to be replaced

* Added more tests and validations

* Fixed cuncurrency issues when updating parent and child at the same time, permissions triggered by a move on a node with a pending acl and permissions needeing to be reapplied on nodes that already have the pending acl aspect

* Increase the tree strcuture as sometimes we don't reach the timeout in tests

* code cleanup and formatting

(cherry picked from commit 1b2c5d4c37)
2021-03-15 13:36:55 +00:00
Travis CI User
074baf84ab [maven-release-plugin][skip ci] prepare for next development iteration 2021-03-15 12:29:32 +00:00
Travis CI User
7b3e3a1a97 [maven-release-plugin][skip ci] prepare release 7.199.311 2021-03-15 12:29:28 +00:00
evasques
ba1eb7d7fd MNT-22009 - When setting permissions async, nodes with the aspect app… (#111) (#346)
* MNT-22009 - When setting permissions async, nodes with the aspect applied cannot be deleted
* Added unit test that deletes a node with the sys:pendingFixAcl aspect
before the job runs
* Added verification to the job to verify if node is in archive store
and if so, it shall not process that node and remove sys:pendingFixAcl aspect and properties

(cherry picked from commit 6438a2732a)
2021-03-15 12:01:24 +00:00
Travis CI User
ab7670b7b3 [maven-release-plugin][skip ci] prepare for next development iteration 2021-03-15 11:35:20 +00:00
Travis CI User
253929f415 [maven-release-plugin][skip ci] prepare release 7.199.310 2021-03-15 11:35:14 +00:00
evasques
6261c372c6 [MNT-21847] - Aync permissions fail when new nodes are created (#1188) (#345)
Fix:
*Changed method setFixedAcls on class ADMAccessControlListDAO to continue to propagate through children to apply the correct acl not only when the current child acl matches the shared acl to replace but also when the current child acl matches the new shared acl
Unit Test:
*Refactored the unit test FixedAclUpdaterTest to be able to add in a new test without repeating code: separating the operations that set the permissions from the one that triggers the job into separate methods
*As it was if one test failed, leaving aspects to be processed, the test would run indefinitely (it was programmed to keep running the job while there where nodes with the aspect). Added a verification to stop triggering the job if the number of nodes with the pendingFixAcl did not change between executions.
*Also, if one test failed, it would leave nodes with pendingFixAcl aspect in the database, and the other tests that ran after would also fail, not completing the goal of processing all nodes with the aspect. If a test fails, the folder structure it ran is now deleted so no nodes with the aspect from that structure are processed by the other tests.
*Added a test to find the first folder in a tree where permissions where set async that has the pendingFixAcl aspect and that creates a new node in it to verify the issue

(cherry picked from commit 443e5e226430a2760492fb82214ad520e7e1cb75)
2021-03-15 11:08:18 +00:00
Travis CI User
eba5043ffe [maven-release-plugin][skip ci] prepare for next development iteration 2021-03-05 11:13:11 +00:00
Travis CI User
0c02b7e9f2 [maven-release-plugin][skip ci] prepare release 7.199.309 2021-03-05 11:13:06 +00:00
alandavis
85710587f6 ACS-1071 revision not set in version.properties (#335)
(cherry picked from commit 1e5188a4a7)
2021-03-05 10:47:05 +00:00
Travis CI User
e14003a436 [maven-release-plugin][skip ci] prepare for next development iteration 2021-02-19 14:45:55 +00:00
Travis CI User
23ba8f2d41 [maven-release-plugin][skip ci] prepare release 7.199.308 2021-02-19 14:45:49 +00:00
Alexandru-Eusebiu Epure
905e861396 MNT-21671 : Download as zip REST api does not include custom folders (#1090) (#1092) (#302)
Add dictionaryService to CreateDwonloadArchiveAction
   ZipDownloadExporter constructor now required dictionaryService
   ZipDownloadExporter#startNode will include into archive all subclasses of node type cm:folder.
   Add a custom model and create a custom node in DownloadServiceIntegrationTest, this use case will be tested in DownloadServiceIntegrationTest#createDownload()

(cherry picked from commit 3a31ac3634)
(cherry picked from commit 28bebe0e6d)
2021-02-19 15:47:14 +02:00
Travis CI User
4ec2a93535 [maven-release-plugin][skip ci] prepare for next development iteration 2021-02-10 08:22:48 +00:00
Travis CI User
9d1b966ad5 [maven-release-plugin][skip ci] prepare release 7.199.307 2021-02-10 08:22:41 +00:00
Epure Alexandru-Eusebiu
a9210f6086 Empty commit to trigger build 2021-02-10 09:00:11 +02:00
evasques
fafc3e7e1d MNT-22135 Filter policy to only run on admin auth - Unit test (#275) (#282)
Created unit test testIfGroupIsAdminAuthority to check if public method isAdminAuthority correctly validates groups:
* Verify it can identify GROUP_ALFRESCO_ADMINISTRATORS as an admin group
* Verify created groups (non administrators) and users are not considered administrators
* Add a subgroup to the parent group and verify if its still identified as non admin
* Add the group to the administrators group and verify if both group and subgroup are identified correctly as admins
* Add the user to the subgroup and verify if he's an admin
* Create a group with the same name as an admin user, group should not be identified as admin

(cherry picked from commit 592dde531f)
2021-02-09 16:22:21 +00:00
alandavis
376f146e7c Remove Whitesource [skip ci]
(cherry picked from commit 471492c8e0)
2021-01-25 08:54:44 +00:00
Travis CI User
5559ad446e [maven-release-plugin][skip ci] prepare for next development iteration 2020-11-20 09:41:24 +00:00
Travis CI User
ac5396031d [maven-release-plugin][skip ci] prepare release 7.199.306 2020-11-20 09:41:17 +00:00
Alexandru-Eusebiu Epure
0ed32cf65d Merge pull request #170 from Alfresco/fix/MNT-22055_metadata_extraction_fails
MNT-22055 : Metadata extraction fails for certain documents
2020-11-20 10:07:51 +02:00
Epure Alexandru-Eusebiu
578d779183 MNT-22055 : Metadata extraction fails for certain documents when using legacy transformations
(cherry picked from commit 3351862)
2020-11-20 09:41:50 +02:00
Travis CI User
a5821023e2 [maven-release-plugin][skip ci] prepare for next development iteration 2020-11-19 17:13:06 +00:00
Travis CI User
809e943d15 [maven-release-plugin][skip ci] prepare release 7.199.305 2020-11-19 17:12:59 +00:00
tiagosalvado10
70a7334e0d Merge pull request #168 from Alfresco/fix/MNT-22061_FixPrimaryPath_622
MNT-22061: REST api does not update the primary path on new version upload
2020-11-19 16:14:51 +00:00
Epure Alexandru-Eusebiu
98df0752d8 MNT-22055 : Metadata extraction fails for certain documents when using legacy transformations
Bump tika to 1.24.1
   Remove metadata-extractor dependency
   Bump poi to 4.1.2
2020-11-19 17:45:36 +02:00
tiagos
a076f28a4c [MNT-22015] REST api does not update the primary path on new version upload
(cherry picked from commit 73b393a541)
2020-11-18 10:51:56 +00:00
Travis CI User
a2021092df [maven-release-plugin][skip ci] prepare for next development iteration 2020-11-16 20:31:56 +00:00
Travis CI User
93260c0bc8 [maven-release-plugin][skip ci] prepare release 7.199.304 2020-11-16 20:31:48 +00:00
Alexandru-Eusebiu Epure
c205c94caa Merge pull request #156 from Alfresco/fix/MNT-22036_API_always_applies_versioning_622
MNT-22036 : REST API always applies versioning
2020-11-16 21:56:33 +02:00
Epure Alexandru-Eusebiu
5135482fd2 Remove bad assertion of property count. 2020-11-16 21:34:32 +02:00
Alexandru-Eusebiu Epure
ed9aa57849 Merge pull request #149 from Alfresco/fix/MNT-22036_API_always_applies_versioning
MNT-22036 : REST API always applies versioning
  Add property boolean versioningEnabled
  Add versioningEnabled to node creation using multipart/form-data
  Add versioningEnabled to node creation using JSON
  Add unit tests for node creation using JSON.
(cherry picked from commit 09c2c95081)
2020-11-16 18:11:37 +02:00
Travis CI User
7b578827d1 [maven-release-plugin][skip ci] prepare for next development iteration 2020-11-09 11:08:00 +00:00
Travis CI User
11a5731ca7 [maven-release-plugin][skip ci] prepare release 7.199.303 2020-11-09 11:07:53 +00:00
evasques
ce48f64a14 MNT-21800 - CMIS Web Service Check Out returns error (#137)
* Fix/MNT-21800 CMIS Web Service Check Out returns error (#1232)

* MNT-21800 : CMIS Web Service Check Out returns error
   Integrate path into codebase.

(cherry picked from commit 51a7793668ba1c969c5de37603190244e3839cd0)

Co-authored-by: Alexandru-Eusebiu Epure <alexeusebiu@gmail.com>
2020-11-09 10:41:06 +00:00
Travis CI User
4a9a7ba4de [maven-release-plugin][skip ci] prepare for next development iteration 2020-11-06 17:25:29 +00:00
Travis CI User
0dc7d62d3f [maven-release-plugin][skip ci] prepare release 7.199.302 2020-11-06 17:25:22 +00:00
evasques
7f54671ca2 MNT-21967 - ClassCastException when using CMIS query with SCORE() function (#136)
* MNT-21967 - ClassCastException when using CMIS query with SCORE() function (#128)

* Added missing validation before if columnName is the expected column
before normalizing value to float, in case the column is Score

(cherry picked from commit acac23f29a)
2020-11-06 16:22:05 +00:00
Alan Davis
84e2ff5f1f Should be using TRAVIS_ACCESS_TOKEN rather than TRAVIS_ACCESS_TOKEN_TEMP [skip ci] 2020-10-14 08:31:28 +01:00
Travis CI User
75fbb557fe [maven-release-plugin][skip ci] prepare for next development iteration 2020-10-13 17:02:09 +00:00
Travis CI User
d40fb4f988 [maven-release-plugin][skip ci] prepare release 7.199.301 2020-10-13 17:02:01 +00:00
Alan Davis
f50a76d20d Should be using TRAVIS_ACCESS_TOKEN rather than TRAVIS_ACCESS_TOKEN_TEMP to trigger downstream project builds 2020-10-13 17:33:20 +01:00
Travis CI User
c170ed725a [maven-release-plugin][skip ci] prepare for next development iteration 2020-10-11 08:59:51 +00:00
Travis CI User
62ccbe9da2 [maven-release-plugin][skip ci] prepare release 7.199.300 2020-10-11 08:59:45 +00:00
Alan Davis
310689994d Switch to alfresco-community-repo project 2020-10-11 09:28:54 +01:00
Travis CI User
62a506da47 [maven-release-plugin][skip ci] prepare for next development iteration 2020-10-09 09:27:29 +00:00
Travis CI User
399a29eef2 [maven-release-plugin][skip ci] prepare release 7.199.300-TEST5 2020-10-09 09:27:21 +00:00
Alan Davis
4167f6810e Add back in missing keystore scripts 2020-10-09 08:05:37 +01:00
Travis CI User
01fe638d60 [maven-release-plugin][skip ci] prepare for next development iteration 2020-10-08 12:09:16 +00:00
Travis CI User
3ad2db96ab [maven-release-plugin][skip ci] prepare release 7.199.300-TEST4 2020-10-08 12:09:09 +00:00
Alan Davis
1c9366dcaf Only copy win64 and linux pdf-renderer to dist zip
Sort out what get included in dist jar and zip

(cherry picked from commit 779f8af717)

Remove READMEs that have been moved to the top level.

(cherry picked from commit 9826fd6bb0)
2020-10-08 12:27:35 +01:00
Travis CI User
9c1daf0795 [maven-release-plugin][skip ci] prepare for next development iteration 2020-10-04 19:16:34 +00:00
Travis CI User
fb7a6a8a1f [maven-release-plugin][skip ci] prepare release 7.199.300-TEST3 2020-10-04 19:16:28 +00:00
Alan Davis
4307444e2d Merge commits for 6.2.2.3 changes to release/6.2.2
* [MNT-21766]: Significant degradation of performance as file and site count increase (#1217)
- Added the following indexes on alf_transaction:
idx_alf_txn_ctms_sc, cols (commit_time_ms)
idx_alf_txn_id_ctms, cols (id, commit_time_ms)
- Added the following indexes on alf_node:
idx_alf_node_ver, cols (version)
idx_alf_node_txn, cols (transaction_id)
- Created patch patch.db-V6.3-add-indexes-node-transaction
- Updated version.schema to 14002
- Added system property system.new-node-transaction-indexes.ignored, set
as true by default to not apply the patch automatically
- Created the MySQL update dbscripts to add the new indexes - and also
drop and recreate the pre-existing index idx_alf_txn_ctms on alf_transaction that was
inconsistent with the other DBMS: was indexing only commit_time_ms when
on all other DBMS index idx_alf_txn_ctms was on (commit_time_ms, id)
- Created the Postgres update dbscripts to add the new indexes

(cherry picked from commit d70746f63a6e6a2154d2e37c577955a17c42256e)

* Change schema upgrade from to 13005..13006 on patch apply

* Fixed merge from cherry pick, missing colon

(cherry picked from commit 73f94fc5ca0d2ea322d12a59cf3ae980ef94bf1c)
2020-10-04 19:50:40 +01:00
Travis CI User
89ae5bc193 [maven-release-plugin][skip ci] prepare for next development iteration 2020-10-02 10:38:02 +00:00
Travis CI User
fe537e97d5 [maven-release-plugin][skip ci] prepare release 7.199.300-TEST2 2020-10-02 10:37:55 +00:00
Alan Davis
c7b29613d4 REPO-5358 Deployment modules should extend each other
The alfresco-community-repo's deployment module now provides the basis for alfresco-enterprise-repo and acs-packaging
deployment modules. This makes it like the other branches and avoids duplication of licenses between projects.

(partial picked from commit c4d1f5824d)
2020-10-02 11:06:47 +01:00
Cezar.Leahu
4d1f6ae91e REPO-5111 Update build scripts [skip ci] 2020-09-30 22:30:52 +03:00
Travis CI User
1f2d85e252 [maven-release-plugin][skip ci] prepare for next development iteration 2020-09-27 10:25:31 +00:00
Travis CI User
efa330adf5 [maven-release-plugin][skip ci] prepare release 7.199.300-TEST1 2020-09-27 10:25:24 +00:00
Alan Davis
abde3fa4cb REPO-5271 Backport new structure to relaese/6.2.2 (#21)
- Simplify dependencies and standardise order
- README updated
- Green builds
- Changes to make Jars in enterprise war match
- Changes to make files in enterprise image match
- Added travis_wait 40 to the initial build as it can take 20 minutes to download artifacts
- Removed NodesTest.siteConsumerWillGet403OnFileWithDisabledInherittedPermissions introduced in 7.0.0 and fails in earlier versions.
- GetSiteMember[s]Tests changed in 7.0.0. Setting test back to previous values.
2020-09-27 10:53:02 +01:00
Cezar.Leahu
1d6a775f22 ACS-550 Add .gitignore
(cherry picked from commit 36ccfe2bea)
2020-09-03 11:24:33 +03:00
Iulian Aftene
6596825462 Merge pull request #12 from Alfresco/feature/REPO-5318_622
REPO-5318-Create l10n.properties release 6.2.2
2020-08-21 11:43:30 +03:00
aftene
30a9c0c065 REPO-5318-Create l10n.properties
- delete l10n.properties files from data-model, remote-api and repository
 - add new global l10n.properties file
2020-08-19 19:40:13 +03:00
Chris Shields
1399b363cc Merge remote-tracking branch 'acs-community-packaging/develop' into release/6.2.2 2020-07-21 10:45:00 +01:00
Chris Shields
6416432f42 Merge remote-tracking branch 'alfresco-remote-api/support/HF/7.147.N' into release/6.2.2 2020-07-21 10:44:59 +01:00
Chris Shields
1c7c87caee Merge remote-tracking branch 'alfresco-repository/support/HF/7.199.N' into release/6.2.2 2020-07-21 10:44:57 +01:00
Chris Shields
42de0e1607 Merge remote-tracking branch 'alfresco-data-model/support/HF/8.50.18.N' into release/6.2.2 2020-07-21 10:44:57 +01:00
Chris Shields
9da76f53e0 Merge remote-tracking branch 'alfresco-core/support/HF/7.34.N' into release/6.2.2 2020-07-21 10:44:57 +01:00
Chris Shields
c70fdd47a7 Moved remote-api support/HF/7.147.N into its own directory 2020-07-21 10:44:14 +01:00
Chris Shields
d96e726db4 Moved repository support/HF/7.199.N into its own directory 2020-07-21 10:43:42 +01:00
Chris Shields
fc66677977 Moved data-model support/HF/8.50.18.N into its own directory 2020-07-21 10:43:27 +01:00
Chris Shields
2a9f61076c Moved core support/HF/7.34.N into its own directory 2020-07-21 10:43:19 +01:00
Travis CI User
12c66a09d1 [maven-release-plugin][skip ci] prepare for next development iteration 2020-06-26 18:57:20 +00:00
Travis CI User
5882e3d002 [maven-release-plugin][skip ci] prepare release alfresco-remote-api-7.147.0 2020-06-26 18:57:13 +00:00
Ancuta Morarasu
c15bace290 ACS-248: [6.2.2] HF branch - version 7.147.0-SNAPSHOT 2020-06-26 21:39:06 +03:00
Travis CI User
40eb3f1649 [maven-release-plugin][skip ci] prepare for next development iteration 2020-06-26 18:30:40 +00:00
Travis CI User
edd5c3ac7b [maven-release-plugin][skip ci] prepare release alfresco-repository-7.199.0 2020-06-26 18:30:32 +00:00
Ancuta Morarasu
71eb5f3011 ACS-248: [6.2.2] HF branch - version 7.199.0-SNAPSHOT 2020-06-26 21:07:51 +03:00
Travis CI User
1bf2cf015c [maven-release-plugin][skip ci] prepare for next development iteration 2020-06-26 17:51:56 +00:00
Travis CI User
cd97fb3c3a [maven-release-plugin][skip ci] prepare release 8.50.18.0 2020-06-26 17:51:50 +00:00
Ancuta Morarasu
fc729dd26f ACS-248: [6.2.2] HF branch - version 8.50.18.0-SNAPSHOT 2020-06-26 20:43:59 +03:00
Travis CI User
8c21deee57 [maven-release-plugin][skip ci] prepare for next development iteration 2020-06-26 17:36:12 +00:00
Travis CI User
0cf79474a1 [maven-release-plugin][skip ci] prepare release 7.34.0 2020-06-26 17:36:06 +00:00
Ancuta Morarasu
5a840b7ecf ACS-248: [6.2.2] HF branch - version 7.34.0-SNAPSHOT 2020-06-26 20:32:04 +03:00
68 changed files with 2258 additions and 1504 deletions

View File

@@ -42,15 +42,6 @@ install: travis_retry travis_wait 40 bash scripts/travis/build.sh
jobs:
include:
- name: "WhiteSource scan"
stage: test
# only on release branches or master and if it is not a PR
if: fork = false AND (branch = master OR branch =~ /release\/.*/) AND type != pull_request
script:
# Download the latest version of WhiteSource Unified Agent
- curl -LJO https://github.com/whitesource/unified-agent-distribution/releases/latest/download/wss-unified-agent.jar
# Run WhiteSource Unified Agent
- java -jar wss-unified-agent.jar -apiKey ${WHITESOURCE_API_KEY} -c .wss-unified-agent.config -d ./packaging/war
# - name: "Source Clear Scan"
# # only on release branches or master and if it is not a PR

View File

@@ -1,8 +0,0 @@
{
"generalSettings": {
"shouldScanRepo": true
},
"checkRunSettings": {
"vulnerableCheckRunConclusionLevel": "failure"
}
}

View File

@@ -1,228 +0,0 @@
####################################################################
# WhiteSource Unified-Agent configuration file
####################################################################
##########################################
# GENERAL SCAN MODE: Files and Package Managers
##########################################
checkPolicies=true
forceCheckAllDependencies=true
forceUpdate=true
forceUpdate.failBuildOnPolicyViolation=true
offline=false
#ignoreSourceFiles=true
#scanComment=
#updateInventory=false
#resolveAllDependencies=false
#failErrorLevel=ALL
#requireKnownSha1=false
#generateScanReport=true
#scanReportTimeoutMinutes=10
#excludeDependenciesFromNodes=.*commons-io.*,.*maven-model
#projectPerFolder=true
#projectPerFolderIncludes=
#projectPerFolderExcludes=
#wss.connectionTimeoutMinutes=60
# Change the below URL to your WhiteSource server.
# Use the 'WhiteSource Server URL' which can be retrieved
# from your 'Profile' page on the 'Server URLs' panel.
# Then, add the '/agent' path to it.
wss.url=https://saas.whitesourcesoftware.com/agent
#npm.resolveDependencies=false
#npm.ignoreSourceFiles=false
#npm.includeDevDependencies=true
#npm.runPreStep=true
#npm.ignoreNpmLsErrors=true
#npm.ignoreScripts=true
#npm.yarnProject=true
#npm.accessToken=
#npm.identifyByNameAndVersion=true
#bower.resolveDependencies=false
#bower.ignoreSourceFiles=true
#bower.runPreStep=true
#nuget.resolvePackagesConfigFiles=false
#nuget.resolveCsProjFiles=false
#nuget.resolveDependencies=false
#nuget.restoreDependencies=true
#nuget.ignoreSourceFiles=true
#nuget.runPreStep=true
#nuget.resolveNuspecFiles=false
#python.resolveDependencies=false
#python.ignoreSourceFiles=false
#python.ignorePipInstallErrors=true
#python.installVirtualenv=true
#python.resolveHierarchyTree=false
#python.requirementsFileIncludes=requirements.txt
#python.resolveSetupPyFiles=true
#python.runPipenvPreStep=true
#python.pipenvDevDependencies=true
#python.IgnorePipenvInstallErrors=true
#maven.ignoredScopes=test provided
maven.resolveDependencies=true
#maven.ignoreSourceFiles=true
#maven.aggregateModules=true
maven.ignorePomModules=false
#maven.runPreStep=true
#maven.ignoreMvnTreeErrors=true
#maven.environmentPath=
#maven.m2RepositoryPath=
#gradle.ignoredScopes=
#gradle.resolveDependencies=false
#gradle.runAssembleCommand=false
#gradle.runPreStep=true
#gradle.ignoreSourceFiles=true
#gradle.aggregateModules=true
#gradle.preferredEnvironment=wrapper
#gradle.localRepositoryPath=
#paket.resolveDependencies=false
#paket.ignoredGroups=
#paket.ignoreSourceFiles=false
#paket.runPreStep=true
#paket.exePath=
#go.resolveDependencies=false
#go.collectDependenciesAtRuntime=true
#go.dependencyManager=
#go.ignoreSourceFiles=true
#go.glide.ignoreTestPackages=false
#go.gogradle.enableTaskAlias=true
#ruby.resolveDependencies = false
#ruby.ignoreSourceFiles = false
#ruby.installMissingGems = true
#ruby.runBundleInstall = true
#ruby.overwriteGemFile = true
#sbt.resolveDependencies=false
#sbt.ignoreSourceFiles=true
#sbt.aggregateModules=true
#sbt.runPreStep=true
#sbt.targetFolder=
#php.resolveDependencies=false
#php.runPreStep=true
#php.includeDevDependencies=true
#html.resolveDependencies=false
#cocoapods.resolveDependencies=false
#cocoapods.runPreStep=true
#cocoapods.ignoreSourceFiles=false
#hex.resolveDependencies=false
#hex.runPreStep=true
#hex.ignoreSourceFiles=false
#hex.aggregateModules=true
##################################
# Organization tokens:
##################################
apiKey=
#userKey is required if WhiteSource administrator has enabled "Enforce user level access" option
#userKey=
projectName=alfresco-repository
projectVersion=7.N
projectToken=
productName=ACS Community
productVersion=
productToken=
#updateType=APPEND
#requesterEmail=user@provider.com
#########################################################################################
# Includes/Excludes Glob patterns - PLEASE USE ONLY ONE EXCLUDE LINE AND ONE INCLUDE LINE
#########################################################################################
#includes=**/*.c **/*.cc **/*.cp **/*.cpp **/*.cxx **/*.c++ **/*.h **/*.hpp **/*.hxx
#includes=**/*.m **/*.mm **/*.js **/*.php
includes=**/*.jar
#includes=**/*.gem **/*.rb
#includes=**/*.dll **/*.cs **/*.nupkg
#includes=**/*.tgz **/*.deb **/*.gzip **/*.rpm **/*.tar.bz2
#includes=**/*.zip **/*.tar.gz **/*.egg **/*.whl **/*.py
## Exclude file extensions or specific directories by adding **/*.<extension> or **<excluded_dir>/**
excludes=**/*sources.jar **/*javadoc.jar
case.sensitive.glob=false
followSymbolicLinks=true
##################################
# Archive properties
##################################
#archiveExtractionDepth=2
#archiveIncludes=**/*.war **/*.ear
#archiveExcludes=**/*sources.jar
##################################
# Proxy settings
##################################
#proxy.host=
#proxy.port=
#proxy.user=
#proxy.pass=
##################################
# SCM settings
##################################
#scm.type=
#scm.user=
#scm.pass=
#scm.ppk=
#scm.url=
#scm.branch=
#scm.tag=
#scm.npmInstall=
#scm.npmInstallTimeoutMinutes=
#scm.repositoriesFile=
##############################################
# SCAN MODE: Linux package manager settings
##############################################
#scanPackageManager=true
##################################
# SCAN MODE: Docker images
##################################
#docker.scanImages=true
#docker.includes=.*.*
#docker.excludes=
#docker.pull.enable=true
#docker.pull.images=.*.*
#docker.pull.maxImages=10
#docker.pull.tags=.*.*
#docker.pull.digest=
#docker.delete.force=true
#docker.login.sudo=false
#docker.aws.enable=true
#docker.aws.registryIds=
##################################
# SCAN MODE: Docker containers
##################################
#docker.scanContainers=true
#docker.containerIncludes=.*.*
#docker.containerExcludes=
################################
# Serverless settings
################################
#serverless.provider=
#serverless.scanFunctions=true
#serverless.includes=
#serverless.excludes=
#serverless.region=
#serverless.maxFunctions=10

View File

@@ -1,42 +0,0 @@
### Alfresco Core
[![Build Status](https://travis-ci.com/Alfresco/alfresco-core.svg?branch=master)](https://travis-ci.com/Alfresco/alfresco-core)
Alfresco Core is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
The library contains the following:
* Various helpers and utils
* Canned queries interface and supporting classes
* Generic encryption supporting classes
Version 7 of the library uses Spring 5, Quartz 2.3 and does not have Hibernate dependency.
### Building and testing
The project can be built and tested by running Maven command:
~~~
mvn clean install
~~~
### Artifacts
The artifacts can be obtained by:
* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/content/groups/public)
* getting as Maven dependency by adding the dependency to your pom file:
~~~
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-core</artifactId>
<version>version</version>
</dependency>
~~~
and Alfresco repository:
~~~
<repository>
<id>alfresco-maven-repo</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository>
~~~
The SNAPSHOT version of the artifact is **never** published.
### Old version history
The history for older versions can be found in [Alfresco SVN](https://svn.alfresco.com/repos/alfresco-open-mirror/services/alfresco-core/)
### Contributing guide
Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.

View File

@@ -1,5 +1,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-core</artifactId>
<name>Alfresco Core</name>
<description>Alfresco core libraries and utils</description>
@@ -7,13 +8,14 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
@@ -22,10 +24,12 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@@ -50,6 +54,7 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${dependency.spring.version}</version>
<!-- exclude spring-jcl which is brought in by spring-core -->
<!-- see https://issues.alfresco.com/jira/browse/REPO-4774 -->
<exclusions>
@@ -62,10 +67,12 @@
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${dependency.spring.version}</version>
</dependency>
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<version>2.3.2</version>
<!-- exclude c3p0 -->
<!-- see https://issues.alfresco.com/jira/browse/REPO-3447 -->
<exclusions>
@@ -87,6 +94,7 @@
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.2</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
@@ -106,6 +114,7 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.5</version>
</dependency>
<!-- provided dependencies -->
@@ -125,6 +134,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -322,7 +322,7 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
try
{
keyInfoManager = getKeyInfoManager(getKeyStoreParameters());
keyInfoManager = getKeyInfoManager(getKeyMetaDataFileLocation());
KeyStore ks = loadKeyStore(keyStoreParameters, keyInfoManager);
logger.debug("Initializing key managers");
@@ -355,7 +355,7 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
try
{
keyInfoManager = getKeyInfoManager(getKeyStoreParameters());
keyInfoManager = getKeyInfoManager(getKeyMetaDataFileLocation());
KeyStore ks = loadKeyStore(getKeyStoreParameters(), keyInfoManager);
logger.debug("Initializing trust managers");
@@ -376,7 +376,12 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
}
}
}
protected String getKeyMetaDataFileLocation()
{
return keyStoreParameters.getKeyMetaDataFileLocation();
}
protected InputStream getKeyStoreStream(String location) throws FileNotFoundException
{
if(location == null)
@@ -391,17 +396,9 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
return new FileOutputStream(getKeyStoreParameters().getLocation());
}
protected KeyInfoManager getKeyInfoManager(KeyStoreParameters keyStoreParameters) throws IOException
protected KeyInfoManager getKeyInfoManager(String metadataFileLocation) throws FileNotFoundException, IOException
{
return new KeyInfoManager(keyStoreParameters, keyResourceLoader);
}
@Deprecated
protected KeyInfoManager getKeyInfoManager(String metadataFileLocation) throws IOException
{
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setKeyMetaDataFileLocation(metadataFileLocation);
return new KeyInfoManager(keyStoreParameters, keyResourceLoader);
return new KeyInfoManager(metadataFileLocation, keyResourceLoader);
}
protected KeyMap cacheKeys(KeyStore ks, KeyInfoManager keyInfoManager)
@@ -566,7 +563,7 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
try
{
keyInfoManager = getKeyInfoManager(keyStoreParameters);
keyInfoManager = getKeyInfoManager(keyStoreParameters.getKeyMetaDataFileLocation());
ks = loadKeyStore(keyStoreParameters, keyInfoManager);
// Loaded
}
@@ -638,7 +635,7 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
try
{
keyInfoManager = getKeyInfoManager(getKeyStoreParameters());
keyInfoManager = getKeyInfoManager(getKeyMetaDataFileLocation());
Key key = getSecretKey(keyInfoManager.getKeyInformation(keyAlias));
encryptionKeysRegistry.registerKey(keyAlias, key);
keys.setKey(keyAlias, key);
@@ -681,7 +678,7 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
{
if(!keyStoreExists(keyStoreParameters.getLocation()))
{
keyInfoManager = getKeyInfoManager(keyStoreParameters);
keyInfoManager = getKeyInfoManager(keyStoreParameters.getKeyMetaDataFileLocation());
KeyStore ks = initialiseKeyStore(keyStoreParameters.getType(), keyStoreParameters.getProvider());
String keyStorePassword = keyInfoManager.getKeyStorePassword();
@@ -689,7 +686,7 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
{
throw new AlfrescoRuntimeException("Key store password is null for keystore at location "
+ getKeyStoreParameters().getLocation()
+ ". Either specify it as a JVM property or in key store meta data location.");
+ ", key store meta data location" + getKeyMetaDataFileLocation());
}
for(String keyAlias : keys.getKeyAliases())
@@ -768,13 +765,8 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
}
}
protected Key getSecretKey(KeyInformation keyInformation) throws AlfrescoRuntimeException, NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException
protected Key getSecretKey(KeyInformation keyInformation) throws NoSuchAlgorithmException, InvalidKeyException, InvalidKeySpecException
{
if (keyInformation == null)
{
throw new AlfrescoRuntimeException("Unable to get secret key: no key information is provided");
}
byte[] keyData = keyInformation.getKeyData();
if(keyData == null)
@@ -804,7 +796,7 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
writeLock.lock();
try
{
keyInfoManager = getKeyInfoManager(getKeyStoreParameters());
keyInfoManager = getKeyInfoManager(getKeyMetaDataFileLocation());
KeyStore ks = loadKeyStore(getKeyStoreParameters(), keyInfoManager);
// loading Key
@@ -993,7 +985,7 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
public static class KeyInfoManager
{
private KeyResourceLoader keyResourceLoader;
private KeyStoreParameters keyStoreParameters;
private String metadataFileLocation;
private Properties keyProps;
private String keyStorePassword = null;
private Map<String, KeyInformation> keyInfo;
@@ -1013,10 +1005,10 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
}
}
KeyInfoManager(KeyStoreParameters keyStoreParameters, KeyResourceLoader keyResourceLoader) throws IOException, FileNotFoundException
KeyInfoManager(String metadataFileLocation, KeyResourceLoader keyResourceLoader) throws IOException, FileNotFoundException
{
this.keyResourceLoader = keyResourceLoader;
this.keyStoreParameters = keyStoreParameters;
this.metadataFileLocation = metadataFileLocation;
keyInfo = new HashMap<String, KeyInformation>(2);
loadKeyMetaData();
}
@@ -1033,73 +1025,31 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
* Where required, <tt>null</tt> values must be inserted into the map to indicate the presence
* of a key that is not protected by a password. They entry for {@link #KEY_KEYSTORE_PASSWORD}
* is required if the keystore is password protected.
*
* WARNING. Storing passwords (keyMetaDataFileLocation) on the file system is not following best security practices.
*
* <p/>Loading of keys info from system (JVM) properties takes precedence over metadata file.
* <p/>Set the unique ID of the keystore and remove the metadata file location property to use JVM properties lookup instead. The property lookup format is the following:
* <ul>
* <li>[keystore-id].password - keystore password</li>
* <li>[keystore-id].aliases - comma separated list of aliases for the keys in the keystore</li>
* <li>[keystore-id].[alias].keyData - key data bytes in base64</li>
* <li>[keystore-id].[alias].algorithm - key algorithm</li>
* <li>[keystore-id].[alias].password - key password</li>
* </ul>
*
*/
protected void loadKeyMetaData() throws IOException, FileNotFoundException
{
if (keyStoreParameters.getId() != null &&
(keyStoreParameters.getKeyMetaDataFileLocation() == null ||
keyStoreParameters.getKeyMetaDataFileLocation().isEmpty()))
keyProps = keyResourceLoader.loadKeyMetaData(metadataFileLocation);
if(keyProps != null)
{
Properties jvmProperties = System.getProperties();
keyStorePassword = jvmProperties.getProperty(keyStoreParameters.getId() + ".password");
String aliases = jvmProperties.getProperty(keyStoreParameters.getId() + ".aliases");
if (aliases == null || aliases.isEmpty())
String aliases = keyProps.getProperty("aliases");
if(aliases == null)
{
logger.warn("No aliases were specified for " + keyStoreParameters.getId()
+ " keystore");
throw new AlfrescoRuntimeException("Passwords file must contain an aliases key");
}
else
this.keyStorePassword = keyProps.getProperty(KEY_KEYSTORE_PASSWORD);
StringTokenizer st = new StringTokenizer(aliases, ",");
while(st.hasMoreTokens())
{
StringTokenizer st = new StringTokenizer(aliases, ",");
while(st.hasMoreTokens())
{
String keyAlias = st.nextToken();
keyInfo.put(keyAlias, loadKeyInformation(jvmProperties, keyAlias, keyStoreParameters.getId() + "."));
}
String keyAlias = st.nextToken();
keyInfo.put(keyAlias, loadKeyInformation(keyAlias));
}
}
else
{
logger.warn("Storing passwords (" + keyStoreParameters.getKeyMetaDataFileLocation()
+ ") on the file system is not following best security practices." +
" Please refer to documentation and use JVM properties instead");
keyProps = keyResourceLoader.loadKeyMetaData(keyStoreParameters.getKeyMetaDataFileLocation());
if(keyProps != null)
{
String aliases = keyProps.getProperty("aliases");
if(aliases == null)
{
throw new AlfrescoRuntimeException("Passwords file must contain an aliases key");
}
this.keyStorePassword = keyProps.getProperty(KEY_KEYSTORE_PASSWORD);
StringTokenizer st = new StringTokenizer(aliases, ",");
while(st.hasMoreTokens())
{
String keyAlias = st.nextToken();
keyInfo.put(keyAlias, loadKeyInformation(keyProps, keyAlias, ""));
}
}
else
{
// TODO
//throw new FileNotFoundException("Cannot find key metadata file " + getKeyMetaDataFileLocation());
}
// TODO
//throw new FileNotFoundException("Cannot find key metadata file " + getKeyMetaDataFileLocation());
}
}
@@ -1117,11 +1067,11 @@ public class AlfrescoKeyStoreImpl implements AlfrescoKeyStore
this.keyProps.remove(keyAlias);
}
protected KeyInformation loadKeyInformation(Properties keyProps, String keyAlias, String prefix)
protected KeyInformation loadKeyInformation(String keyAlias)
{
String keyPassword = keyProps.getProperty(prefix + keyAlias + ".password");
String keyData = keyProps.getProperty(prefix + keyAlias + ".keyData");
String keyAlgorithm = keyProps.getProperty(prefix + keyAlias + ".algorithm");
String keyPassword = keyProps.getProperty(keyAlias + ".password");
String keyData = keyProps.getProperty(keyAlias + ".keyData");
String keyAlgorithm = keyProps.getProperty(keyAlias + ".algorithm");
byte[] keyDataBytes = null;
if(keyData != null && !keyData.equals(""))

View File

@@ -22,15 +22,12 @@ import org.alfresco.util.PropertyCheck;
/**
* Stores Java keystore initialisation parameters.
*
* WARNING. Storing passwords (keyMetaDataFileLocation) on the file system is not following best security practices.
*
*
* @since 4.0
*
*/
public class KeyStoreParameters
{
private String id;
private String name;
private String type;
private String provider;
@@ -41,40 +38,8 @@ public class KeyStoreParameters
{
}
/**
* WARNING. Storing passwords (keyMetaDataFileLocation) on the file system is not following best security practices.
*
* <p/>Set the unique ID of the keystore and aliases to use Java system properties lookup instead. The property lookup format is:
* <ul>
* <li>[keystore-id].password - keystore password</li>
* <li>[keystore-id].aliases - comma separated list of aliases for the keys in the keystore</li>
* <li>[keystore-id].[alias].keydata - key data bytes in base64</li>
* <li>[keystore-id].[alias].algorithm - key algorithm</li>
* <li>[keystore-id].[alias].password - key password</li>
* </ul>
*
* Loading of keys info from system (JVM) properties takes precedence over metadata file.
*
* @param id unique identifier of the keystore
* @param name human readable name of the keystore
* @param type type of the keystore
* @param keyStoreProvider keystore provider
* @param keyMetaDataFileLocation path to keystore metadata file on the file system
* @param location path to keystore on the file system
*/
public KeyStoreParameters(String id, String name, String type, String keyStoreProvider,
String keyMetaDataFileLocation, String location)
{
this(name, type, keyStoreProvider, keyMetaDataFileLocation, location);
this.id = id;
}
/**
* Use {@link #KeyStoreParameters(String, String, String, String, String, String)} instead
*/
@Deprecated()
public KeyStoreParameters(String name, String type, String keyStoreProvider,
String keyMetaDataFileLocation, String location)
String keyMetaDataFileLocation, String location)
{
super();
this.name = name;
@@ -84,13 +49,8 @@ public class KeyStoreParameters
this.location = location;
}
public void init()
{
if (!PropertyCheck.isValidPropertyString(getId()))
{
setId(null);
}
if (!PropertyCheck.isValidPropertyString(getLocation()))
{
setLocation(null);
@@ -109,11 +69,6 @@ public class KeyStoreParameters
}
}
public String getId()
{
return id;
}
public String getName()
{
return name;
@@ -138,12 +93,7 @@ public class KeyStoreParameters
{
return location;
}
public void setId(String id)
{
this.id = id;
}
public void setName(String name)
{
this.name = name;

View File

@@ -1,388 +0,0 @@
/*
* Copyright (C) 2005-2020 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.encryption;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.alfresco.error.AlfrescoRuntimeException;
import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class AlfrescoKeyStoreTest
{
@Mock
private EncryptionKeysRegistry encryptionKeysRegistry;
@Rule
public TestName testName = new TestName();
@Test
public void testSysPropConfig()
{
String keyStoreId = testName.getMethodName() + "-keystore";
String alias1 = "mykey1";
String alias2 = "mykey2";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setId(keyStoreId);
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-2.jks");
System.setProperty(keyStoreId + "." + "password", "ksPwd2");
System.setProperty(keyStoreId + "." + "aliases", alias1 + "," + alias2);
System.setProperty(keyStoreId + "." + alias1 + "." + "password", "aliasPwd1");
System.setProperty(keyStoreId + "." + alias2 + "." + "password", "aliasPwd2");
try
{
AlfrescoKeyStore alfrescoKeyStore = new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
Set<String> expectedAliases = new HashSet<>();
expectedAliases.add(alias1);
expectedAliases.add(alias2);
Assert.assertEquals("The aliases are not correct", expectedAliases, alfrescoKeyStore.getKeyAliases());
Assert.assertNotNull("Failed to retrieve a key from keystore.", alfrescoKeyStore.getKey(alias1));
Assert.assertNotNull("Failed to retrieve a key from keystore.", alfrescoKeyStore.getKey(alias2));
}
finally
{
System.clearProperty(keyStoreId + "." + "password");
System.clearProperty(keyStoreId + "." + "aliases");
System.clearProperty(keyStoreId + "." + alias1 + "." + "password");
System.clearProperty(keyStoreId + "." + alias2 + "." + "password");
}
}
@Test
public void testSysPropConfigWithoutAliases()
{
String keyStoreId = testName.getMethodName() + "-keystore";
String alias1 = "mykey1";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setId(keyStoreId);
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
System.setProperty(keyStoreId + "." + "password", "ksPwd1");
System.setProperty(keyStoreId + "." + alias1 + "." + "password", "aliasPwd1");
try
{
AlfrescoKeyStore keyStore = new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
Assert.assertNull(keyStore.getKey(alias1));
}
finally
{
System.clearProperty(keyStoreId + "." + "password");
System.clearProperty(keyStoreId + "." + alias1 + "." + "password");
}
}
@Test
public void testMetaDataFileConfig()
{
String alias1 = "mykey1";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
keyStoreParameters.setKeyMetaDataFileLocation("classpath:keystore-tests/ks1-metadata.properties");
AlfrescoKeyStore alfrescoKeyStore = new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
Set<String> expectedAliases = new HashSet<>();
expectedAliases.add(alias1);
Assert.assertEquals("The aliases are not correct", expectedAliases, alfrescoKeyStore.getKeyAliases());
Assert.assertNotNull("Failed to retrieve a key from keystore.", alfrescoKeyStore.getKey(alias1));
}
/**
* Config via System props should be default, but if the metadata file location is set, it will be used instead.
* This is done to maintain backwards compatibility and simplify testing use cases.
*/
@Test(expected = AlfrescoRuntimeException.class)
public void testConfigBothSystemAndFile()
{
String keyStoreId = testName.getMethodName() + "-keystore";
String alias1 = "mykey1";
String alias2 = "mykey2";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setId(keyStoreId);
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-2.jks");
// use metadata file from keystore with one key
keyStoreParameters.setKeyMetaDataFileLocation("classpath:keystore-tests/ks1-metadata.properties");
System.setProperty(keyStoreId + "." + "password", "ksPwd2");
System.setProperty(keyStoreId + "." + "aliases", alias1 + "," + alias2);
System.setProperty(keyStoreId + "." + alias1 + "." + "password", "aliasPwd1");
System.setProperty(keyStoreId + "." + alias2 + "." + "password", "aliasPwd2");
try
{
new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
}
finally
{
System.clearProperty(keyStoreId + "." + "password");
System.clearProperty(keyStoreId + "." + "aliases");
System.clearProperty(keyStoreId + "." + alias1 + "." + "password");
System.clearProperty(keyStoreId + "." + alias2 + "." + "password");
}
}
@Test(expected = AlfrescoRuntimeException.class)
public void testValidateKeysWrongAliasMetadataFile() throws Exception
{
String alias1 = "mykey1";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
keyStoreParameters.setKeyMetaDataFileLocation("classpath:keystore-tests/wrong-alias-metadata.properties");
AlfrescoKeyStoreImpl alfrescoKeyStore = new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
alfrescoKeyStore.setKeysToValidate(Collections.singleton(alias1));
alfrescoKeyStore.setValidateKeyChanges(true);
alfrescoKeyStore.setEncryptionKeysRegistry(encryptionKeysRegistry);
alfrescoKeyStore.validateKeys();
}
@Test
public void testEmptyKeysMetadataFile()
{
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
keyStoreParameters.setKeyMetaDataFileLocation("classpath:keystore-tests/empty-alias-metadata.properties");
new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
}
@Test(expected = AlfrescoRuntimeException.class)
public void testWrongKeystorePasswordMetadataFile()
{
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
keyStoreParameters.setKeyMetaDataFileLocation("classpath:keystore-tests/wrong-keystore-password-metadata.properties");
new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
}
@Test(expected = AlfrescoRuntimeException.class)
public void testWrongKeyPasswordMetadataFile()
{
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
keyStoreParameters.setKeyMetaDataFileLocation("classpath:keystore-tests/wrong-key-password-metadata.properties");
new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
}
@Test(expected = AlfrescoRuntimeException.class)
public void testValidateKeysWrongAliasSysProps() throws Exception
{
String keyStoreId = testName.getMethodName() + "-keystore";
String alias1 = "mykey1";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setId(keyStoreId);
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
System.setProperty(keyStoreId + "." + "aliases", "wrong-alias,another-wrong-alias");
System.setProperty(keyStoreId + "." + "password", "ksPwd1");
System.setProperty(keyStoreId + "." + alias1 + "." + "password", "aliasPwd1");
try
{
AlfrescoKeyStoreImpl alfrescoKeyStore = new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
alfrescoKeyStore.setValidateKeyChanges(true);
alfrescoKeyStore.setKeysToValidate(Collections.singleton(alias1));
alfrescoKeyStore.setEncryptionKeysRegistry(encryptionKeysRegistry);
alfrescoKeyStore.validateKeys();
}
finally
{
System.clearProperty(keyStoreId + "." + "aliases");
System.clearProperty(keyStoreId + "." + "password");
System.clearProperty(keyStoreId + "." + alias1 + "." + "password");
}
}
@Test
public void testEmptyKeysSysProps()
{
String keyStoreId = testName.getMethodName() + "-keystore";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setId(keyStoreId);
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
System.setProperty(keyStoreId + "." + "aliases", "empty-alias,another-empty-alias");
System.setProperty(keyStoreId + "." + "password", "ksPwd1");
try
{
new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
}
finally
{
System.clearProperty(keyStoreId + "." + "aliases");
System.clearProperty(keyStoreId + "." + "password");
}
}
@Test(expected = AlfrescoRuntimeException.class)
public void testWrongKeystorePasswordSysProps()
{
String keyStoreId = testName.getMethodName() + "-keystore";
String alias1 = "mykey1";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setId(keyStoreId);
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
System.setProperty(keyStoreId + "." + "aliases", alias1);
System.setProperty(keyStoreId + "." + "password", "wrong-password");
System.setProperty(keyStoreId + "." + alias1 + "." + "password", "aliasPwd1");
try
{
new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
}
finally
{
System.clearProperty(keyStoreId + "." + "aliases");
System.clearProperty(keyStoreId + "." + "password");
System.clearProperty(keyStoreId + "." + alias1 + "." + "password");
}
}
@Test(expected = AlfrescoRuntimeException.class)
public void testWrongKeyPasswordSysProps()
{
String keyStoreId = testName.getMethodName() + "-keystore";
String alias1 = "mykey1";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setId(keyStoreId);
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
System.setProperty(keyStoreId + "." + "aliases", alias1);
System.setProperty(keyStoreId + "." + "password", "ksPwd1");
System.setProperty(keyStoreId + "." + alias1 + "." + "password", "wrong-key-password");
try
{
new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
}
finally
{
System.clearProperty(keyStoreId + "." + "aliases");
System.clearProperty(keyStoreId + "." + "password");
System.clearProperty(keyStoreId + "." + alias1 + "." + "password");
}
}
/**
* No exception is expected. An empty keystore can be created.
*/
@Test
public void testConfigEmptyKeystore()
{
String keyStoreId = testName.getMethodName() + "-keystore";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setId(keyStoreId);
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:non-existing-path/some-keystore.jks");
new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
}
@Test(expected = AlfrescoRuntimeException.class)
public void testValidateKeysEmptyAliasSysProps() throws Exception
{
String keyStoreId = testName.getMethodName() + "-keystore";
KeyStoreParameters keyStoreParameters = new KeyStoreParameters();
keyStoreParameters.setId(keyStoreId);
keyStoreParameters.setName(testName.getMethodName());
keyStoreParameters.setType("JCEKS");
keyStoreParameters.setProvider("SunJCE");
keyStoreParameters.setLocation("classpath:keystore-tests/ks-test-1.jks");
System.setProperty(keyStoreId + "." + "password", "ksPwd1");
try
{
AlfrescoKeyStoreImpl alfrescoKeyStore = new AlfrescoKeyStoreImpl(keyStoreParameters, new SpringKeyResourceLoader());
alfrescoKeyStore.setValidateKeyChanges(true);
alfrescoKeyStore.setKeysToValidate(Collections.singleton("non-existing-alias"));
alfrescoKeyStore.setEncryptionKeysRegistry(encryptionKeysRegistry);
alfrescoKeyStore.validateKeys();
}
finally
{
System.clearProperty(keyStoreId + "." + "password");
}
}
}

View File

@@ -1,2 +0,0 @@
aliases=empty-alias
keystore.password=ksPwd1

View File

@@ -1,3 +0,0 @@
aliases=mykey1
keystore.password=ksPwd1
mykey1.password=aliasPwd1

View File

@@ -1,24 +0,0 @@
The keystores contained in this folder are used by tests.
==================
== ks-test-1.ks ==
==================
Keystore password: ksPwd1
Keystore type: JCEKS
Keystore provider: SunJCE
Your keystore contains 1 entry
mykey1: aliasPwd1
==================
== ks-test-2.ks ==
==================
Keystore password: ksPwd2
Keystore type: JCEKS
Keystore provider: SunJCE
Your keystore contains 2 entries
mykey1: aliasPwd1
mykey2: aliasPwd2

View File

@@ -1,3 +0,0 @@
aliases=non-existing-alias
keystore.password=ksPwd1
mykey1.password=aliasPwd1

View File

@@ -1,3 +0,0 @@
aliases=mykey1
keystore.password=ksPwd1
mykey1.password=wrong-key-password

View File

@@ -1,3 +0,0 @@
aliases=mykey1
keystore.password=wrong-password
mykey1.password=aliasPwd1

View File

@@ -1,47 +0,0 @@
### Alfresco Data Model
[![Build Status](https://travis-ci.com/Alfresco/alfresco-data-model.svg?branch=master)](https://travis-ci.com/Alfresco/alfresco-data-model)
Data model is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
The library contains the following:
* Dictionary, Repository and Search Services interfaces
* Models for data types and Dictionary implementation
* Parsers
Please note that the data model uses version 2 of the Jackson libraries.
The upgrade from version 1 was not backward compatible, any projects
that are dependent on data model using Jackson 1.x should use the data-model 6.N branch.
Version 8.0 of data-model depends on alfresco-core 7.0 which is based on Spring 5.
### Building and testing
The project can be built and tested by running Maven command:
~~~
mvn clean install
~~~
### Artifacts
The artifacts can be obtained by:
* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/content/groups/public)
* getting as Maven dependency by adding the dependency to your pom file:
~~~
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-data-model</artifactId>
<version>version</version>
</dependency>
~~~
and Alfresco repository:
~~~
<repository>
<id>alfresco-maven-repo</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository>
~~~
The SNAPSHOT version of the artifact is **never** published.
### Old version history
The history for older versions can be found in [Alfresco SVN](https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD/root/projects/data-model)
### Contributing guide
Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.

View File

@@ -7,11 +7,11 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<properties>
<!-- Files to exclude from SonarQube analysis -->
<!-- Files to exclude from SonarQube analysis -->
<sonar.exclusions>
source/java/org/alfresco/repo/search/impl/parsers/CMIS*er.java,
source/java/org/alfresco/repo/search/impl/parsers/FTSParser.java,
@@ -147,7 +147,8 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
@@ -225,6 +226,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>

View File

@@ -22,7 +22,6 @@
<mimetype mimetype="application/vnd.ms-project" display="Microsoft Project">
<extension default="true">mpp</extension>
<extension>mpt</extension>
</mimetype>
<mimetype mimetype="image/vnd.adobe.photoshop" display="Adobe Photoshop">
@@ -109,28 +108,11 @@
<extension>acp</extension>
</mimetype>
<mimetype mimetype="application/vnd.visio" display="Microsoft Visio">
<extension default="true">vsd</extension>
<extension>vss</extension>
<extension>vst</extension>
<extension>vsd</extension>
</mimetype>
<mimetype mimetype="application/vnd.visio2013" display="Microsoft Visio 2013">
<extension>vsdx</extension>
</mimetype>
<mimetype mimetype="application/vnd.ms-visio.drawing.macroenabled.main+xml" display="Microsoft Visio macro-enabled drawing">
<extension>vsdm</extension>
</mimetype>
<mimetype mimetype="application/vnd.ms-visio.stencil.main+xml" display="Microsoft Visio stencil">
<extension>vssx</extension>
</mimetype>
<mimetype mimetype="application/vnd.ms-visio.stencil.macroenabled.main+xml" display="Microsoft Visio macro-enabled stencil">
<extension>vssm</extension>
</mimetype>
<mimetype mimetype="application/vnd.ms-visio.template.main+xml" display="Microsoft Visio template">
<extension>vstx</extension>
</mimetype>
<mimetype mimetype="application/vnd.ms-visio.template.macroenabled.main+xml" display="Microsoft Visio macro-enabled template">
<extension>vstm</extension>
</mimetype>
<mimetype mimetype="application/vnd.adobe.xdp+xml" display="Adobe Acrobat XML Data Package">
<extension>xdp</extension>
</mimetype>

View File

@@ -9,6 +9,6 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
</project>

View File

@@ -20,7 +20,6 @@ RUN mkdir -p ${TOMCAT_DIR}/shared/classes/alfresco/extension/mimetypes && \
mkdir -p ${TOMCAT_DIR}/shared/classes/alfresco/extension/transform/renditions && \
mkdir -p ${TOMCAT_DIR}/shared/classes/alfresco/extension/transform/pipelines && \
mkdir /licenses && \
mkdir -p ${TOMCAT_DIR}/shared/classes/alfresco/extension/keystore && \
mkdir ${TOMCAT_DIR}/alfresco-mmt && \
touch ${TOMCAT_DIR}/shared/classes/alfresco-global.properties
@@ -29,12 +28,10 @@ RUN mkdir -p ${TOMCAT_DIR}/shared/classes/alfresco/extension/mimetypes && \
# Copy the JDBC drivers for the database you are using to the lib/ directory.
# Copy the alfresco-mmt.jar
# Copy Licenses to the root of the Docker image
# Copy default keystore
COPY ${resource_path}/war ${TOMCAT_DIR}/webapps
COPY ${resource_path}/connector/* ${TOMCAT_DIR}/lib/
COPY ${resource_path}/alfresco-mmt/* ${TOMCAT_DIR}/alfresco-mmt/
COPY ${resource_path}/dependency/licenses/ /licenses/
COPY ${resource_path}/dependency/keystore/metadata-keystore ${TOMCAT_DIR}/shared/classes/alfresco/extension/keystore/
# Change the value of the shared.loader= property to the following:
# shared.loader=${catalina.base}/shared/classes
@@ -91,9 +88,9 @@ RUN mkdir -p ${TOMCAT_DIR}/conf/Catalina/localhost && \
chmod g+rwx ${TOMCAT_DIR}/temp && \
chmod g+rwx ${TOMCAT_DIR}/work && \
chmod o-w ${TOMCAT_DIR}/work && \
chmod 644 ${TOMCAT_DIR}/alfresco-mmt/alfresco-mmt-*.jar && \
find /licenses -type d -exec chmod 0755 {} \; && \
find /licenses -type f -exec chmod 0644 {} \;
chmod 664 ${TOMCAT_DIR}/alfresco-mmt/alfresco-mmt-*.jar && \
find /licenses -type d -exec chmod 0775 {} \; && \
find /licenses -type f -exec chmod 0664 {} \;
EXPOSE 10001

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<properties>
@@ -105,7 +105,7 @@
</execution>
<execution>
<id>unpack-licenses-and-keystore</id>
<id>unpack-licenses</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<profiles>

View File

@@ -10,16 +10,6 @@ services:
image: alfresco/alfresco-community-repo-base:latest
environment:
CATALINA_OPTS : "-agentlib:jdwp=transport=dt_socket,address=*:8000,server=y,suspend=n"
JAVA_TOOL_OPTIONS: "
-Dencryption.keystore.type=JCEKS
-Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
-Dencryption.keyAlgorithm=DESede
-Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore
-Dmetadata-keystore.password=mp6yc0UD9e
-Dmetadata-keystore.aliases=metadata
-Dmetadata-keystore.metadata.password=oKIWzVdEdA
-Dmetadata-keystore.metadata.algorithm=DESede
"
JAVA_OPTS :
"
-Ddb.driver=org.postgresql.Driver
@@ -49,6 +39,10 @@ services:
-Dftp.port=1221
-Dcors.enabled=true
-Dcors.allowed.origins=http://localhost:4200,http://localhost:8080
-Dmetadata-keystore.password=mp6yc0UD9e
-Dmetadata-keystore.aliases=metadata
-Dmetadata-keystore.metadata.password=mp6yc0UD9e
-Dmetadata-keystore.metadata.algorithm=AES
"
ports:
- 8082:8080

View File

@@ -10,16 +10,6 @@ services:
image: alfresco/alfresco-community-repo-base:latest
environment:
CATALINA_OPTS : "-agentlib:jdwp=transport=dt_socket,address=*:8000,server=y,suspend=n"
JAVA_TOOL_OPTIONS: "
-Dencryption.keystore.type=JCEKS
-Dencryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
-Dencryption.keyAlgorithm=DESede
-Dencryption.keystore.location=/usr/local/tomcat/shared/classes/alfresco/extension/keystore/keystore
-Dmetadata-keystore.password=mp6yc0UD9e
-Dmetadata-keystore.aliases=metadata
-Dmetadata-keystore.metadata.password=oKIWzVdEdA
-Dmetadata-keystore.metadata.algorithm=DESede
"
JAVA_OPTS :
"
-Ddb.driver=org.postgresql.Driver
@@ -45,6 +35,10 @@ services:
-Dftp.port=1221
-Dcors.enabled=true
-Dcors.allowed.origins=http://localhost:4200,http://localhost:8080
-Dmetadata-keystore.password=mp6yc0UD9e
-Dmetadata-keystore.aliases=metadata
-Dmetadata-keystore.metadata.password=mp6yc0UD9e
-Dmetadata-keystore.metadata.algorithm=AES
"
ports:
- 8082:8080

View File

@@ -6,7 +6,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<modules>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<developers>

View File

@@ -9,7 +9,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-tests</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<developers>

View File

@@ -7,12 +7,12 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo-packaging</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<properties>
<scm-path>${project.parent.parent.scm.url}</scm-path>
<scm-revision>${build-number}</scm-revision>
<scm-path>local/development/workspace</scm-path>
<scm-revision>${buildNumber}</scm-revision>
</properties>
<dependencies>
@@ -41,6 +41,7 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>org.apache.avalon.framework</groupId>
@@ -71,6 +72,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<!-- Test dependencies -->
@@ -99,6 +101,7 @@
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
@@ -151,7 +154,7 @@
</resource>
</resources>
<plugins>
<!-- Creates a scm revision and stores in ${buildNumber} variable -->
<!-- Gets the scm revision and stores it in the ${buildNumber} variable -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>

27
pom.xml
View File

@@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>alfresco-community-repo</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
<packaging>pom</packaging>
<name>Alfresco Community Repo Parent</name>
@@ -23,7 +23,7 @@
<properties>
<acs.version.major>6</acs.version.major>
<acs.version.minor>2</acs.version.minor>
<acs.version.revision>3</acs.version.revision>
<acs.version.revision>2</acs.version.revision>
<acs.version.label />
<version.edition>Community</version.edition>
@@ -53,7 +53,7 @@
<dependency.activiti.version>5.23.0</dependency.activiti.version>
<dependency.transform.model.version>1.0.2.8</dependency.transform.model.version>
<dependency.alfresco-legacy-lucene.version>6.2</dependency.alfresco-legacy-lucene.version>
<dependency.alfresco-greenmail.version>6.2</dependency.alfresco-greenmail.version>
<dependency.alfresco-greenmail.version>6.1</dependency.alfresco-greenmail.version>
<dependency.spring.version>5.1.15.RELEASE</dependency.spring.version>
<dependency.antlr.version>3.5.2</dependency.antlr.version>
@@ -79,10 +79,10 @@
<dependency.jaxb.version>2.3.2</dependency.jaxb.version>
<dependency.groovy.version>2.5.9</dependency.groovy.version>
<dependency.javax.mail.version>1.6.2</dependency.javax.mail.version>
<dependency.tika.version>1.21-20190624-alfresco-patched</dependency.tika.version>
<dependency.tika.version>1.24.1</dependency.tika.version>
<dependency.spring-security.version>5.1.9.RELEASE</dependency.spring-security.version>
<dependency.truezip.version>7.7.10</dependency.truezip.version>
<dependency.poi.version>4.1.1</dependency.poi.version>
<dependency.poi.version>4.1.2</dependency.poi.version>
<dependency.ooxml-schemas.version>1.4</dependency.ooxml-schemas.version>
<dependency.keycloak.version>11.0.0-alfresco-001</dependency.keycloak.version>
<dependency.jboss.logging.version>3.4.1.Final</dependency.jboss.logging.version>
@@ -93,7 +93,7 @@
<alfresco.googledrive.version>3.2.0</alfresco.googledrive.version>
<alfresco.aos-module.version>1.3.1</alfresco.aos-module.version>
<dependency.postgresql.version>42.2.14</dependency.postgresql.version>
<dependency.postgresql.version>42.2.12</dependency.postgresql.version>
<dependency.mysql.version>8.0.19</dependency.mysql.version>
<dependency.mariadb.version>2.6.0</dependency.mariadb.version>
@@ -112,7 +112,7 @@
<connection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</connection>
<developerConnection>scm:git:https://github.com/Alfresco/alfresco-community-repo.git</developerConnection>
<url>https://github.com/Alfresco/alfresco-community-repo</url>
<tag>7.300-TEST2</tag>
<tag>7.199.312</tag>
</scm>
<distributionManagement>
@@ -172,11 +172,6 @@
<classifier>win64</classifier>
<type>tgz</type>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-pdf-renderer</artifactId>
<version>${dependency.alfresco-pdf-renderer.version}</version>
</dependency>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-server-root</artifactId>
@@ -232,7 +227,7 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
@@ -488,12 +483,6 @@
<artifactId>xercesImpl</artifactId>
<version>${dependency.xercesImpl.version}</version>
</dependency>
<!-- Newer metadata-extractor, used in TIKA, see ACS-370 -->
<dependency>
<groupId>com.drewnoakes</groupId>
<artifactId>metadata-extractor</artifactId>
<version>2.13.0</version>
</dependency>
<!-- upgrade dependency from TIKA -->
<dependency>
<groupId>com.github.junrar</groupId>

View File

@@ -1,41 +0,0 @@
### Alfresco Remote API
[![Build Status](https://travis-ci.com/Alfresco/alfresco-remote-api.svg?branch=master)](https://travis-ci.com/Alfresco/alfresco-remote-api)
Remote API is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
The library contains the following:
* REST API framework
* WebScript implementations including [V1 REST APIs](https://community.alfresco.com/community/ecm/blog/2017/05/02/v1-rest-api-10-things-you-should-know)
* [OpenCMIS](https://chemistry.apache.org/java/opencmis.html) implementations
### Building and testing
The project can be built by running Maven command:
~~~
mvn clean install
~~~
The tests are combined in test classes split by test type or Spring application context used in the test, see classes in _src/test/java/org/alfresco_. All of these classes as well as individual tests can be run by specifying the test class name and a set of DB connection properties, for example:
~~~
mvn clean test -Dtest=SomeTest -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql:alfresco -Ddb.username=alfresco -Ddb.password=alfresco
~~~
### Artifacts
The artifacts can be obtained by:
* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/content/groups/public)
* getting as Maven dependency by adding the dependency to your pom file:
~~~
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-remote-api</artifactId>
<version>version</version>
</dependency>
~~~
and Alfresco Maven repository:
~~~
<repository>
<id>alfresco-maven-repo</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository>
~~~
The SNAPSHOT version of the artifact is **never** published.
### Contributing guide
Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<dependencies>
@@ -78,6 +78,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -239,54 +240,6 @@
<alfresco-pdf-renderer.exe>${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer</alfresco-pdf-renderer.exe>
</properties>
</profile>
<profile>
<id>osx-alfresco-pdf-renderer-test</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-pdf-renderer</artifactId>
<version>${dependency.alfresco-pdf-renderer.version}</version>
<classifier>osx</classifier>
<type>tgz</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<inherited>false</inherited>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>extract-alfresco-pdf-renderer-test</id>
<phase>generate-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<target>
<echo message="Extracting alfresco-pdf-renderer (OS-X) for testing..." />
<mkdir dir="${project.build.directory}/test-binaries/alfresco-pdf-renderer" />
<exec failonerror="true" executable="tar" dir="${project.build.directory}/test-binaries/alfresco-pdf-renderer">
<arg value="xf" />
<arg value="${settings.localRepository}/org/alfresco/alfresco-pdf-renderer/${dependency.alfresco-pdf-renderer.version}/alfresco-pdf-renderer-${dependency.alfresco-pdf-renderer.version}-osx.tgz" />
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<alfresco-pdf-renderer.exe>${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer</alfresco-pdf-renderer.exe>
</properties>
</profile>
</profiles>
<build>
<pluginManagement>

View File

@@ -208,7 +208,7 @@ public abstract class BaseSSOAuthenticationFilter extends BaseAuthenticationFilt
{
match = container.getRegistry().findWebScript(req.getMethod(), getScriptUrl(req));
}
catch (NotFoundException notFoundEx)
catch (NotFoundException | IllegalArgumentException Ex)
{
getLogger().debug(req.getMethod() + " " + getScriptUrl(req) + "not found in Public API Container.");
}

View File

@@ -1831,6 +1831,19 @@ public class NodesImpl implements Nodes
{
versionMajor = Boolean.valueOf(str);
}
String versioningEnabledStringValue = parameters.getParameter("versioningEnabled");
if (null != versioningEnabledStringValue)
{
boolean versioningEnabled = Boolean.parseBoolean(versioningEnabledStringValue);
if (versioningEnabled)
{
versionMajor = (null != versionMajor) ? versionMajor : true;
}
else
{
versionMajor = null;
}
}
String versionComment = parameters.getParameter(PARAM_VERSION_COMMENT);
// Create the node
@@ -2331,6 +2344,11 @@ public class NodesImpl implements Nodes
private void handleNodeRename(Map<QName, Serializable> props, NodeRef nodeRef)
{
Serializable nameProp = props.get(ContentModel.PROP_NAME);
handleNodeRename(nameProp, nodeRef);
}
private void handleNodeRename(Serializable nameProp, NodeRef nodeRef)
{
if ((nameProp != null))
{
String currentName = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
@@ -2705,6 +2723,7 @@ public class NodesImpl implements Nodes
String fileName = parameters.getParameter(PARAM_NAME);
if (fileName != null)
{
handleNodeRename(fileName, nodeRef);
// optionally rename, before updating the content
nodeService.setProperty(nodeRef, ContentModel.PROP_NAME, fileName);
}
@@ -2891,6 +2910,7 @@ public class NodesImpl implements Nodes
String versionComment = null;
String relativePath = null;
String renditionNames = null;
boolean versioningEnabled = true;
Map<String, Object> qnameStrProps = new HashMap<>();
Map<QName, Serializable> properties = null;
@@ -2947,6 +2967,19 @@ public class NodesImpl implements Nodes
case "renditions":
renditionNames = getStringOrNull(field.getValue());
break;
case "versioningenabled":
String versioningEnabledStringValue = getStringOrNull(field.getValue());
if (null != versioningEnabledStringValue)
{
// MNT-22036 versioningenabled parameter was added to disable versioning of newly created nodes.
// The default API mechanism should not be changed/affected.
// Versioning is enabled by default when creating a node using form-data.
// To preserve this, versioningEnabled value must be 'true' for any given value typo/valuesNotSupported (except case-insensitive 'false')
// .equalsIgnoreCase("false") will return true only when the input value is 'false'
// !.equalsIgnoreCase("false") will return false only when the input value is 'false'
versioningEnabled = !versioningEnabledStringValue.equalsIgnoreCase("false");
}
break;
default:
{
@@ -3019,12 +3052,14 @@ public class NodesImpl implements Nodes
throw new ConstraintViolatedException(fileName + " already exists.");
}
}
// Note: pending REPO-159, we currently auto-enable versioning on new upload (but not when creating empty file)
if (versionMajor == null)
{
versionMajor = true;
}
// MNT-22036 add versioningEnabled property for newly created nodes.
versionMajor = versioningEnabled ? versionMajor : null;
// Create a new file.
NodeRef nodeRef = createNewFile(parentNodeRef, fileName, nodeTypeQName, content, properties, assocTypeQName, parameters, versionMajor, versionComment);

View File

@@ -5605,6 +5605,279 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
assertTrue(((ArrayList) (propUpdateResponse.get("custom:locations"))).size() == 1);
}
@Test
public void versioningEnabledMultipartNodeCreationTest() throws Exception
{
setRequestContext(user1);
String myNodeId = getMyNodeId();
// Test Scenarios:
// 1: majorVersion not set - versioningEnabled not set Expect: MAJOR version
// 2: majorVersion not set - versioningEnabled false Expect: versioning disabled
// 3: majorVersion true - versioningEnabled false Expect: versioning disabled
// 4: majorVersion false - versioningEnabled false Expect: versioning disabled
// 5: majorVersion not set - versioningEnabled true Expect: MAJOR version
// 6: majorVersion true - versioningEnabled true Expect: MAJOR version
// 7: majorVersion false - versioningEnabled true Expect: Minor version
// 8: majorVersion not set - versioningEnabled False Expect: versioning disabled
// 9: majorVersion not set - versioningEnabled invalid Expect: MAJOR version
// Scenario 1:
String fileName = "myfile" + UUID.randomUUID() + ".txt";
File file = getResourceFile("quick-2.pdf");
MultiPartBuilder multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
MultiPartRequest reqBody = multiPartBuilder.build();
HttpResponse response = post(getNodeChildrenUrl(myNodeId), reqBody.getBody(), null, reqBody.getContentType(), 201);
Document documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
// Default behaviour, expect to be MAJOR Version 1.0
Map<String, Object> documentProperties = documentResponse.getProperties();
assertEquals("MAJOR", documentProperties.get("cm:versionType"));
assertEquals("1.0", documentProperties.get("cm:versionLabel"));
// Scenario 2:
fileName = "myfile" + UUID.randomUUID() + ".txt";
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
multiPartBuilder.setVersioningEnabled("false");
reqBody = multiPartBuilder.build();
response = post(getNodeChildrenUrl(myNodeId), reqBody.getBody(), null, reqBody.getContentType(), 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
// Scenario 3:
fileName = "myfile" + UUID.randomUUID() + ".txt";
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
multiPartBuilder.setMajorVersion(true);
multiPartBuilder.setVersioningEnabled("false");
reqBody = multiPartBuilder.build();
response = post(getNodeChildrenUrl(myNodeId), reqBody.getBody(), null, reqBody.getContentType(), 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
// Scenario 4:
fileName = "myfile" + UUID.randomUUID() + ".txt";
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
multiPartBuilder.setMajorVersion(false);
multiPartBuilder.setVersioningEnabled("false");
reqBody = multiPartBuilder.build();
response = post(getNodeChildrenUrl(myNodeId), reqBody.getBody(), null, reqBody.getContentType(), 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
// Scenario 5:
fileName = "myfile" + UUID.randomUUID() + ".txt";
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
multiPartBuilder.setVersioningEnabled("true");
reqBody = multiPartBuilder.build();
response = post(getNodeChildrenUrl(myNodeId), reqBody.getBody(), null, reqBody.getContentType(), 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertEquals("MAJOR", documentProperties.get("cm:versionType"));
assertEquals("1.0", documentProperties.get("cm:versionLabel"));
// Scenario 6:
fileName = "myfile" + UUID.randomUUID() + ".txt";
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
multiPartBuilder.setMajorVersion(true);
multiPartBuilder.setVersioningEnabled("true");
reqBody = multiPartBuilder.build();
response = post(getNodeChildrenUrl(myNodeId), reqBody.getBody(), null, reqBody.getContentType(), 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertEquals("MAJOR", documentProperties.get("cm:versionType"));
assertEquals("1.0", documentProperties.get("cm:versionLabel"));
// Scenario 7:
fileName = "myfile" + UUID.randomUUID() + ".txt";
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
multiPartBuilder.setMajorVersion(false);
multiPartBuilder.setVersioningEnabled("true");
reqBody = multiPartBuilder.build();
response = post(getNodeChildrenUrl(myNodeId), reqBody.getBody(), null, reqBody.getContentType(), 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertEquals("MINOR", documentProperties.get("cm:versionType"));
assertEquals("0.1", documentProperties.get("cm:versionLabel"));
// Scenario 8:
fileName = "myfile" + UUID.randomUUID() + ".txt";
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
multiPartBuilder.setVersioningEnabled("False");
reqBody = multiPartBuilder.build();
response = post(getNodeChildrenUrl(myNodeId), reqBody.getBody(), null, reqBody.getContentType(), 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
// Scenario 9:
fileName = "myfile" + UUID.randomUUID() + ".txt";
multiPartBuilder = MultiPartBuilder.create().setFileData(new FileData(fileName, file));
multiPartBuilder.setVersioningEnabled("invalid");
reqBody = multiPartBuilder.build();
response = post(getNodeChildrenUrl(myNodeId), reqBody.getBody(), null, reqBody.getContentType(), 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertEquals("MAJOR", documentProperties.get("cm:versionType"));
assertEquals("1.0", documentProperties.get("cm:versionLabel"));
}
@Test
public void versioningEnabledJSONNodeCreationTest() throws Exception
{
setRequestContext(user1);
String myNodeId = getMyNodeId();
// Test Scenarios:
// 1: majorVersion not set - versioningEnabled not set Expect: versioning disabled
// 2: majorVersion not set - versioningEnabled false Expect: versioning disabled
// 3: majorVersion true - versioningEnabled false Expect: versioning disabled
// 4: majorVersion false - versioningEnabled false Expect: versioning disabled
// 5: majorVersion not set - versioningEnabled true Expect: MAJOR version
// 6: majorVersion true - versioningEnabled true Expect: MAJOR version
// 7: majorVersion false - versioningEnabled true Expect: Minor version
// 8: majorVersion not set - versioningEnabled False Expect: versioning disabled
// 9: majorVersion not set - versioningEnabled invalid Expect: versioning disabled
// 10 majorVersion not set - versioningenabled true Expect: versioning disabled
Document d1 = new Document();
Map<String, String> requestHeaders = new HashMap<>();
//Scenario 1:
d1.setName("testDoc" + UUID.randomUUID());
d1.setNodeType(TYPE_CM_CONTENT);
HttpResponse response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
Document documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
Map<String, Object> documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
//Scenario 2:
d1.setName("testDoc" + UUID.randomUUID());
requestHeaders = new HashMap<>();
requestHeaders.put("versioningEnabled","false");
response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
//Scenario 3:
d1.setName("testDoc" + UUID.randomUUID());
requestHeaders = new HashMap<>();
requestHeaders.put("versioningEnabled","false");
requestHeaders.put("majorVersion","true");
response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
//Scenario 4:
d1.setName("testDoc" + UUID.randomUUID());
requestHeaders = new HashMap<>();
requestHeaders.put("versioningEnabled","false");
requestHeaders.put("majorVersion","false");
response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
//Scenario 5:
d1.setName("testDoc" + UUID.randomUUID());
requestHeaders = new HashMap<>();
requestHeaders.put("versioningEnabled","true");
response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertEquals("MAJOR", documentProperties.get("cm:versionType"));
assertEquals("1.0", documentProperties.get("cm:versionLabel"));
//Scenario 6:
d1.setName("testDoc" + UUID.randomUUID());
requestHeaders = new HashMap<>();
requestHeaders.put("versioningEnabled","true");
requestHeaders.put("majorVersion","true");
response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertEquals("MAJOR", documentProperties.get("cm:versionType"));
assertEquals("1.0", documentProperties.get("cm:versionLabel"));
//Scenario 7:
d1.setName("testDoc" + UUID.randomUUID());
requestHeaders = new HashMap<>();
requestHeaders.put("versioningEnabled","true");
requestHeaders.put("majorVersion","false");
response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertEquals("MINOR", documentProperties.get("cm:versionType"));
assertEquals("0.1", documentProperties.get("cm:versionLabel"));
//Scenario 8:
d1.setName("testDoc" + UUID.randomUUID());
requestHeaders = new HashMap<>();
requestHeaders.put("versioningEnabled","False");
response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
//Scenario 9:
d1.setName("testDoc" + UUID.randomUUID());
requestHeaders = new HashMap<>();
requestHeaders.put("versioningEnabled","invalid");
response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
//Scenario 10:
d1.setName("testDoc" + UUID.randomUUID());
requestHeaders = new HashMap<>();
requestHeaders.put("versioningenabled","true");
response = post(getNodeChildrenUrl(myNodeId), toJsonAsStringNonNull(d1),requestHeaders, null, null, 201);
documentResponse = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
documentProperties = documentResponse.getProperties();
assertNull(documentProperties);
}
@Test public void testAuditableProperties() throws Exception
{
setRequestContext(user1);
@@ -5708,6 +5981,55 @@ public class NodeApiTest extends AbstractSingleNetworkSiteTest
assertTrue(currentPath.equals(expectedPath));
}
@Test
public void testPrimaryPathVersion() throws Exception
{
setRequestContext(user1);
AuthenticationUtil.setFullyAuthenticatedUser(user1);
String myNodeId = getMyNodeId();
// /Company Home/User Homes/user<timestamp>/folder_A
String folderName = "folder_A";
Folder folder = createFolder(myNodeId, folderName);
NodeRef folderNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, folder.getId());
// /Company Home/User Homes/user<timestamp>/folder_A/testDoc<GUID>
String docName = "testDoc" + GUID.generate();
Document doc = new Document();
doc.setName(docName);
doc.setNodeType(TYPE_CM_CONTENT);
HttpResponse response = post(getNodeChildrenUrl(folderNodeRef.getId()), toJsonAsStringNonNull(doc), 201);
Document docResp = RestApiUtil.parseRestApiEntry(response.getJsonResponse(), Document.class);
NodeRef docNodeRef = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, docResp.getId());
// Checks that current path and name match
String expectedPath1 = "/Company Home/User Homes/" + user1 + "/" + folderName + "/" + docName;
Path docPath1 = nodeService.getPath(docNodeRef);
Path.ChildAssocElement docPathLast1 = (Path.ChildAssocElement) docPath1.last();
String docLocalName1 = docPathLast1.getRef().getQName().getLocalName();
String currentPath1 = docPath1.toDisplayPath(nodeService, permissionService) + "/" + docLocalName1;
assertTrue(docName.equals(docLocalName1));
assertTrue(expectedPath1.equals(currentPath1));
// Upload document new content supplying a different name
String docName2 = "testDoc2" + GUID.generate();
Map<String, String> params = new HashMap<>();
params.put("name", docName2);
Document docResp2 = updateTextFileWithRandomContent(docNodeRef.getId(), 1024L, params);
NodeRef docNodeRef2 = new NodeRef(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE, docResp2.getId());
// Checks new path and name after new version upload
String expectedPath2 = "/Company Home/User Homes/" + user1 + "/" + folderName + "/" + docName2;
Path docPath2 = nodeService.getPath(docNodeRef2);
Path.ChildAssocElement docPathLast2 = (Path.ChildAssocElement) docPath2.last();
String docLocalName2 = docPathLast2.getRef().getQName().getLocalName();
String currentPath2 = docPath2.toDisplayPath(nodeService, permissionService) + "/" + docLocalName2;
assertFalse(docLocalName1.equals(docLocalName2));
assertTrue(docName2.equals(docLocalName2));
assertFalse(expectedPath1.equals(currentPath2));
assertTrue(expectedPath2.equals(currentPath2));
}
private String getDataDictionaryNodeId() throws Exception
{
Map params = new HashMap<>();

View File

@@ -43,7 +43,6 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
/**
* <i><b>multipart/form-data</b></i> builder.
@@ -57,6 +56,7 @@ public class MultiPartBuilder
private String updateNodeRef;
private String description;
private String contentTypeQNameStr;
private String versioningEnabled;
private List<String> aspects = Collections.emptyList();
private Boolean majorVersion;
private Boolean overwrite;
@@ -76,6 +76,7 @@ public class MultiPartBuilder
this.updateNodeRef = that.updateNodeRef;
this.description = that.description;
this.contentTypeQNameStr = that.contentTypeQNameStr;
this.versioningEnabled = that.versioningEnabled;
this.aspects = new ArrayList<>(that.aspects);
this.majorVersion = that.majorVersion;
this.overwrite = that.overwrite;
@@ -125,6 +126,12 @@ public class MultiPartBuilder
return this;
}
public MultiPartBuilder setVersioningEnabled(String versioningEnabled)
{
this.versioningEnabled = versioningEnabled;
return this;
}
public MultiPartBuilder setAspects(List<String> aspects)
{
this.aspects = aspects;
@@ -278,6 +285,7 @@ public class MultiPartBuilder
addPartIfNotNull(parts, "updatenoderef", updateNodeRef);
addPartIfNotNull(parts, "description", description);
addPartIfNotNull(parts, "contenttype", contentTypeQNameStr);
addPartIfNotNull(parts, "versioningenabled", versioningEnabled);
addPartIfNotNull(parts, "aspects", getCommaSeparated(aspects));
addPartIfNotNull(parts, "majorversion", majorVersion);
addPartIfNotNull(parts, "overwrite", overwrite);

View File

@@ -1,41 +0,0 @@
### Alfresco Repository
[![Build Status](https://travis-ci.com/Alfresco/alfresco-repository.svg?branch=master)](https://travis-ci.com/Alfresco/alfresco-repository)
Repository is a library packaged as a jar file which is part of [Alfresco Content Services Repository](https://community.alfresco.com/docs/DOC-6385-project-overview-repository).
The library contains the following:
* DAOs and SQL scripts
* Various Service implementations
* Utility classes
### Building and testing
The project can be built by running Maven command:
~~~
mvn clean install
~~~
The tests are combined in test classes split by test type or Spring application context used in the test, see classes in _src/test/java/org/alfresco_. All of these classes as well as individual tests can be run by specifying the test class name and a set of DB connection properties, for example:
~~~
mvn clean test -Dtest=SomeRepoTest -Ddb.driver=org.postgresql.Driver -Ddb.name=alfresco -Ddb.url=jdbc:postgresql:alfresco -Ddb.username=alfresco -Ddb.password=alfresco
~~~
### Artifacts
The artifacts can be obtained by:
* downloading from [Alfresco repository](https://artifacts.alfresco.com/nexus/content/groups/public)
* getting as Maven dependency by adding the dependency to your pom file:
~~~
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-repository</artifactId>
<version>version</version>
</dependency>
~~~
and Alfresco Maven repository:
~~~
<repository>
<id>alfresco-maven-repo</id>
<url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
</repository>
~~~
The SNAPSHOT version of the artifact is **never** published.
### Contributing guide
Please use [this guide](CONTRIBUTING.md) to make a contribution to the project.

View File

@@ -7,7 +7,7 @@
<parent>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-community-repo</artifactId>
<version>7.300-TEST2</version>
<version>7.199.312</version>
</parent>
<dependencies>
@@ -65,7 +65,6 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
@@ -75,21 +74,19 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.14</version>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.4</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>commons-pool</groupId>
@@ -343,6 +340,7 @@
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.10.5</version>
</dependency>
<dependency>
<groupId>jaxen</groupId>
@@ -467,7 +465,8 @@
<dependency>
<groupId>org.quartz-scheduler</groupId>
<artifactId>quartz</artifactId>
<exclusions>
<version>2.3.2</version>
<exclusions>
<exclusion>
<groupId>com.mchange</groupId>
<artifactId>*</artifactId>
@@ -812,6 +811,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -1020,54 +1020,6 @@
<alfresco-pdf-renderer.exe>${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer</alfresco-pdf-renderer.exe>
</properties>
</profile>
<profile>
<id>osx-alfresco-pdf-renderer-test</id>
<activation>
<os>
<family>mac</family>
</os>
</activation>
<dependencies>
<dependency>
<groupId>org.alfresco</groupId>
<artifactId>alfresco-pdf-renderer</artifactId>
<version>${dependency.alfresco-pdf-renderer.version}</version>
<classifier>osx</classifier>
<type>tgz</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<inherited>false</inherited>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>extract-alfresco-pdf-renderer-test</id>
<phase>generate-test-resources</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<target>
<echo message="Extracting alfresco-pdf-renderer (OS-X) for testing..." />
<mkdir dir="${project.build.directory}/test-binaries/alfresco-pdf-renderer" />
<exec failonerror="true" executable="tar" dir="${project.build.directory}/test-binaries/alfresco-pdf-renderer">
<arg value="xf" />
<arg value="${settings.localRepository}/org/alfresco/alfresco-pdf-renderer/${dependency.alfresco-pdf-renderer.version}/alfresco-pdf-renderer-${dependency.alfresco-pdf-renderer.version}-osx.tgz" />
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
<alfresco-pdf-renderer.exe>${project.build.directory}/test-binaries/alfresco-pdf-renderer/alfresco-pdf-renderer</alfresco-pdf-renderer.exe>
</properties>
</profile>
</profiles>

View File

@@ -81,22 +81,19 @@ public class TransactionAwareHolder<T> extends Holder<T>
{
this.internalHolder = internalHolder;
this.value = internalHolder.getValue();
txListener = new TxAwareHolderListener();
}
@Override
public T getValue()
{
if (TransactionSynchronizationManager.isSynchronizationActive())
{
AlfrescoTransactionSupport.bindListener(txListener);
}
registerTxListenerIfNeeded();
return this.value;
}
@Override
public void setValue(T value)
{
registerTxListenerIfNeeded();
this.value = value;
}
@@ -109,6 +106,17 @@ public class TransactionAwareHolder<T> extends Holder<T>
'}';
}
// MNT-21800 CMIS Web Service Check Out returns error
private void registerTxListenerIfNeeded()
{
if (this.txListener == null && TransactionSynchronizationManager.isSynchronizationActive())
{
TxAwareHolderListener listener = new TxAwareHolderListener();
AlfrescoTransactionSupport.bindListener(listener);
this.txListener = listener;
}
}
private class TxAwareHolderListener extends TransactionListenerAdapter
{
@Override

View File

@@ -177,13 +177,13 @@ public class CMISResultSetRow implements ResultSetRow
context.setScore(getScore());
for (Column column : query.getColumns())
{
// When an SCORE selector is included, score must be adapted to range 0..1 due to CMIS specification
if (column.getFunction()!= null && column.getFunction().getName().equals(Score.NAME))
{
return getNormalisedScore();
}
else if (column.getAlias().equals(columnName))
if (column.getAlias().equals(columnName))
{
//When an SCORE selector is included, score must be adapted to range 0..1 due to CMIS specification
if (column.getFunction()!= null && column.getFunction().getName().equals(Score.NAME))
{
return getNormalisedScore();
}
return column.getFunction().getValue(column.getFunctionArguments(), context);
}
// Special case for one selector - ignore any table aliases

View File

@@ -68,11 +68,10 @@ public class TikaAutoMetadataExtracter extends TikaPoweredMetadataExtracter
protected static Log logger = LogFactory.getLog(TikaAutoMetadataExtracter.class);
private static AutoDetectParser parser;
private static TikaConfig config;
private static String EXIF_IMAGE_HEIGHT_TAG = "Exif Image Height";
private static String EXIF_IMAGE_WIDTH_TAG = "Exif Image Width";
private static String EXIF_IMAGE_HEIGHT_TAG = "Exif SubIFD:Exif Image Height";
private static String EXIF_IMAGE_WIDTH_TAG = "Exif SubIFD:Exif Image Width";
private static String JPEG_IMAGE_HEIGHT_TAG = "Image Height";
private static String JPEG_IMAGE_WIDTH_TAG = "Image Width";
private static String COMPRESSION_TAG = "Compression";
public static ArrayList<String> SUPPORTED_MIMETYPES;
private static ArrayList<String> buildMimeTypes(TikaConfig tikaConfig)
@@ -127,16 +126,12 @@ public class TikaAutoMetadataExtracter extends TikaPoweredMetadataExtracter
if(MimetypeMap.MIMETYPE_IMAGE_JPEG.equals(metadata.get(Metadata.CONTENT_TYPE)))
{
//check if the image has exif information
if(metadata.get(EXIF_IMAGE_WIDTH_TAG) != null
&& metadata.get(EXIF_IMAGE_HEIGHT_TAG) != null
&& metadata.get(COMPRESSION_TAG) != null)
if (metadata.get(EXIF_IMAGE_WIDTH_TAG) != null && metadata.get(EXIF_IMAGE_HEIGHT_TAG) != null)
{
//replace the exif size properties that will be embedded in the node with
//the guessed dimensions from Tika
putRawValue(TIFF.IMAGE_LENGTH.getName(), extractSize(metadata.get(EXIF_IMAGE_HEIGHT_TAG)), properties);
putRawValue(TIFF.IMAGE_WIDTH.getName(), extractSize(metadata.get(EXIF_IMAGE_WIDTH_TAG)), properties);
putRawValue(JPEG_IMAGE_HEIGHT_TAG, metadata.get(EXIF_IMAGE_HEIGHT_TAG), properties);
putRawValue(JPEG_IMAGE_WIDTH_TAG, metadata.get(EXIF_IMAGE_WIDTH_TAG), properties);
putRawValue(TIFF.IMAGE_LENGTH.getName(), extractSize(metadata.get(JPEG_IMAGE_HEIGHT_TAG)), properties);
putRawValue(TIFF.IMAGE_WIDTH.getName(), extractSize(metadata.get(JPEG_IMAGE_WIDTH_TAG)), properties);
}
}
return properties;

View File

@@ -23,7 +23,7 @@
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.repo.domain.permissions;
package org.alfresco.repo.domain.permissions;
import java.io.Serializable;
import java.util.ArrayList;
@@ -392,8 +392,20 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
{
return;
}
else
{
else
{
// When node is copied when the aspect is applied, the sharedACLtoReplace will not match the children's ACLS
// to replace, we need to use the current one.
Long currentAcl = nodeDAO.getNodeAclId(nodeId);
if (nodeDAO.hasNodeAspect(nodeId, ContentModel.ASPECT_PENDING_FIX_ACL))
{
// If node has a pending acl, retrieve the sharedAclToReplace from node property. When the job calls
// this, it already does it but on move and copy operations, it uses the new parents old ACL.
sharedAclToReplace = (Long) nodeDAO.getNodeProperty(nodeId, ContentModel.PROP_SHARED_ACL_TO_REPLACE);
}
// Lazily retrieve/create the shared ACL
if (mergeFrom == null)
{
@@ -405,33 +417,26 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
nodeDAO.setNodeAclId(nodeId, mergeFrom);
}
List<NodeIdAndAclId> children = nodeDAO.getPrimaryChildrenAcls(nodeId);
if(children.size() > 0)
{
nodeDAO.setPrimaryChildrenSharedAclId(nodeId, sharedAclToReplace, mergeFrom);
}
List<NodeIdAndAclId> children = nodeDAO.getPrimaryChildrenAcls(nodeId);
if (!propagateOnChildren)
{
return;
}
}
for (NodeIdAndAclId child : children)
{
Long acl = child.getAclId();
{
//Use the current ACL instead of the stored value, it could've been changed meanwhile
Long acl = nodeDAO.getNodeAclId(child.getId());
if (acl == null)
{
propagateOnChildren = setFixAclPending(child.getId(), inheritFrom, mergeFrom, sharedAclToReplace, changes, false, asyncCall, propagateOnChildren);
}
else
{
// if(acl.equals(mergeFrom))
// {
// setFixedAcls(child.getId(), inheritFrom, mergeFrom, sharedAclToReplace, changes, false);
// }
// Already replaced
if(acl.equals(sharedAclToReplace))
// Still has old shared ACL or already replaced
if(acl.equals(sharedAclToReplace) || acl.equals(mergeFrom) || acl.equals(currentAcl))
{
propagateOnChildren = setFixAclPending(child.getId(), inheritFrom, mergeFrom, sharedAclToReplace, changes, false, asyncCall, propagateOnChildren);
}
@@ -456,7 +461,22 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
}
}
}
}
}
// By doing an eager update of the direct children we canot see if another thread has changed the ACL
// between the time we get the child nodes and we update them. By updating the direct children last it is
// possible to verify if any child has changed meanwhile.
if(children.size() > 0)
{
nodeDAO.setPrimaryChildrenSharedAclId(nodeId, sharedAclToReplace, mergeFrom);
}
// When this is not executed triggered by the job, but a move or copy operation occures on a pending
// node, we don't want to apply the OLD ACL that was pending
if(nodeDAO.hasNodeAspect(nodeId, ContentModel.ASPECT_PENDING_FIX_ACL))
{
removePendingAclAspect(nodeId);
}
}
}
@@ -509,25 +529,45 @@ public class ADMAccessControlListDAO implements AccessControlListDAO
}
// set ASPECT_PENDING_FIX_ACL aspect on node to be later on processed with FixedAclUpdater amd switch flag
// FIXED_ACL_ASYNC_REQUIRED_KEY
addFixedAclPendingAspect(nodeId, sharedAclToReplace, inheritFrom);
addFixedAclPendingAspect(nodeId, sharedAclToReplace, inheritFrom, mergeFrom);
AlfrescoTransactionSupport.bindResource(FixedAclUpdater.FIXED_ACL_ASYNC_REQUIRED_KEY, true);
// stop propagating on children nodes
return false;
}
private void addFixedAclPendingAspect(Long nodeId, Long sharedAclToReplace, Long inheritFrom)
{
Set<QName> aspect = new HashSet<>();
aspect.add(ContentModel.ASPECT_PENDING_FIX_ACL);
nodeDAO.addNodeAspects(nodeId, aspect);
Map<QName, Serializable> pendingAclProperties = new HashMap<>();
pendingAclProperties.put(ContentModel.PROP_SHARED_ACL_TO_REPLACE, sharedAclToReplace);
pendingAclProperties.put(ContentModel.PROP_INHERIT_FROM_ACL, inheritFrom);
nodeDAO.addNodeProperties(nodeId, pendingAclProperties);
if (log.isDebugEnabled())
{
log.debug("Set Fixed Acl Pending : " + nodeId + " " + nodeDAO.getNodePair(nodeId).getSecond());
private void addFixedAclPendingAspect(Long nodeId, Long sharedAclToReplace, Long inheritFrom, Long mergeFrom)
{
//If the node already has the pending ACL aspect, just update the new inheritFrom value
if (nodeDAO.hasNodeAspect(nodeId, ContentModel.ASPECT_PENDING_FIX_ACL))
{
Map<QName, Serializable> pendingAclProperties = new HashMap<>();
pendingAclProperties.put(ContentModel.PROP_INHERIT_FROM_ACL, inheritFrom);
nodeDAO.addNodeProperties(nodeId, pendingAclProperties);
return;
}
Set<QName> aspect = new HashSet<>();
aspect.add(ContentModel.ASPECT_PENDING_FIX_ACL);
nodeDAO.addNodeAspects(nodeId, aspect);
Map<QName, Serializable> pendingAclProperties = new HashMap<>();
pendingAclProperties.put(ContentModel.PROP_SHARED_ACL_TO_REPLACE, sharedAclToReplace);
pendingAclProperties.put(ContentModel.PROP_INHERIT_FROM_ACL, inheritFrom);
nodeDAO.addNodeProperties(nodeId, pendingAclProperties);
if (log.isDebugEnabled())
{
log.debug("Set Fixed Acl Pending : " + nodeId + " " + nodeDAO.getNodePair(nodeId).getSecond());
}
}
public void removePendingAclAspect(Long nodeId)
{
Set<QName> aspects = new HashSet<>(1);
aspects.add(ContentModel.ASPECT_PENDING_FIX_ACL);
Set<QName> pendingFixAclProperties = new HashSet<>();
pendingFixAclProperties.add(ContentModel.PROP_SHARED_ACL_TO_REPLACE);
pendingFixAclProperties.add(ContentModel.PROP_INHERIT_FROM_ACL);
nodeDAO.removeNodeAspects(nodeId, aspects);
nodeDAO.removeNodeProperties(nodeId, pendingFixAclProperties);
}
/**

View File

@@ -105,5 +105,7 @@ public interface AccessControlListDAO
public void updateInheritance(Long childNodeId, Long oldParentAclId, Long newParentAclId);
public void setFixedAcls(Long nodeId, Long inheritFrom, Long mergeFrom, Long sharedAclToReplace, List<AclChange> changes, boolean set);
public void setFixedAcls(Long nodeId, Long inheritFrom, Long mergeFrom, Long sharedAclToReplace, List<AclChange> changes, boolean set);
public void removePendingAclAspect(Long nodeId);
}

View File

@@ -53,6 +53,7 @@ import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.repo.transaction.TransactionListenerAdapter;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.StoreRef;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.alfresco.service.transaction.TransactionService;
@@ -91,8 +92,8 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
private int maxItemBatchSize = 100;
private int numThreads = 4;
private ClassPolicyDelegate<OnInheritPermissionsDisabled> onInheritPermissionsDisabledDelegate;
private PolicyComponent policyComponent;
private ClassPolicyDelegate<OnInheritPermissionsDisabled> onInheritPermissionsDisabledDelegate;
private PolicyComponent policyComponent;
private PolicyIgnoreUtil policyIgnoreUtil;
public void setNumThreads(int numThreads)
@@ -135,8 +136,8 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
{
this.lockTimeToLive = lockTimeToLive;
this.lockRefreshTime = lockTimeToLive / 2;
}
}
public void setPolicyComponent(PolicyComponent policyComponent)
{
this.policyComponent = policyComponent;
@@ -149,7 +150,8 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
public void init()
{
onInheritPermissionsDisabledDelegate = policyComponent.registerClassPolicy(PermissionServicePolicies.OnInheritPermissionsDisabled.class);
onInheritPermissionsDisabledDelegate = policyComponent
.registerClassPolicy(PermissionServicePolicies.OnInheritPermissionsDisabled.class);
}
private class GetNodesWithAspects
@@ -262,26 +264,34 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
{
log.debug(String.format("Processing node %s", nodeRef));
}
final Long nodeId = nodeDAO.getNodePair(nodeRef).getFirst();
// MNT-22009 - If node was deleted and in archive store, remove the aspect and properties and do not
// process
if (nodeRef.getStoreRef().equals(StoreRef.STORE_REF_ARCHIVE_SPACESSTORE))
{
accessControlListDAO.removePendingAclAspect(nodeId);
return null;
}
// retrieve acl properties from node
Long inheritFrom = (Long) nodeDAO.getNodeProperty(nodeId,
ContentModel.PROP_INHERIT_FROM_ACL);
Long sharedAclToReplace = (Long) nodeDAO.getNodeProperty(nodeId,
ContentModel.PROP_SHARED_ACL_TO_REPLACE);
Long inheritFrom = (Long) nodeDAO.getNodeProperty(nodeId, ContentModel.PROP_INHERIT_FROM_ACL);
Long sharedAclToReplace = (Long) nodeDAO.getNodeProperty(nodeId, ContentModel.PROP_SHARED_ACL_TO_REPLACE);
// set inheritance using retrieved prop
accessControlListDAO.setInheritanceForChildren(nodeRef, inheritFrom, sharedAclToReplace,
true);
accessControlListDAO.setInheritanceForChildren(nodeRef, inheritFrom, sharedAclToReplace, true);
// Remove aspect
accessControlListDAO.removePendingAclAspect(nodeId);
nodeDAO.removeNodeAspects(nodeId, aspects);
nodeDAO.removeNodeProperties(nodeId, PENDING_FIX_ACL_ASPECT_PROPS);
if (!policyIgnoreUtil.ignorePolicy(nodeRef))
{
boolean transformedToAsyncOperation = toBoolean((Boolean) AlfrescoTransactionSupport.getResource(FixedAclUpdater.FIXED_ACL_ASYNC_REQUIRED_KEY));
boolean transformedToAsyncOperation = toBoolean(
(Boolean) AlfrescoTransactionSupport.getResource(FixedAclUpdater.FIXED_ACL_ASYNC_REQUIRED_KEY));
OnInheritPermissionsDisabled onInheritPermissionsDisabledPolicy = onInheritPermissionsDisabledDelegate.get(ContentModel.TYPE_BASE);
OnInheritPermissionsDisabled onInheritPermissionsDisabledPolicy = onInheritPermissionsDisabledDelegate
.get(ContentModel.TYPE_BASE);
onInheritPermissionsDisabledPolicy.onInheritPermissionsDisabled(nodeRef, transformedToAsyncOperation);
}
@@ -395,12 +405,8 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
AclWorkProvider provider = new AclWorkProvider();
AclWorker worker = new AclWorker();
BatchProcessor<NodeRef> bp = new BatchProcessor<>(
"FixedAclUpdater",
transactionService.getRetryingTransactionHelper(),
provider,
numThreads, maxItemBatchSize,
applicationContext,
BatchProcessor<NodeRef> bp = new BatchProcessor<>("FixedAclUpdater",
transactionService.getRetryingTransactionHelper(), provider, numThreads, maxItemBatchSize, applicationContext,
log, 100);
int count = bp.process(worker, true);
return count;
@@ -413,7 +419,7 @@ public class FixedAclUpdater extends TransactionListenerAdapter implements Appli
finally
{
jobLockRefreshCallback.isActive.set(false);
if(lockToken != null)
if (lockToken != null)
{
jobLockService.releaseLock(lockToken, lockQName);
}

View File

@@ -179,7 +179,9 @@ CREATE TABLE alf_transaction
change_txn_id VARCHAR(56) NOT NULL,
commit_time_ms BIGINT,
PRIMARY KEY (id),
KEY idx_alf_txn_ctms (commit_time_ms),
KEY idx_alf_txn_ctms (commit_time_ms, id),
KEY idx_alf_txn_ctms_sc (commit_time_ms),
KEY idx_alf_txn_id_ctms (id, commit_time_ms),
KEY fk_alf_txn_svr (server_id),
CONSTRAINT fk_alf_txn_svr FOREIGN KEY (server_id) REFERENCES alf_server (id)
) ENGINE=InnoDB;
@@ -222,6 +224,8 @@ CREATE TABLE alf_node
KEY idx_alf_node_crd (audit_created, store_id, type_qname_id),
KEY idx_alf_node_mor (audit_modifier, store_id, type_qname_id),
KEY idx_alf_node_mod (audit_modified, store_id, type_qname_id),
KEY idx_alf_node_ver (version),
KEY idx_alf_node_txn (transaction_id),
CONSTRAINT fk_alf_node_acl FOREIGN KEY (acl_id) REFERENCES alf_access_control_list (id),
CONSTRAINT fk_alf_node_store FOREIGN KEY (store_id) REFERENCES alf_store (id),
CONSTRAINT fk_alf_node_tqn FOREIGN KEY (type_qname_id) REFERENCES alf_qname (id),

View File

@@ -1681,6 +1681,16 @@
<columnname>type_qname_id</columnname>
</columnnames>
</index>
<index name="idx_alf_node_ver" unique="false">
<columnnames>
<columnname>version</columnname>
</columnnames>
</index>
<index name="idx_alf_node_txn" unique="false">
<columnnames>
<columnname>transaction_id</columnname>
</columnnames>
</index>
</indexes>
</table>
<table name="alf_node_aspects">
@@ -2674,6 +2684,18 @@
<index name="idx_alf_txn_ctms" unique="false">
<columnnames>
<columnname>commit_time_ms</columnname>
<columnname>id</columnname>
</columnnames>
</index>
<index name="idx_alf_txn_ctms_sc" unique="false">
<columnnames>
<columnname>commit_time_ms</columnname>
</columnnames>
</index>
<index name="idx_alf_txn_id_ctms" unique="false">
<columnnames>
<columnname>id</columnname>
<columnname>commit_time_ms</columnname>
</columnnames>
</index>
<index name="fk_alf_txn_svr" unique="false">

View File

@@ -196,6 +196,8 @@ CREATE TABLE alf_transaction
CONSTRAINT fk_alf_txn_svr FOREIGN KEY (server_id) REFERENCES alf_server (id)
);
CREATE INDEX idx_alf_txn_ctms ON alf_transaction (commit_time_ms, id);
CREATE INDEX idx_alf_txn_ctms_sc ON alf_transaction (commit_time_ms);
CREATE INDEX idx_alf_txn_id_ctms ON alf_transaction (id, commit_time_ms);
CREATE INDEX fk_alf_txn_svr ON alf_transaction (server_id);
CREATE SEQUENCE alf_store_seq START WITH 1 INCREMENT BY 1;
@@ -244,6 +246,8 @@ CREATE INDEX fk_alf_node_acl ON alf_node (acl_id);
CREATE INDEX fk_alf_node_store ON alf_node (store_id);
CREATE INDEX idx_alf_node_tqn ON alf_node (type_qname_id, store_id, id);
CREATE INDEX fk_alf_node_loc ON alf_node (locale_id);
CREATE INDEX idx_alf_node_ver ON alf_node (version);
CREATE INDEX idx_alf_node_txn ON alf_node (transaction_id);
CREATE INDEX fk_alf_store_root ON alf_store (root_node_id);
ALTER TABLE alf_store ADD CONSTRAINT fk_alf_store_root FOREIGN KEY (root_node_id) REFERENCES alf_node (id);

View File

@@ -1740,6 +1740,16 @@
<columnname>id</columnname>
</columnnames>
</index>
<index name="idx_alf_node_ver" unique="false">
<columnnames>
<columnname>version</columnname>
</columnnames>
</index>
<index name="idx_alf_node_txn" unique="false">
<columnnames>
<columnname>transaction_id</columnname>
</columnnames>
</index>
</indexes>
</table>
<table name="alf_node_aspects">
@@ -2753,6 +2763,17 @@
<columnname>id</columnname>
</columnnames>
</index>
<index name="idx_alf_txn_ctms_sc" unique="false">
<columnnames>
<columnname>commit_time_ms</columnname>
</columnnames>
</index>
<index name="idx_alf_txn_id_ctms" unique="false">
<columnnames>
<columnname>id</columnname>
<columnname>commit_time_ms</columnname>
</columnnames>
</index>
</indexes>
</table>
<table name="alf_usage_delta">

View File

@@ -54,6 +54,7 @@
<ref bean="patch.db-V5.1-metadata-query-indexes" />
<ref bean="patch.db-V5.2-remove-jbpm-tables-from-db" />
<ref bean="patch.db-V6.0-change-set-indexes" />
<ref bean="patch.db-V6.3-add-indexes-node-transaction" />
</list>
</property>
</bean>

View File

@@ -0,0 +1,35 @@
--
-- Title: Update alf_node and alf_transaction indexes for more performance
-- Database: MySQL
-- Since: V6.3
-- Author: Eva Vasques
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
DROP INDEX idx_alf_node_ver; --(optional)
CREATE INDEX idx_alf_node_ver ON alf_node (version);
DROP INDEX idx_alf_node_txn; --(optional)
CREATE INDEX idx_alf_node_txn ON alf_node (transaction_id);
DROP INDEX idx_alf_txn_ctms; --(optional)
CREATE INDEX idx_alf_txn_ctms ON alf_transaction (commit_time_ms, id);
DROP INDEX idx_alf_txn_ctms_sc; --(optional)
CREATE INDEX idx_alf_txn_ctms_sc ON alf_transaction (commit_time_ms);
DROP INDEX idx_alf_txn_id_ctms; --(optional)
CREATE INDEX idx_alf_txn_id_ctms ON alf_transaction (id, commit_time_ms);
--
-- Record script finish
--
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V6.3-add-indexes-node-transaction';
INSERT INTO alf_applied_patch
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
VALUES
(
'patch.db-V6.3-add-indexes-node-transaction', 'Create aditional indexes on alf_node and alf_transaction',
0, 13005, -1, 13006, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
);

View File

@@ -0,0 +1,32 @@
--
-- Title: Update alf_node and alf_transaction indexes for more performance
-- Database: PostgreSQL
-- Since: V6.3
-- Author: Eva Vasques
--
-- Please contact support@alfresco.com if you need assistance with the upgrade.
--
DROP INDEX idx_alf_node_ver; --(optional)
CREATE INDEX idx_alf_node_ver ON alf_node (version);
DROP INDEX idx_alf_node_txn; --(optional)
CREATE INDEX idx_alf_node_txn ON alf_node (transaction_id);
DROP INDEX idx_alf_txn_ctms_sc; --(optional)
CREATE INDEX idx_alf_txn_ctms_sc ON alf_transaction (commit_time_ms);
DROP INDEX idx_alf_txn_id_ctms; --(optional)
CREATE INDEX idx_alf_txn_id_ctms ON alf_transaction (id, commit_time_ms);
--
-- Record script finish
--
DELETE FROM alf_applied_patch WHERE id = 'patch.db-V6.3-add-indexes-node-transaction';
INSERT INTO alf_applied_patch
(id, description, fixes_from_schema, fixes_to_schema, applied_to_schema, target_schema, applied_on_date, applied_to_server, was_executed, succeeded, report)
VALUES
(
'patch.db-V6.3-add-indexes-node-transaction', 'Create aditional indexes on alf_node and alf_transaction',
0, 13005, -1, 13006, null, 'UNKNOWN', ${TRUE}, ${TRUE}, 'Script completed'
);

View File

@@ -15,12 +15,10 @@
</bean>
<bean id="keyStoreParameters" class="org.alfresco.encryption.KeyStoreParameters" init-method="init">
<property name="id" value="metadata-keystore"/>
<property name="name" value="Key Store"/>
<property name="location" value="${encryption.keystore.location}"/>
<property name="provider" value="${encryption.keystore.provider}"/>
<property name="type" value="${encryption.keystore.type}"/>
<!-- This property is left for backwards compatibility -->
<property name="keyMetaDataFileLocation" value="${encryption.keystore.keyMetaData.location}"/>
</bean>
@@ -32,22 +30,18 @@
<!-- TODO i18n for key store names -->
<bean id="sslKeyStoreParameters" class="org.alfresco.encryption.KeyStoreParameters" init-method="init">
<property name="id" value="ssl-keystore"/>
<property name="name" value="SSL Key Store"/>
<property name="location" value="${encryption.ssl.keystore.location}"/>
<property name="type" value="${encryption.ssl.keystore.type}"/>
<property name="provider" value="${encryption.ssl.keystore.provider}"/>
<!-- This property is left for backwards compatibility -->
<property name="keyMetaDataFileLocation" value="${encryption.ssl.keystore.keyMetaData.location}"/>
</bean>
<bean id="sslTrustStoreParameters" class="org.alfresco.encryption.KeyStoreParameters" init-method="init">
<property name="id" value="ssl-truststore"/>
<property name="name" value="SSL Trust Store"/>
<property name="location" value="${encryption.ssl.truststore.location}"/>
<property name="type" value="${encryption.ssl.truststore.type}"/>
<property name="provider" value="${encryption.ssl.truststore.provider}"/>
<!-- This property is left for backwards compatibility -->
<property name="keyMetaDataFileLocation" value="${encryption.ssl.truststore.keyMetaData.location}"/>
</bean>
@@ -77,12 +71,10 @@
</bean>
<bean id="backupKeyStoreParameters" class="org.alfresco.encryption.KeyStoreParameters" init-method="init">
<property name="id" value="metadata-backup-keystore"/>
<property name="name" value="Backup Key Store"/>
<property name="location" value="${encryption.keystore.backup.location}"/>
<property name="provider" value="${encryption.keystore.backup.provider}"/>
<property name="type" value="${encryption.keystore.backup.type}"/>
<!-- This property is left for backwards compatibility -->
<property name="keyMetaDataFileLocation" value="${encryption.keystore.backup.keyMetaData.location}"/>
</bean>

View File

@@ -1,10 +1,7 @@
# This file and the keystore is deprecated
# Please generate a new keystore for new systems and use JVM properties for it's configuration
aliases=metadata
# The password protecting the keystore entries
keystore.password=mp6yc0UD9e
# The password protecting the alias: metadata
metadata.keyData=
metadata.algorithm=DESede
aliases=metadata
# The password protecting the keystore entries
keystore.password=mp6yc0UD9e
# The password protecting the alias: metadata
metadata.keyData=
metadata.algorithm=DESede
metadata.password=oKIWzVdEdA

View File

@@ -400,4 +400,6 @@ patch.updateAdminUserWhenDefault.result=\n\Successfully removed password2 proper
patch.db-V5.2-remove-jbpm-tables-from-db.description=Removes all JBPM related tables from the database.
patch.db-V6.0-change-set-indexes.description=Add additional indexes to support acl tracking.
patch.db-V6.0-change-set-indexes.description=Add additional indexes to support acl tracking.
patch.db-V6.3-add-indexes-node-transaction.description=Create additional indexes on alf_node and alf_transaction

View File

@@ -1397,5 +1397,17 @@
<value>classpath:alfresco/dbscripts/upgrade/6.0/${db.script.dialect}/change-set-indexes.sql</value>
</property>
</bean>
<bean id="patch.db-V6.3-add-indexes-node-transaction" class="org.alfresco.repo.admin.patch.impl.SchemaUpgradeScriptPatch" parent="basePatch">
<property name="id"><value>patch.db-V6.3-add-indexes-node-transaction</value></property>
<property name="description"><value>patch.db-V6.3-add-indexes-node-transaction.description</value></property>
<property name="fixesFromSchema"><value>0</value></property>
<property name="fixesToSchema"><value>13005</value></property>
<property name="targetSchema"><value>13006</value></property>
<property name="ignored"><value>${system.new-node-transaction-indexes.ignored}</value></property>
<property name="scriptUrl">
<value>classpath:alfresco/dbscripts/upgrade/6.3/${db.script.dialect}/add-indexes-node-transaction.sql</value>
</property>
</bean>
</beans>

View File

@@ -3,7 +3,7 @@
repository.name=Main Repository
# Schema number
version.schema=13010
version.schema=13006
# Directory configuration
@@ -816,22 +816,20 @@ dir.keystore=classpath:alfresco/keystore
# general encryption parameters
encryption.keySpec.class=org.alfresco.encryption.DESEDEKeyGenerator
encryption.keyAlgorithm=AES
encryption.cipherAlgorithm=AES/CBC/PKCS5Padding
encryption.keyAlgorithm=DESede
encryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
# secret key keystore configuration
encryption.keystore.location=${dir.keystore}/keystore
# configuration via metadata is deprecated
encryption.keystore.keyMetaData.location=
encryption.keystore.keyMetaData.location=${dir.keystore}/keystore-passwords.properties
encryption.keystore.provider=
encryption.keystore.type=pkcs12
encryption.keystore.type=JCEKS
# backup secret key keystore configuration
encryption.keystore.backup.location=${dir.keystore}/backup-keystore
# configuration via metadata is deprecated
encryption.keystore.backup.keyMetaData.location=
encryption.keystore.backup.keyMetaData.location=${dir.keystore}/backup-keystore-passwords.properties
encryption.keystore.backup.provider=
encryption.keystore.backup.type=pkcs12
encryption.keystore.backup.type=JCEKS
# Should encryptable properties be re-encrypted with new encryption keys on botstrap?
encryption.bootstrap.reencrypt=false
@@ -844,13 +842,11 @@ encryption.mac.algorithm=HmacSHA1
encryption.ssl.keystore.location=${dir.keystore}/ssl.keystore
encryption.ssl.keystore.provider=
encryption.ssl.keystore.type=JCEKS
# configuration via metadata is deprecated
encryption.ssl.keystore.keyMetaData.location=
encryption.ssl.keystore.keyMetaData.location=${dir.keystore}/ssl-keystore-passwords.properties
encryption.ssl.truststore.location=${dir.keystore}/ssl.truststore
encryption.ssl.truststore.provider=
encryption.ssl.truststore.type=JCEKS
# configuration via metadata is deprecated
encryption.ssl.truststore.keyMetaData.location=
encryption.ssl.truststore.keyMetaData.location=${dir.keystore}/ssl-truststore-passwords.properties
# Re-encryptor properties
encryption.reencryptor.chunkSize=100
@@ -1317,3 +1313,6 @@ system.delete_not_exists.delete_batchsize=1000
system.delete_not_exists.read_only=false
system.delete_not_exists.timeout_seconds=-1
system.prop_table_cleaner.algorithm=V2
# Creates additional indexes on alf_node and alf_transaction. Recommended for large repositories.
system.new-node-transaction-indexes.ignored=true

View File

@@ -65,9 +65,6 @@ import org.junit.runners.Suite;
org.alfresco.repo.content.filestore.ReadOnlyFileContentStoreTest.class,
org.alfresco.repo.content.RoutingContentStoreTest.class,
org.alfresco.encryption.EncryptionTests.class,
org.alfresco.encryption.KeyStoreTests.class
// TODO REPO-2791 org.alfresco.repo.content.routing.StoreSelectorAspectContentStoreTest.class,
})
public class AppContext02TestSuite

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.encryption;
import java.io.Serializable;
@@ -270,6 +270,28 @@ public class EncryptionTests extends TestCase
mainEncryptor.setKeyProvider(mainKeyProvider);
}
}
public void testBootstrapReEncrypt()
{
try
{
// ensure that the backup key store is not available
backupKeyStoreParameters.setLocation("");
//backupKeyStore.reload();
mainKeyStore.reload();
reEncryptor.bootstrapReEncrypt();
fail("Should have caught missing backup key store");
}
catch(MissingKeyException e)
{
System.out.println("Successfully caught missing key exception");
}
catch(InvalidKeystoreException e)
{
fail("Unexpected exception: " + e.getMessage());
}
}
protected void testChangeKeysImpl(boolean cacheCiphers) throws Throwable
{

View File

@@ -1,28 +1,28 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L%
*/
package org.alfresco.encryption;
import static org.junit.Assert.assertTrue;
@@ -37,7 +37,6 @@ import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -213,7 +212,7 @@ public class KeyStoreTests
TestAlfrescoKeyStore missingMainKeyStore = getKeyStore("main", "JCEKS", Collections.singletonMap(KeyProvider.ALIAS_METADATA, "metadata"),
Collections.singletonMap(KeyProvider.ALIAS_METADATA, generateEncodedKey()), generateKeystoreName(), generateKeystoreName());
missingMainKeyStore.setKeysToValidate(new HashSet<>(Collections.singletonList("metadata")));
encryptionKeysRegistry.unregisterKey(KeyProvider.ALIAS_METADATA);
keyStoreChecker.setMainKeyStore(missingMainKeyStore);
@@ -241,7 +240,7 @@ public class KeyStoreTests
// missing main keystore, missing backup keystore, metadata registered key -> error, re-instate the keystore
TestAlfrescoKeyStore missingMainKeyStore = getKeyStore("main", "JCEKS", Collections.singletonMap(KeyProvider.ALIAS_METADATA, "metadata"),
null, generateKeystoreName(), generateKeystoreName());
missingMainKeyStore.setKeysToValidate(new HashSet<>(Collections.singletonList("metadata")));
assertTrue("", encryptionKeysRegistry.isKeyRegistered("metadata"));
keyStoreChecker.setMainKeyStore(missingMainKeyStore);
@@ -269,7 +268,6 @@ public class KeyStoreTests
// create main keystore
TestAlfrescoKeyStore mainKeyStore = getKeyStore("main", "JCEKS", Collections.singletonMap(KeyProvider.ALIAS_METADATA, "metadata"),
null, generateKeystoreName(), generateKeystoreName());
mainKeyStore.setKeysToValidate(new HashSet<>(Collections.singletonList("metadata")));
createAndPopulateKeyStore(mainKeyStore);
// de-register metadata key
@@ -305,7 +303,6 @@ public class KeyStoreTests
TestAlfrescoKeyStore keyStore = getKeyStore("main", "JCEKS", Collections.singletonMap(KeyProvider.ALIAS_METADATA, "metadata"),
null, generateKeystoreName(), generateKeystoreName());
keyStore.setKeysToValidate(new HashSet<>(Collections.singletonList("metadata")));
createAndPopulateKeyStore(keyStore);
keyStoreChecker.setMainKeyStore(keyStore);
@@ -361,7 +358,6 @@ public class KeyStoreTests
TestAlfrescoKeyStore keyStore = getKeyStore("main", "JCEKS", Collections.singletonMap(KeyProvider.ALIAS_METADATA, "metadata"),
null, generateKeystoreName(), generateKeystoreName());
keyStore.setKeysToValidate(new HashSet<>(Collections.singletonList("metadata")));
createAndPopulateKeyStore(keyStore);
try

View File

@@ -34,7 +34,6 @@ import java.io.Serializable;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Properties;
@@ -85,7 +84,6 @@ import org.alfresco.util.testing.category.LuceneTests;
import org.alfresco.util.testing.category.RedundantTests;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.ClassPathResource;
@@ -398,73 +396,8 @@ public class ImapMessageTest extends TestCase
}
}
@Test
public void testSearchTermWithNonEnglishLocale() throws Exception
{
folder = (IMAPFolder) store.getFolder(TEST_FOLDER);
folder.open(Folder.READ_ONLY);
Locale defaultLocale = Locale.getDefault();
try
{
Locale.setDefault(Locale.FRENCH);
String dateStr = "12-Jul-2020";
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand()
{
@Override
public Object doCommand(IMAPProtocol protocol)
{
return protocol.command("UID SEARCH SINCE " + dateStr, null);
}
};
// UID SEARCH SINCE
Response[] ret = (Response[]) folder.doCommand(uid_search_since);
IMAPResponse response = (IMAPResponse) ret[0];
assertEquals("* SEARCH ", response.toString());
}
catch (MessagingException e)
{
fail("Date cannot be parsed");
}
finally
{
Locale.setDefault(defaultLocale);
}
}
@Test
public void testSearchTermWithNonEnglishLocaleFalsePositive() throws Exception
{
Locale defaultLocale = Locale.getDefault();
try
{
folder = (IMAPFolder) store.getFolder(TEST_FOLDER);
folder.open(Folder.READ_ONLY);
Locale.setDefault(Locale.FRENCH);
String dateStr = "12-juil.-2020";
final IMAPFolder.ProtocolCommand uid_search_since = new IMAPFolder.ProtocolCommand()
{
@Override
public Object doCommand(IMAPProtocol protocol)
{
return protocol.command("UID SEARCH SINCE " + dateStr, null);
}
};
// UID SEARCH SINCE
Response[] ret = (Response[]) folder.doCommand(uid_search_since);
assertEquals("java.net.SocketException: Connection reset", ret[0].getException().toString());
}
catch (MessagingException e)
{
// expected
}
finally
{
Locale.setDefault(defaultLocale);
}
}
public void testUnmodifiedMessage() throws Exception
{
// Get test message UID
@@ -840,7 +773,7 @@ public class ImapMessageTest extends TestCase
txn.commit();
// Closing client connection
folder.forceClose();
folder.close(false);
store.close();
logger.debug("tearDown end");
}

View File

@@ -1151,7 +1151,7 @@ public class ImapServiceImplTest extends TestCase
* MNT-12773
* @throws AddressException
*/
public void testSearchTerms() throws AddressException
public void testSearchTerms() throws AddressException
{
List<AlfrescoImapFolder> mf = imapService.listMailboxes(user, IMAP_ROOT+"/"+TEST_IMAP_FOLDER_NAME+"/_*", false);
ArrayList<Long> res = new ArrayList<Long>();

View File

@@ -1716,6 +1716,62 @@ public class AuthorityServiceTest extends TestCase
; // expected
}
}
public void testIfGroupIsAdminAuthority()
{
String adminGroup = "GROUP_ALFRESCO_ADMINISTRATORS";
String parentGroup = "parentGroup";
String subGroup1 = "subGroup1";
String subGroup2 = "subGroup2";
String username = "johnsnow";
HashMap<QName, Serializable> properties = new HashMap<>();
properties.put(ContentModel.PROP_USERNAME, username);
personService.createPerson(properties);
pubAuthorityService.createAuthority(AuthorityType.GROUP, parentGroup);
pubAuthorityService.createAuthority(AuthorityType.GROUP, subGroup1);
pubAuthorityService.createAuthority(AuthorityType.GROUP, subGroup2);
// Verify it can identify GROUP_ALFRESCO_ADMINISTRATORS as an admin group
assertTrue(pubAuthorityService.isAdminAuthority(adminGroup));
// Verify the created groups and users are not administrators
assertFalse(pubAuthorityService.isAdminAuthority(pubAuthorityService.getName(AuthorityType.GROUP, parentGroup)));
assertFalse(pubAuthorityService.isAdminAuthority(pubAuthorityService.getName(AuthorityType.GROUP, subGroup1)));
assertFalse(pubAuthorityService.isAdminAuthority(pubAuthorityService.getName(AuthorityType.GROUP, subGroup2)));
assertFalse(pubAuthorityService.isAdminAuthority(username));
// Add a subgroup to the parent group and verify if its still identified as non admin
pubAuthorityService.addAuthority(pubAuthorityService.getName(AuthorityType.GROUP, parentGroup),
pubAuthorityService.getName(AuthorityType.GROUP, subGroup1));
assertFalse(pubAuthorityService.isAdminAuthority(pubAuthorityService.getName(AuthorityType.GROUP, parentGroup)));
assertFalse(pubAuthorityService.isAdminAuthority(pubAuthorityService.getName(AuthorityType.GROUP, subGroup1)));
// Add the group to the administrators group and if both group and subgroup are identified correctly as admins
pubAuthorityService.addAuthority(adminGroup, pubAuthorityService.getName(AuthorityType.GROUP, parentGroup));
assertTrue(pubAuthorityService.isAdminAuthority(pubAuthorityService.getName(AuthorityType.GROUP, parentGroup)));
assertTrue(pubAuthorityService.isAdminAuthority(pubAuthorityService.getName(AuthorityType.GROUP, subGroup1)));
// Add another subgroup to the parent group - the subgroup should automatically become an admin
pubAuthorityService.addAuthority(pubAuthorityService.getName(AuthorityType.GROUP, parentGroup),
pubAuthorityService.getName(AuthorityType.GROUP, subGroup2));
assertTrue(pubAuthorityService.isAdminAuthority(pubAuthorityService.getName(AuthorityType.GROUP, subGroup2)));
// Add the user to a subgroup and verify if he's an admin
pubAuthorityService.addAuthority(pubAuthorityService.getName(AuthorityType.GROUP, subGroup2), username);
assertTrue(pubAuthorityService.isAdminAuthority(username));
// Create a group with the same name as an admin user, group should not be identified as admin
pubAuthorityService.createAuthority(AuthorityType.GROUP, username);
assertFalse(pubAuthorityService.isAdminAuthority(pubAuthorityService.getName(AuthorityType.GROUP, username)));
//Cleanup created authorities
pubAuthorityService.deleteAuthority(pubAuthorityService.getName(AuthorityType.GROUP, parentGroup));
pubAuthorityService.deleteAuthority(pubAuthorityService.getName(AuthorityType.GROUP, subGroup1));
pubAuthorityService.deleteAuthority(pubAuthorityService.getName(AuthorityType.GROUP, subGroup2));
pubAuthorityService.deleteAuthority(pubAuthorityService.getName(AuthorityType.GROUP, username));
personService.deletePerson(username);
}
private <T extends Policy> T createClassPolicy(Class<T> policyInterface, QName policyQName, QName triggerOnClass)
{

View File

@@ -52,16 +52,9 @@ mimetype.config.cronExpression=0 0 0 ? JAN * 1970
rendition.config.cronExpression=0 0 0 ? JAN * 1970
local.transform.service.cronExpression=0 0 0 ? JAN * 1970
transform.service.cronExpression=0 0 0 ? JAN * 1970
system.delete_not_exists.batchsize=100000
system.delete_not_exists.delete_batchsize=1000
system.delete_not_exists.read_only=false
system.delete_not_exists.timeout_seconds=-1
system.prop_table_cleaner.algorithm=V2
# For testing only
encryption.keystore.keyMetaData.location=${dir.keystore}/keystore-passwords.properties
encryption.keyAlgorithm=DESede
encryption.cipherAlgorithm=DESede/CBC/PKCS5Padding
encryption.keystore.type=JCEKS
encryption.keystore.backup.type=JCEKS