mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-18 15:33:09 +00:00
[CST-12108] added javaDoc
This commit is contained in:
@@ -23,20 +23,20 @@ public interface QAEventSecurityService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the specified user can see a specific QASource
|
* Check if the specified user can see a specific QASource
|
||||||
* @param context the context
|
* @param context the context
|
||||||
* @param user the eperson to consider
|
* @param user the eperson to consider
|
||||||
* @param qaSource the qaSource involved
|
* @param sourceName the source name
|
||||||
* @return <code>true</code> if the specified user can eventually see events in the QASource
|
* @return <code>true</code> if the specified user can eventually see events in the QASource
|
||||||
*/
|
*/
|
||||||
boolean canSeeSource(Context context, EPerson user, String qaSource);
|
boolean canSeeSource(Context context, EPerson user, String sourceName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the specified user can see a specific QAEvent. It is expected that a QAEvent in a not visible QASource
|
* Check if the specified user can see a specific QAEvent. It is expected that a QAEvent in a not visible QASource
|
||||||
* cannot be accessed. So implementation of this method should enforce this rule.
|
* cannot be accessed. So implementation of this method should enforce this rule.
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
* @param user the eperson to consider
|
* @param user the eperson to consider
|
||||||
* @param qaEvent the qaevent to check
|
* @param qaEvent the qaevent to check
|
||||||
* @return <code>true</code> if the specified user can see the specified event
|
* @return <code>true</code> if the specified user can see the specified event
|
||||||
*/
|
*/
|
||||||
boolean canSeeEvent(Context context, EPerson user, QAEvent qaEvent);
|
boolean canSeeEvent(Context context, EPerson user, QAEvent qaEvent);
|
||||||
@@ -45,11 +45,11 @@ public interface QAEventSecurityService {
|
|||||||
* Generate a query to restrict the qa events returned by other search/find method to the only ones visible to the
|
* Generate a query to restrict the qa events returned by other search/find method to the only ones visible to the
|
||||||
* specified user
|
* specified user
|
||||||
*
|
*
|
||||||
* @param context the context
|
* @param context the context
|
||||||
* @param user the eperson to consider
|
* @param user the eperson to consider
|
||||||
* @param qaSource the qaSource involved
|
* @param sourceName the source name
|
||||||
* @return the solr filter query
|
* @return the solr filter query
|
||||||
*/
|
*/
|
||||||
public Optional<String> generateQAEventFilterQuery(Context context, EPerson user, String qaSource);
|
public Optional<String> generateQAEventFilterQuery(Context context, EPerson user, String sourceName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -16,10 +16,23 @@ import org.dspace.eperson.EPerson;
|
|||||||
import org.dspace.qaevent.security.QASecurity;
|
import org.dspace.qaevent.security.QASecurity;
|
||||||
import org.dspace.qaevent.service.QAEventSecurityService;
|
import org.dspace.qaevent.service.QAEventSecurityService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementation of the security service for QAEvents.
|
||||||
|
* This implementation manages a configuration of {@link QASecurity} instances,
|
||||||
|
* each responsible for security checks for a specific QA source.
|
||||||
|
*
|
||||||
|
* @author Mykhaylo Boychuk (mykhaylo.boychuk@4science.com)
|
||||||
|
*/
|
||||||
public class QAEventSecurityServiceImpl implements QAEventSecurityService {
|
public class QAEventSecurityServiceImpl implements QAEventSecurityService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default security settings to be used when specific configurations are not available for a QA source.
|
||||||
|
*/
|
||||||
private QASecurity defaultSecurity;
|
private QASecurity defaultSecurity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A mapping of QA source names to their corresponding QASecurity configurations.
|
||||||
|
*/
|
||||||
private Map<String, QASecurity> qaSecurityConfiguration;
|
private Map<String, QASecurity> qaSecurityConfiguration;
|
||||||
|
|
||||||
public void setQaSecurityConfiguration(Map<String, QASecurity> qaSecurityConfiguration) {
|
public void setQaSecurityConfiguration(Map<String, QASecurity> qaSecurityConfiguration) {
|
||||||
@@ -30,27 +43,58 @@ public class QAEventSecurityServiceImpl implements QAEventSecurityService {
|
|||||||
this.defaultSecurity = defaultSecurity;
|
this.defaultSecurity = defaultSecurity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a query to restrict the qa events returned by other search/find method to the only ones visible to the
|
||||||
|
* specified user
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
* @param user the eperson to consider
|
||||||
|
* @param sourceName the source name
|
||||||
|
* @return the solr filter query
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Optional<String> generateQAEventFilterQuery(Context context, EPerson user, String qaSource) {
|
public Optional<String> generateQAEventFilterQuery(Context context, EPerson user, String sourceName) {
|
||||||
QASecurity qaSecurity = getQASecurity(qaSource);
|
QASecurity qaSecurity = getQASecurity(sourceName);
|
||||||
return qaSecurity.generateFilterQuery(context, user);
|
return qaSecurity.generateFilterQuery(context, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the QASecurity configuration for the specified QA source, or uses the default
|
||||||
|
* configuration if not available.
|
||||||
|
*
|
||||||
|
* @param qaSource The name of the QA source.
|
||||||
|
* @return The QASecurity configuration for the specified QA source, or the default configuration if not available.
|
||||||
|
*/
|
||||||
private QASecurity getQASecurity(String qaSource) {
|
private QASecurity getQASecurity(String qaSource) {
|
||||||
return qaSecurityConfiguration.getOrDefault(qaSource, defaultSecurity);
|
return qaSecurityConfiguration.getOrDefault(qaSource, defaultSecurity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the user is authorized to see the specified QA event.
|
||||||
|
*
|
||||||
|
* @param context the context
|
||||||
|
* @param user the eperson to consider
|
||||||
|
* @param qaEvent the qaevent to check
|
||||||
|
* @return <code>true</code> if the specified user can see the specified event
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canSeeEvent(Context context, EPerson user, QAEvent qaEvent) {
|
public boolean canSeeEvent(Context context, EPerson user, QAEvent qaEvent) {
|
||||||
String source = qaEvent.getSource();
|
String source = qaEvent.getSource();
|
||||||
QASecurity qaSecurity = getQASecurity(source);
|
QASecurity qaSecurity = getQASecurity(source);
|
||||||
return qaSecurity.canSeeQASource(context, user)
|
return qaSecurity.canSeeQASource(context, user) && qaSecurity.canSeeQAEvent(context, user, qaEvent);
|
||||||
&& qaSecurity.canSeeQAEvent(context, user, qaEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether the user is authorized to see events from the specified QA source.
|
||||||
|
* @param context The context.
|
||||||
|
* @param user The EPerson to consider
|
||||||
|
* @param sourceName The source name
|
||||||
|
*
|
||||||
|
* @return True if the user is authorized to see events from the source, false otherwise.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean canSeeSource(Context context, EPerson user, String qaSource) {
|
public boolean canSeeSource(Context context, EPerson user, String sourceName) {
|
||||||
QASecurity qaSecurity = getQASecurity(qaSource);
|
QASecurity qaSecurity = getQASecurity(sourceName);
|
||||||
return qaSecurity.canSeeQASource(context, user);
|
return qaSecurity.canSeeQASource(context, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user