Skip to content

Commit

Permalink
moved from no.uio.ifi to no.elixir.fega and updated version to 2.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbaskaran committed Nov 13, 2023
1 parent a776bf1 commit 95ac7e8
Show file tree
Hide file tree
Showing 14 changed files with 33 additions and 36 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<version>3.1.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>no.uio.ifi</groupId>
<groupId>no.elixir.fega</groupId>
<artifactId>localega-tsd-proxy</artifactId>
<version>1.1.7</version>
<version>2.0.0</version>
<name>localega-tsd-proxy</name>
<description>LocalEGA TSD Proxy</description>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp;
package no.elixir.fega.ltp;

import lombok.extern.slf4j.Slf4j;
import no.uio.ifi.tc.TSDFileAPIClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package no.uio.ifi.ltp.aspects;
package no.elixir.fega.ltp.aspects;

import com.auth0.jwt.JWT;
import com.auth0.jwt.interfaces.DecodedJWT;
import lombok.extern.slf4j.Slf4j;
import no.elixir.fega.ltp.authentication.CEGACredentialsProvider;
import no.uio.ifi.clearinghouse.Clearinghouse;
import no.uio.ifi.clearinghouse.model.Visa;
import no.uio.ifi.clearinghouse.model.VisaType;
import no.uio.ifi.ltp.authentication.CEGACredentialsProvider;
import no.uio.ifi.ltp.dto.Credentials;
import no.elixir.fega.ltp.dto.Credentials;
import org.apache.commons.codec.digest.Crypt;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.auth.AuthenticationException;
Expand All @@ -34,9 +34,6 @@
import java.util.*;
import java.util.stream.Collectors;

import static no.uio.ifi.ltp.aspects.ProcessArgumentsAspect.EGA_USERNAME;
import static no.uio.ifi.ltp.aspects.ProcessArgumentsAspect.ELIXIR_ID;

