org.dspace.sword
Class SWORDAuthenticator

java.lang.Object
  extended by org.dspace.sword.SWORDAuthenticator

public class SWORDAuthenticator
extends Object

This class offers a thin wrapper for the default DSpace authentication module for the SWORD implementation

Author:
Richard Jones

Constructor Summary
SWORDAuthenticator()
           
 
Method Summary
 SWORDContext authenticate(AtomDocumentRequest request)
          Authenticate the given atom document request.
 SWORDContext authenticate(Deposit deposit)
          Authenticate the deposit request.
 SWORDContext authenticate(ServiceDocumentRequest request)
          Authenticate the given service document request.
 boolean authenticates(Context context, String un, String pw)
          Does the given username and password authenticate for the given DSpace Context?
 boolean canSubmit(SWORDService swordService, Deposit deposit, DSpaceObject dso)
          Can the users contained in this object's member SWORDContext make a successful submission to the selected collection.
 boolean canSubmitTo(SWORDContext swordContext, Collection collection)
          Can the current SWORD Context permit deposit into the given collection in the given DSpace Context IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to ADD OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to ADD AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to ADD OR the on-behalf-of user is null)
 boolean canSubmitTo(SWORDContext context, DSpaceObject dso)
          Can the given context submit to the specified dspace object.
 boolean canSubmitTo(SWORDContext swordContext, Item item)
          Does the given context have the authority to submit to the given item.
 List<Collection> getAllowedCollections(SWORDContext swordContext)
          Get an array of all the collections that the current SWORD context will allow deposit onto in the given DSpace context Forwards to: getAllowedCollections(swordContext, null) See that method for details of the conditions applied
 List<Collection> getAllowedCollections(SWORDContext swordContext, Community community)
          Get an array of all the collections that the current SWORD context will allow deposit onto in the given DSpace context IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to ADD OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to ADD AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to ADD OR the on-behalf-of user is null)
 List<Community> getAllowedCommunities(SWORDContext swordContext)
          Get an array of all the communities that the current SWORD context will allow deposit onto in the given DSpace context The user may submit to a community if the following conditions are met: IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to READ OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to READ AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to READ OR the on-behalf-of user is null)
 List<Item> getAllowedItems(SWORDContext swordContext, Collection collection)
          Get a list of all the items that the current SWORD context will allow deposit onto in the given DSpace context IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to WRITE on the item and ADD on the ORIGINAL bundle OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to WRITE on the item and ADD on the ORIGINAL bundle AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to WRITE on the item and ADD on the ORIGINAL bundle OR the on-behalf-of user is null)
 List<Community> getCommunities(SWORDContext swordContext, Community community)
          Get an array of all the collections that the current SWORD context will allow deposit onto in the given DSpace context The user may submit to a community if the following conditions are met: IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to READ OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to READ AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to READ OR the on-behalf-of user is null)
 boolean isInGroup(Group group, EPerson eperson)
          Is the given eperson in the given group, or any of the groups that are also members of that group.
 boolean isOnBehalfOfAdmin(SWORDContext swordContext)
          Is the given onBehalfOf user DSpace administrator? This translates as asking the question of whether the given eperson is a member of the special DSpace group Administrator, with id 1
 boolean isOnBehalfOfInGroup(SWORDContext swordContext, Group group)
          Is the onBehalfOf user a member of the given group or one of its sub groups
 boolean isUserAdmin(SWORDContext swordContext)
          Is the authenticated user a DSpace administrator? This translates as asking the question of whether the given eperson is a member of the special DSpace group Administrator, with id 1
 boolean isUserInGroup(SWORDContext swordContext, Group group)
          Is the authenticated user a member of the given group or one of its sub groups?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SWORDAuthenticator

public SWORDAuthenticator()
Method Detail

authenticates

public boolean authenticates(Context context,
                             String un,
                             String pw)
Does the given username and password authenticate for the given DSpace Context?

Parameters:
context -
un -
pw -
Returns:
true if yes, false if not

authenticate

public SWORDContext authenticate(ServiceDocumentRequest request)
                          throws SWORDException,
                                 SWORDErrorException,
                                 SWORDAuthenticationException
Authenticate the given service document request. This extracts the appropriate information from the request and forwards to the appropriate authentication method

Parameters:
request -
Returns:
Throws:
SWORDException
SWORDErrorException
SWORDAuthenticationException

authenticate

public SWORDContext authenticate(AtomDocumentRequest request)
                          throws SWORDException,
                                 SWORDErrorException,
                                 SWORDAuthenticationException
Authenticate the given atom document request. This extracts the appropriate information from the request, and forwards to the appropriate authentication method

Parameters:
request -
Returns:
Throws:
SWORDException
SWORDErrorException
SWORDAuthenticationException

authenticate

public SWORDContext authenticate(Deposit deposit)
                          throws SWORDException,
                                 SWORDErrorException,
                                 SWORDAuthenticationException
Authenticate the deposit request.

Parameters:
deposit -
Returns:
Throws:
SWORDException
SWORDErrorException
SWORDAuthenticationException

canSubmit

public boolean canSubmit(SWORDService swordService,
                         Deposit deposit,
                         DSpaceObject dso)
                  throws DSpaceSWORDException,
                         SWORDErrorException
Can the users contained in this object's member SWORDContext make a successful submission to the selected collection. See javadocs for individual canSubmitTo methods to see the conditions which are applied in each situation

