use of no.mnemonic.act.platform.api.exceptions.AuthenticationFailedException in project act-platform by mnemonic-no.
the class AuthenticationAspect method invoke.
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Service service = getService(invocation);
RequestHeader requestHeader = getRequestHeader(invocation);
try {
// For each service method invocation verify that user is authenticated!
// noinspection unchecked
accessController.validate(requestHeader.getCredentials());
} catch (InvalidCredentialsException ex) {
throw new AuthenticationFailedException("Could not authenticate user: " + ex.getMessage());
}
if (SecurityContext.isSet()) {
return invocation.proceed();
}
try (SecurityContext ignored = SecurityContext.set(service.createSecurityContext(requestHeader.getCredentials()))) {
return invocation.proceed();
}
}
use of no.mnemonic.act.platform.api.exceptions.AuthenticationFailedException in project act-platform by mnemonic-no.
the class FactGetCommentsDelegate method handle.
public ResultSet<FactComment> handle(GetFactCommentsRequest request) throws AccessDeniedException, AuthenticationFailedException, InvalidArgumentException, ObjectNotFoundException {
// Fetch Fact and verify that it exists.
FactRecord fact = factRequestResolver.resolveFact(request.getFact());
// Verify that user is allowed to access the Fact.
securityContext.checkReadPermission(fact);
// Verify that user is allowed to view the Fact's comments.
securityContext.checkPermission(TiFunctionConstants.viewThreatIntelFactComment, fact.getOrganizationID());
// Fetch comments for Fact and filter by 'before' and 'after' timestamps.
List<FactComment> comments = ListUtils.list(fact.getComments()).stream().filter(comment -> request.getBefore() == null || comment.getTimestamp() < request.getBefore()).filter(comment -> request.getAfter() == null || comment.getTimestamp() > request.getAfter()).map(factCommentResponseConverter).collect(Collectors.toList());
return StreamingResultSet.<FactComment>builder().setCount(comments.size()).setLimit(0).setValues(comments).build();
}
Aggregations