/**
* AOP aspect that handles authentication and authorization.
*/
Expand Down Expand Up @@ -68,7 +65,7 @@ public class AAIAspect {
* @return Either the object, returned by the proxied method, or HTTP error response.
* @throws Throwable In case of error.
*/
@Around("execution(public * no.uio.ifi.ltp.controllers.rest.ProxyController.*(..))")
@Around("execution(public * no.elixir.fega.ltp.controllers.rest.ProxyController.*(..))")
public Object authenticateElixirAAI(ProceedingJoinPoint joinPoint) throws Throwable {
Optional<String> optionalBearerAuth = getBearerAuth();
if (optionalBearerAuth.isEmpty()) {
Expand All @@ -80,7 +77,7 @@ public Object authenticateElixirAAI(ProceedingJoinPoint joinPoint) throws Throwa
DecodedJWT decodedJWT = JWT.decode(jwtToken);
List<Visa> controlledAccessGrantsVisas = getVisas(jwtToken, decodedJWT);
log.info("Elixir user {} authenticated and provided following valid GA4GH Visas: {}", decodedJWT.getSubject(), controlledAccessGrantsVisas);
request.setAttribute(ELIXIR_ID, decodedJWT.getSubject());
request.setAttribute(ProcessArgumentsAspect.ELIXIR_ID, decodedJWT.getSubject());
return joinPoint.proceed();
} catch (Exception e) {
log.info(e.getMessage(), e);
Expand All @@ -95,8 +92,8 @@ public Object authenticateElixirAAI(ProceedingJoinPoint joinPoint) throws Throwa
* @return Either the object, returned by the proxied method, or HTTP error response.
* @throws Throwable In case of error.
*/
@Around("execution(public * no.uio.ifi.ltp.controllers.rest.ProxyController.*(..)) && " +
"!execution(public * no.uio.ifi.ltp.controllers.rest.ProxyController.stream(jakarta.servlet.http.HttpServletResponse, String, String))") // we don't need CEGA auth for Data Out endpoints
@Around("execution(public * no.elixir.fega.ltp.controllers.rest.ProxyController.*(..)) && " +
"!execution(public * no.elixir.fega.ltp.controllers.rest.ProxyController.stream(jakarta.servlet.http.HttpServletResponse, String, String))") // we don't need CEGA auth for Data Out endpoints
public Object authenticateCEGA(ProceedingJoinPoint joinPoint) throws Throwable {
if (((MethodSignature) joinPoint.getSignature()).getMethod().getName().equalsIgnoreCase("getFiles")) {
if (Boolean.FALSE.equals(joinPoint.getArgs()[1])) {
Expand All @@ -114,7 +111,7 @@ public Object authenticateCEGA(ProceedingJoinPoint joinPoint) throws Throwable {
throw new AuthenticationException("EGA authentication failed");
}
log.info("EGA user {} authenticated", usernameAndPassword[0]);
request.setAttribute(EGA_USERNAME, usernameAndPassword[0]);
request.setAttribute(ProcessArgumentsAspect.EGA_USERNAME, usernameAndPassword[0]);
return joinPoint.proceed();
} catch (Exception e) {
log.info(e.getMessage(), e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp.aspects;
package no.elixir.fega.ltp.aspects;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
Expand All @@ -12,8 +12,8 @@
import jakarta.servlet.http.HttpServletRequest;
import java.util.List;

import static no.uio.ifi.ltp.aspects.ProcessArgumentsAspect.EGA_USERNAME;
import static no.uio.ifi.ltp.aspects.ProcessArgumentsAspect.ELIXIR_ID;
import static no.elixir.fega.ltp.aspects.ProcessArgumentsAspect.EGA_USERNAME;
import static no.elixir.fega.ltp.aspects.ProcessArgumentsAspect.ELIXIR_ID;

/**
* AOP aspect that maps EGA username with Elixir ID.
Expand All @@ -35,7 +35,7 @@ public class CredentialsMappingAspect {
*
* @param result Object returned by the proxied method.
*/
@AfterReturning(pointcut = "execution(public * no.uio.ifi.ltp.controllers.rest.ProxyController.stream(..))", returning = "result")
@AfterReturning(pointcut = "execution(public * no.elixir.fega.ltp.controllers.rest.ProxyController.stream(..))", returning = "result")
public void publishMessage(Object result) {
String egaUsername = request.getAttribute(EGA_USERNAME).toString();
String elixirId = request.getAttribute(ELIXIR_ID).toString();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp.aspects;
package no.elixir.fega.ltp.aspects;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
Expand Down Expand Up @@ -42,7 +42,7 @@ public class ProcessArgumentsAspect {
* @throws Throwable In case of error.
*/
@SuppressWarnings("rawtypes")
@Around("execution(public * no.uio.ifi.ltp.controllers.rest.ProxyController.stream(..)) || execution(public * no.uio.ifi.ltp.controllers.rest.ProxyController.deleteFile(..))")
@Around("execution(public * no.elixir.fega.ltp.controllers.rest.ProxyController.stream(..)) || execution(public * no.elixir.fega.ltp.controllers.rest.ProxyController.deleteFile(..))")
public Object processArguments(ProceedingJoinPoint joinPoint) throws Throwable {
try {
Object[] arguments = joinPoint.getArgs();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package no.uio.ifi.ltp.aspects;
package no.elixir.fega.ltp.aspects;

import com.google.gson.Gson;
import lombok.extern.slf4j.Slf4j;
import no.uio.ifi.ltp.dto.EncryptedIntegrity;
import no.uio.ifi.ltp.dto.FileDescriptor;
import no.uio.ifi.ltp.dto.Operation;
import no.elixir.fega.ltp.dto.EncryptedIntegrity;
import no.elixir.fega.ltp.dto.FileDescriptor;
import no.elixir.fega.ltp.dto.Operation;
import no.uio.ifi.tc.model.pojo.TSDFileAPIResponse;
import org.apache.http.entity.ContentType;
import org.aspectj.lang.annotation.AfterReturning;
Expand All @@ -20,7 +20,7 @@
import java.util.Objects;
import java.util.UUID;

import static no.uio.ifi.ltp.aspects.ProcessArgumentsAspect.*;
import static no.elixir.fega.ltp.aspects.ProcessArgumentsAspect.*;

/**
* AOP aspect that publishes MQ messages.
Expand Down Expand Up @@ -58,7 +58,7 @@ public class PublishMQAspect {
* @param result Object returned by the proxied method.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@AfterReturning(pointcut = "execution(@org.springframework.web.bind.annotation.PatchMapping public * no.uio.ifi.ltp.controllers.rest.ProxyController.stream(..))", returning = "result")
@AfterReturning(pointcut = "execution(@org.springframework.web.bind.annotation.PatchMapping public * no.elixir.fega.ltp.controllers.rest.ProxyController.stream(..))", returning = "result")
public void publishUpload(Object result) {
ResponseEntity genericResponseEntity = (ResponseEntity) result;
if (!String.valueOf(Objects.requireNonNull(genericResponseEntity).getStatusCode()).startsWith("20")) {
Expand Down Expand Up @@ -97,7 +97,7 @@ public void publishUpload(Object result) {
* @param result Object returned by the proxied method.
*/
@SuppressWarnings({"unchecked", "rawtypes"})
@AfterReturning(pointcut = "execution(public * no.uio.ifi.ltp.controllers.rest.ProxyController.deleteFile(..))", returning = "result")
@AfterReturning(pointcut = "execution(public * no.elixir.fega.ltp.controllers.rest.ProxyController.deleteFile(..))", returning = "result")
public void publishRemove(Object result) {
ResponseEntity genericResponseEntity = (ResponseEntity) result;
if (!String.valueOf(Objects.requireNonNull(genericResponseEntity).getStatusCode()).startsWith("20")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package no.uio.ifi.ltp.authentication;
package no.elixir.fega.ltp.authentication;

import no.uio.ifi.ltp.dto.Credentials;
import no.elixir.fega.ltp.dto.Credentials;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp.controllers.rest;
package no.elixir.fega.ltp.controllers.rest;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp.controllers.rest;
package no.elixir.fega.ltp.controllers.rest;

import lombok.extern.slf4j.Slf4j;
import no.uio.ifi.tc.TSDFileAPIClient;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp.dto;
package no.elixir.fega.ltp.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp.dto;
package no.elixir.fega.ltp.dto;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp.dto;
package no.elixir.fega.ltp.dto;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp.dto;
package no.elixir.fega.ltp.dto;

/**
* Type of file event (created, moved, removed, etc.)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package no.uio.ifi.ltp;
package no.elixir.fega.ltp;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
Expand Down

0 comments on commit 95ac7e8

Please sign in to comment.