Returns:
true if yes, false if not
Throws:
DSpaceSWORDException
SWORDErrorException

isUserAdmin

public boolean isUserAdmin(SWORDContext swordContext)
                    throws DSpaceSWORDException
Is the authenticated user a DSpace administrator? This translates as asking the question of whether the given eperson is a member of the special DSpace group Administrator, with id 1

Parameters:
swordContext -
Returns:
true if administrator, false if not
Throws:
SQLException
DSpaceSWORDException

isOnBehalfOfAdmin

public boolean isOnBehalfOfAdmin(SWORDContext swordContext)
                          throws DSpaceSWORDException
Is the given onBehalfOf user DSpace administrator? This translates as asking the question of whether the given eperson is a member of the special DSpace group Administrator, with id 1

Parameters:
swordContext -
Returns:
true if administrator, false if not
Throws:
SQLException
DSpaceSWORDException

isUserInGroup

public boolean isUserInGroup(SWORDContext swordContext,
                             Group group)
Is the authenticated user a member of the given group or one of its sub groups?

Parameters:
group -
Returns:

isOnBehalfOfInGroup

public boolean isOnBehalfOfInGroup(SWORDContext swordContext,
                                   Group group)
Is the onBehalfOf user a member of the given group or one of its sub groups

Parameters:
group -
Returns:

isInGroup

public boolean isInGroup(Group group,
                         EPerson eperson)
Is the given eperson in the given group, or any of the groups that are also members of that group. This method recurses until it has exhausted the tree of groups or finds the given eperson

Parameters:
group -
eperson -
Returns:
true if in group, false if not

getAllowedCommunities

public List<Community> getAllowedCommunities(SWORDContext swordContext)
                                      throws DSpaceSWORDException
Get an array of all the communities that the current SWORD context will allow deposit onto in the given DSpace context The user may submit to a community if the following conditions are met: IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to READ OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to READ AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to READ OR the on-behalf-of user is null)

Parameters:
swordContext -
Returns:
the array of allowed collections
Throws:
DSpaceSWORDException

getCommunities

public List<Community> getCommunities(SWORDContext swordContext,
                                      Community community)
                               throws DSpaceSWORDException
Get an array of all the collections that the current SWORD context will allow deposit onto in the given DSpace context The user may submit to a community if the following conditions are met: IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to READ OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to READ AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to READ OR the on-behalf-of user is null)

Parameters:
community -
Returns:
the array of allowed collections
Throws:
DSpaceSWORDException

getAllowedCollections

public List<Collection> getAllowedCollections(SWORDContext swordContext)
                                       throws DSpaceSWORDException
Get an array of all the collections that the current SWORD context will allow deposit onto in the given DSpace context Forwards to: getAllowedCollections(swordContext, null) See that method for details of the conditions applied

Parameters:
swordContext -
Returns:
the array of allowed collections
Throws:
DSpaceSWORDException

getAllowedCollections

public List<Collection> getAllowedCollections(SWORDContext swordContext,
                                              Community community)
                                       throws DSpaceSWORDException
Get an array of all the collections that the current SWORD context will allow deposit onto in the given DSpace context IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to ADD OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to ADD AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to ADD OR the on-behalf-of user is null)

Parameters:
swordContext -
Returns:
the array of allowed collections
Throws:
DSpaceSWORDException

getAllowedItems

public List<Item> getAllowedItems(SWORDContext swordContext,
                                  Collection collection)
                           throws DSpaceSWORDException
Get a list of all the items that the current SWORD context will allow deposit onto in the given DSpace context IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to WRITE on the item and ADD on the ORIGINAL bundle OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to WRITE on the item and ADD on the ORIGINAL bundle AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to WRITE on the item and ADD on the ORIGINAL bundle OR the on-behalf-of user is null)

Parameters:
swordContext -
Returns:
the array of allowed collections
Throws:
DSpaceSWORDException

canSubmitTo

public boolean canSubmitTo(SWORDContext swordContext,
                           Collection collection)
                    throws DSpaceSWORDException
Can the current SWORD Context permit deposit into the given collection in the given DSpace Context IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to ADD OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to ADD AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to ADD OR the on-behalf-of user is null)

Parameters:
swordContext -
collection -
Returns:
Throws:
DSpaceSWORDException

canSubmitTo

public boolean canSubmitTo(SWORDContext swordContext,
                           Item item)
                    throws DSpaceSWORDException
Does the given context have the authority to submit to the given item. The context has permission of the following conditions are met: IF: the authenticated user is an administrator AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to WRITE on the item and ADD on the ORIGINAL bundle OR the on-behalf-of user is null) OR IF: the authenticated user is authorised to WRITE on the item and ADD on the ORIGINAL bundle AND: (the on-behalf-of user is an administrator OR the on-behalf-of user is authorised to WRITE on the item and ADD on the ORIGINAL bundle OR the on-behalf-of user is null)

Parameters:
swordContext -
Returns:
the array of allowed collections
Throws:
DSpaceSWORDException

canSubmitTo

public boolean canSubmitTo(SWORDContext context,
                           DSpaceObject dso)
                    throws DSpaceSWORDException
Can the given context submit to the specified dspace object. This forwards to the individual methods for different object types; see their documentation for details of the conditions.

Parameters:
context -
dso -
Returns:
Throws:
DSpaceSWORDException


Copyright © 2010 DuraSpace. All Rights Reserved.