mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
[PRODSEC-9364] added java-uuid-generator (#2778)
* [PRODSEC-9364] added java-uuid-generator * [PRODSEC-9364] addressed formatting issues * [PRODSEC-9364] removed unnecessary qualifier java.util * [PRODSEC-9364] removed addition import and change year in header
This commit is contained in:
@@ -47,11 +47,11 @@
|
||||
<artifactId>commons-math3</artifactId>
|
||||
<version>3.6.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.fasterxml.uuid/java-uuid-generator -->
|
||||
<dependency>
|
||||
<groupId>org.safehaus.jug</groupId>
|
||||
<artifactId>jug</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<classifier>asl</classifier>
|
||||
<groupId>com.fasterxml.uuid</groupId>
|
||||
<artifactId>java-uuid-generator</artifactId>
|
||||
<version>5.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.logging.log4j</groupId>
|
||||
|
@@ -21,7 +21,7 @@ package org.alfresco.util;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Random;
|
||||
|
||||
import org.safehaus.uuid.UUIDGenerator;
|
||||
import com.fasterxml.uuid.Generators;
|
||||
import org.alfresco.api.AlfrescoPublicApi;
|
||||
|
||||
/**
|
||||
@@ -69,7 +69,7 @@ public final class GUID
|
||||
public static String generate()
|
||||
{
|
||||
int randomInt = RANDOM.nextInt(SECURE_RANDOM_POOL_MAX_ITEMS);
|
||||
return UUIDGenerator.getInstance().generateRandomBasedUUID(SECURE_RANDOM_POOL[randomInt]).toString();
|
||||
return Generators.randomBasedGenerator(SECURE_RANDOM_POOL[randomInt]).generate().toString();
|
||||
}
|
||||
|
||||
// == Not sure if we need this functionality again (derekh) ==
|
||||
|
@@ -33,13 +33,13 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.zip.CRC32;
|
||||
|
||||
import com.fasterxml.uuid.Generators;
|
||||
import org.alfresco.repo.cache.SimpleCache;
|
||||
import org.alfresco.service.cmr.repository.datatype.Duration;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.codec.binary.Hex;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.safehaus.uuid.UUIDGenerator;
|
||||
import org.alfresco.util.ParameterCheck;
|
||||
|
||||
/**
|
||||
@@ -497,7 +497,7 @@ public class InMemoryTicketComponentImpl implements TicketComponent
|
||||
this.userName = userName;
|
||||
this.validDuration = validDuration;
|
||||
this.testDuration = validDuration.divide(2);
|
||||
final String guid = UUIDGenerator.getInstance().generateRandomBasedUUID().toString();
|
||||
final String guid = Generators.randomBasedGenerator().generate().toString();
|
||||
|
||||
this.ticketId = computeTicketId(expires, expiryDate, userName, guid);
|
||||
|
||||
|
@@ -84,7 +84,7 @@
|
||||
<include>org.alfresco:alfresco-core</include>
|
||||
<include>org.alfresco:alfresco-repository</include>
|
||||
<include>org.apache.commons:commons-compress</include>
|
||||
<include>org.safehaus.jug:jug</include>
|
||||
<include>com.fasterxml.uuid:java-uuid-generator</include>
|
||||
<include>org.alfresco.surf:spring-surf-core</include>
|
||||
<include>org.tukaani:xz</include>
|
||||
<include>org.apache.maven:maven-artifact</include>
|
||||
|
@@ -25,6 +25,7 @@
|
||||
*/
|
||||
package org.alfresco.repo.module.tool;
|
||||
|
||||
import com.fasterxml.uuid.Generators;
|
||||
import de.schlichtherle.truezip.file.*;
|
||||
import de.schlichtherle.truezip.fs.FsSyncException;
|
||||
import de.schlichtherle.truezip.fs.archive.zip.JarDriver;
|
||||
@@ -34,7 +35,6 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.module.ModuleVersionNumber;
|
||||
import org.alfresco.service.cmr.module.ModuleDetails;
|
||||
import org.alfresco.service.cmr.module.ModuleInstallState;
|
||||
import org.safehaus.uuid.UUIDGenerator;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
@@ -916,7 +916,7 @@ public class ModuleManagementTool implements LogOutput
|
||||
*/
|
||||
private static String generateGuid()
|
||||
{
|
||||
return UUIDGenerator.getInstance().generateTimeBasedUUID().toString();
|
||||
return Generators.timeBasedGenerator().generate().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -36,7 +36,10 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.fasterxml.uuid.Generators;
|
||||
import com.fasterxml.uuid.impl.UUIDUtil;
|
||||
import org.alfresco.sync.events.types.ActivityEvent;
|
||||
import org.alfresco.sync.events.types.Event;
|
||||
import org.alfresco.model.ContentModel;
|
||||
@@ -108,8 +111,6 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Interval;
|
||||
import org.joda.time.PeriodType;
|
||||
import org.safehaus.uuid.UUID;
|
||||
import org.safehaus.uuid.UUIDGenerator;
|
||||
|
||||
/**
|
||||
* QuickShare Service implementation.
|
||||
@@ -435,8 +436,8 @@ public class QuickShareServiceImpl implements QuickShareService,
|
||||
// If it is retura dto built from the existing properties.
|
||||
if (! nodeService.getAspects(nodeRef).contains(QuickShareModel.ASPECT_QSHARE))
|
||||
{
|
||||
UUID uuid = UUIDGenerator.getInstance().generateRandomBasedUUID();
|
||||
sharedId = Base64.encodeBase64URLSafeString(uuid.toByteArray()); // => 22 chars (eg. q3bEKPeDQvmJYgt4hJxOjw)
|
||||
UUID uuid = Generators.randomBasedGenerator().generate();
|
||||
sharedId = Base64.encodeBase64URLSafeString(UUIDUtil.asByteArray(uuid)); // => 22 chars (eg. q3bEKPeDQvmJYgt4hJxOjw)
|
||||
|
||||
final Map<QName, Serializable> props = new HashMap<QName, Serializable>(2);
|
||||
props.put(QuickShareModel.PROP_QSHARE_SHAREDID, sharedId);
|
||||
@@ -1246,7 +1247,7 @@ public class QuickShareServiceImpl implements QuickShareService,
|
||||
}
|
||||
|
||||
// Create the expiry action
|
||||
final QuickShareLinkExpiryAction expiryAction = new QuickShareLinkExpiryActionImpl(java.util.UUID.randomUUID().toString(), sharedId,
|
||||
final QuickShareLinkExpiryAction expiryAction = new QuickShareLinkExpiryActionImpl(UUID.randomUUID().toString(), sharedId,
|
||||
"QuickShare link expiry action");
|
||||
// Create the persisted schedule
|
||||
final ScheduledPersistedAction schedule = scheduledPersistedActionService.createSchedule(expiryAction);
|
||||
|
@@ -1,32 +1,33 @@
|
||||
/*
|
||||
* #%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 - 2024 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.repo.security.person;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.batch.BatchProcessor;
|
||||
@@ -41,7 +42,6 @@ import org.springframework.extensions.surf.util.AbstractLifecycleBean;
|
||||
import org.alfresco.util.GUID;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.safehaus.uuid.UUID;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
@@ -168,7 +168,7 @@ public class SplitPersonCleanupBootstrapBean extends AbstractLifecycleBean
|
||||
try
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
UUID id = new UUID(guidString);
|
||||
UUID id = UUID.fromString(guidString);
|
||||
// We have a valid guid.
|
||||
return true;
|
||||
}
|
||||
@@ -188,7 +188,7 @@ public class SplitPersonCleanupBootstrapBean extends AbstractLifecycleBean
|
||||
try
|
||||
{
|
||||
@SuppressWarnings("unused")
|
||||
UUID id = new UUID(guidString);
|
||||
UUID id = UUID.fromString(guidString);
|
||||
// We have a valid guid.
|
||||
return true;
|
||||
}
|
||||
|
@@ -37,7 +37,10 @@ import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.fasterxml.uuid.Generators;
|
||||
import com.fasterxml.uuid.impl.UUIDUtil;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.QuickShareModel;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
@@ -83,8 +86,6 @@ import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.experimental.categories.Category;
|
||||
import org.junit.rules.RuleChain;
|
||||
import org.safehaus.uuid.UUID;
|
||||
import org.safehaus.uuid.UUIDGenerator;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
|
||||
/**
|
||||
@@ -420,8 +421,8 @@ public class QuickShareServiceIntegrationTest
|
||||
|
||||
@Test(expected=InvalidSharedIdException.class) public void getMetadataFromShareIdWithInvalidId()
|
||||
{
|
||||
UUID uuid = UUIDGenerator.getInstance().generateRandomBasedUUID();
|
||||
String sharedId = Base64.encodeBase64URLSafeString(uuid.toByteArray()); // => 22 chars (eg. q3bEKPeDQvmJYgt4hJxOjw)
|
||||
UUID uuid = Generators.randomBasedGenerator().generate();
|
||||
String sharedId = Base64.encodeBase64URLSafeString(UUIDUtil.asByteArray(uuid)); // => 22 chars (eg. q3bEKPeDQvmJYgt4hJxOjw)
|
||||
|
||||
Map<String, Object> metadata = quickShareService.getMetaData(sharedId);
|
||||
}
|
||||
@@ -884,7 +885,7 @@ public class QuickShareServiceIntegrationTest
|
||||
{
|
||||
// Create a private site
|
||||
AuthenticationUtil.setFullyAuthenticatedUser(user1.getUsername());
|
||||
String randomUUID = UUIDGenerator.getInstance().generateRandomBasedUUID().toString();
|
||||
String randomUUID = Generators.randomBasedGenerator().generate().toString();
|
||||
String siteName = "testSite" + randomUUID;
|
||||
siteService.createSite("site-dashboard", siteName, "Title for " + siteName,
|
||||
"Description for " + siteName, SiteVisibility.PRIVATE);
|
||||
|
Reference in New Issue
Block a user