mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-10 03:23:13 +00:00
DS-3346 change and remove deprecated setIgnoreAuthorization in favour of turnOff/restore
This commit is contained in:
@@ -132,8 +132,8 @@ public class CommunityFiliator
|
||||
CommunityFiliator filiator = new CommunityFiliator();
|
||||
Context c = new Context();
|
||||
|
||||
// ve are superuser!
|
||||
c.setIgnoreAuthorization(true);
|
||||
// we are superuser!
|
||||
c.turnOffAuthorisationSystem();
|
||||
|
||||
try
|
||||
{
|
||||
|
@@ -237,7 +237,7 @@ public final class CreateAdministrator
|
||||
{
|
||||
// Of course we aren't an administrator yet so we need to
|
||||
// circumvent authorisation
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
// Find administrator group
|
||||
Group admins = groupService.findByName(context, Group.ADMIN);
|
||||
|
@@ -101,7 +101,7 @@ public class MetadataExporter
|
||||
{
|
||||
// create a context
|
||||
Context context = new Context();
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
OutputFormat xmlFormat = new OutputFormat(Method.XML, "UTF-8", true);
|
||||
xmlFormat.setLineWidth(120);
|
||||
|
@@ -177,7 +177,7 @@ public class ItemExportCLITool {
|
||||
}
|
||||
|
||||
Context c = new Context();
|
||||
c.setIgnoreAuthorization(true);
|
||||
c.turnOffAuthorisationSystem();
|
||||
|
||||
if (myType == Constants.ITEM)
|
||||
{
|
||||
|
@@ -1779,7 +1779,7 @@ public class ItemImportServiceImpl implements ItemImportService, InitializingBea
|
||||
context = new Context();
|
||||
eperson = ePersonService.find(context, oldEPerson.getID());
|
||||
context.setCurrentUser(eperson);
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
boolean isResume = theResumeDir!=null;
|
||||
|
||||
|
@@ -355,7 +355,7 @@ public class ItemUpdate {
|
||||
|
||||
context = new Context();
|
||||
iu.setEPerson(context, iu.eperson);
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
HANDLE_PREFIX = ConfigurationManager.getProperty("handle.canonical.prefix");
|
||||
if (HANDLE_PREFIX == null || HANDLE_PREFIX.length() == 0)
|
||||
@@ -366,19 +366,20 @@ public class ItemUpdate {
|
||||
iu.processArchive(context, sourcedir, itemField, metadataIndexName, alterProvenance, isTest);
|
||||
|
||||
context.complete(); // complete all transactions
|
||||
context.setIgnoreAuthorization(false);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (context != null && context.isValid())
|
||||
{
|
||||
context.abort();
|
||||
context.setIgnoreAuthorization(false);
|
||||
}
|
||||
e.printStackTrace();
|
||||
pr(e.toString());
|
||||
status = 1;
|
||||
}
|
||||
finally {
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
|
||||
if (isTest)
|
||||
{
|
||||
|
@@ -92,7 +92,7 @@ public class CreateStatReport {
|
||||
|
||||
// create context as super user
|
||||
context = new Context();
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
//get paths to directories
|
||||
outputLogDirectory = ConfigurationManager.getProperty("log.report.dir") + File.separator;
|
||||
|
@@ -224,7 +224,7 @@ public class LogAnalyser
|
||||
|
||||
// create context as super user
|
||||
Context context = new Context();
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
// set up our command line variables
|
||||
String myLogDir = null;
|
||||
|
@@ -161,7 +161,7 @@ public class ReportGenerator
|
||||
{
|
||||
// create context as super user
|
||||
Context context = new Context();
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
String myFormat = null;
|
||||
String myInput = null;
|
||||
|
@@ -309,11 +309,11 @@ public class LDAPAuthentication
|
||||
{
|
||||
log.info(LogManager.getHeader(context,
|
||||
"type=ldap-login", "type=ldap_but_already_email"));
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
eperson.setNetid(netid.toLowerCase());
|
||||
ePersonService.update(context, eperson);
|
||||
context.dispatchEvents();
|
||||
context.setIgnoreAuthorization(false);
|
||||
context.restoreAuthSystemState();
|
||||
context.setCurrentUser(eperson);
|
||||
|
||||
// assign user to groups based on ldap dn
|
||||
@@ -328,7 +328,7 @@ public class LDAPAuthentication
|
||||
// TEMPORARILY turn off authorisation
|
||||
try
|
||||
{
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
eperson = ePersonService.create(context);
|
||||
if (StringUtils.isNotEmpty(email))
|
||||
{
|
||||
@@ -362,7 +362,7 @@ public class LDAPAuthentication
|
||||
}
|
||||
finally
|
||||
{
|
||||
context.setIgnoreAuthorization(false);
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
|
||||
log.info(LogManager.getHeader(context, "authenticate",
|
||||
@@ -384,7 +384,7 @@ public class LDAPAuthentication
|
||||
}
|
||||
finally
|
||||
{
|
||||
context.setIgnoreAuthorization(false);
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -612,7 +612,7 @@ public class X509Authentication implements AuthenticationMethod
|
||||
"from=x.509, email=" + email));
|
||||
|
||||
// TEMPORARILY turn off authorisation
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
eperson = ePersonService.create(context);
|
||||
eperson.setEmail(email);
|
||||
eperson.setCanLogIn(true);
|
||||
@@ -620,7 +620,7 @@ public class X509Authentication implements AuthenticationMethod
|
||||
eperson);
|
||||
ePersonService.update(context, eperson);
|
||||
context.dispatchEvents();
|
||||
context.setIgnoreAuthorization(false);
|
||||
context.restoreAuthSystemState();
|
||||
context.setCurrentUser(eperson);
|
||||
setSpecialGroupsFlag(request, email);
|
||||
return SUCCESS;
|
||||
|
@@ -42,7 +42,7 @@ public class FixDefaultPolicies
|
||||
Context c = new Context();
|
||||
|
||||
// turn off authorization
|
||||
c.setIgnoreAuthorization(true);
|
||||
c.turnOffAuthorisationSystem();
|
||||
|
||||
//////////////////////
|
||||
// carnage begins here
|
||||
|
@@ -79,7 +79,7 @@ public class PolicySet
|
||||
Context c = new Context();
|
||||
|
||||
// turn off authorization
|
||||
c.setIgnoreAuthorization(true);
|
||||
c.turnOffAuthorisationSystem();
|
||||
|
||||
//////////////////////
|
||||
// carnage begins here
|
||||
|
@@ -303,21 +303,6 @@ public class Context
|
||||
ignoreAuth = previousState.booleanValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify whether the authorisation system should be ignored for this
|
||||
* context. This should be used sparingly.
|
||||
*
|
||||
* @deprecated use turnOffAuthorisationSystem() for make the change and
|
||||
* restoreAuthSystemState() when change are not more required
|
||||
* @param b
|
||||
* if <code>true</code>, authorisation should be ignored for this
|
||||
* session.
|
||||
*/
|
||||
public void setIgnoreAuthorization(boolean b)
|
||||
{
|
||||
ignoreAuth = b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set extra information that should be added to any message logged in the
|
||||
* scope of this context. An example of this might be the session ID of the
|
||||
|
@@ -155,7 +155,7 @@ public class CurationCli
|
||||
}
|
||||
else
|
||||
{
|
||||
c.setIgnoreAuthorization(true);
|
||||
c.turnOffAuthorisationSystem();
|
||||
}
|
||||
|
||||
Curator curator = new Curator();
|
||||
|
@@ -48,7 +48,7 @@ public class IndexClient {
|
||||
public static void main(String[] args) throws SQLException, IOException, SearchServiceException {
|
||||
|
||||
Context context = new Context();
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
|
||||
String usage = "org.dspace.discovery.IndexClient [-cbhf] | [-r <handle>] | [-i <handle>] or nothing to update/clean an existing index.";
|
||||
Options options = new Options();
|
||||
|
@@ -115,7 +115,7 @@ public class EmbargoCLITool {
|
||||
try
|
||||
{
|
||||
context = new Context();
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
Date now = new Date();
|
||||
|
||||
// scan items under embargo
|
||||
|
@@ -93,10 +93,9 @@ public class EmbargoServiceImpl implements EmbargoService
|
||||
}
|
||||
}
|
||||
String slift = myLift.toString();
|
||||
boolean ignoreAuth = context.ignoreAuthorization();
|
||||
try
|
||||
{
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
itemService.clearMetadata(context, item, lift_schema, lift_element, lift_qualifier, Item.ANY);
|
||||
itemService.addMetadata(context, item, lift_schema, lift_element, lift_qualifier, null, slift);
|
||||
log.info("Set embargo on Item "+item.getHandle()+", expires on: "+slift);
|
||||
@@ -107,7 +106,7 @@ public class EmbargoServiceImpl implements EmbargoService
|
||||
}
|
||||
finally
|
||||
{
|
||||
context.setIgnoreAuthorization(ignoreAuth);
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -81,7 +81,7 @@ public class LicenseCleanup
|
||||
{
|
||||
|
||||
Context ctx = new Context();
|
||||
ctx.setIgnoreAuthorization(true);
|
||||
ctx.turnOffAuthorisationSystem();
|
||||
Iterator<Item> iter = itemService.findAll(ctx);
|
||||
|
||||
Properties props = new Properties();
|
||||
|
@@ -487,7 +487,7 @@ public class RegisterServlet extends EditProfileServlet
|
||||
// Need to create new eperson
|
||||
// FIXME: TEMPORARILY need to turn off authentication, as usually
|
||||
// only site admins can create e-people
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
eperson = personService.create(context);
|
||||
eperson.setEmail(email);
|
||||
if (netid!=null)
|
||||
@@ -495,7 +495,7 @@ public class RegisterServlet extends EditProfileServlet
|
||||
eperson.setNetid(netid.toLowerCase());
|
||||
}
|
||||
personService.update(context, eperson);
|
||||
context.setIgnoreAuthorization(false);
|
||||
context.restoreAuthSystemState();
|
||||
}
|
||||
|
||||
// Now set the current user of the context
|
||||
|
@@ -472,13 +472,13 @@ public class AuthenticationUtil
|
||||
// Need to create new eperson
|
||||
// FIXME: TEMPORARILY need to turn off authentication, as usually
|
||||
// only site admins can create e-people
|
||||
context.setIgnoreAuthorization(true);
|
||||
context.turnOffAuthorisationSystem();
|
||||
EPerson eperson = ePersonService.create(context);
|
||||
eperson.setEmail(email);
|
||||
eperson.setCanLogIn(true);
|
||||
eperson.setSelfRegistered(true);
|
||||
ePersonService.update(context, eperson);
|
||||
context.setIgnoreAuthorization(false);
|
||||
context.restoreAuthSystemState();
|
||||
|
||||
// Give site auth a chance to set/override appropriate fields
|
||||
authenticationService.initEPerson(context, request, eperson);
|
||||
|
Reference in New Issue
Block a user