@@ -0,0 +1,1300 @@
+/*%0A * Copyright (c) 2018. Taimos GmbH http://www.taimos.de%0A */%0A%0Apackage de.taimos.dvalin.jaxrs.security.jwt.cognito;%0A%0Aimport javax.ws.rs.NotAuthorizedException;%0Aimport javax.ws.rs.core.Response;%0A%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.stereotype.Component;%0A%0Aimport de.taimos.daemon.spring.conditional.OnSystemProperty;%0Aimport de.taimos.dvalin.jaxrs.context.DvalinRSContext;%0A%0A@Component%0A@OnSystemProperty(propertyName = %22jwtauth.cognito.poolid%22)%0Apublic class CognitoContext %7B%0A%0A%09private DvalinRSContext context;%0A%0A%09@Autowired%0A%09public void setContext(DvalinRSContext context) %7B%0A%09%09this.context = context;%0A%09%7D%0A%0A%09public CognitoUser getCurrentUser() %7B%0A%09%09CognitoUser currentUser = (CognitoUser) this.context.getCurrentUser();%0A%09%09if (currentUser == null) %7B%0A%09%09%09Response response = Response.status(Response.Status.UNAUTHORIZED).entity(%22Invalid credentials or session%22).build();%0A%09%09%09throw new NotAuthorizedException(response);%0A%09%09%7D%0A%09%09return currentUser;%0A%09%7D%0A%0A%09public String getCurrentSubject() %7B%0A%09%09return this.getCurrentUser().getSubject();%0A%09%7D%0A%0A%09public void assertLoggedIn() %7B%0A%09%09this.context.assertLoggedIn();%0A%09%7D%0A%0A%09public boolean hasRole(String role) %7B%0A%09%09return this.context.hasRole(role);%0A%09%7D%0A%0A%09public boolean isLoggedIn() %7B%0A%09%09return this.context.isLoggedIn();%0A%09%7D%0A%0A%7D%0A

Add CognitoContext