Skip to content

Commit

Permalink
Adapt cherrypick for EE10
Browse files Browse the repository at this point in the history
  • Loading branch information
pdudits authored and jGauravGupta committed Aug 23, 2022
1 parent 82ff574 commit a66a183
Show file tree
Hide file tree
Showing 18 changed files with 108 additions and 111 deletions.
11 changes: 8 additions & 3 deletions openid-standalone-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@
<parent>
<artifactId>security-connectors-parent</artifactId>
<groupId>fish.payara.security.connectors</groupId>
<version>2.4.0-SNAPSHOT</version>
<version>3.0.Alpha6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>openid-standalone-it</artifactId>

<properties>
<version.payara>5.2022.2</version.payara>
<version.payara>6.2022.1.Alpha3</version.payara>
<version.arquillian>1.7.0.Alpha12</version.arquillian>
<version.junit>5.9.0</version.junit>
</properties>
Expand Down Expand Up @@ -112,7 +112,7 @@

<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<artifactId>arquillian-protocol-servlet-jakarta</artifactId>
<scope>test</scope>
</dependency>

Expand All @@ -137,6 +137,11 @@
<artifactId>jersey-common</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,24 +47,6 @@
import java.util.concurrent.ConcurrentMap;
import java.util.logging.Logger;

import javax.json.Json;
import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.ws.rs.BeanParam;
import javax.ws.rs.Consumes;
import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;

import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWSAlgorithm;
import com.nimbusds.jose.JWSHeader;
Expand All @@ -79,12 +61,29 @@
import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTClaimsSet;
import com.nimbusds.jwt.SignedJWT;
import jakarta.json.Json;
import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;
import jakarta.ws.rs.BeanParam;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.FormParam;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.HeaderParam;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriBuilder;
import jakarta.ws.rs.core.UriInfo;

import static fish.payara.security.connectors.openid.api.OpenIdConstant.*;
import static jakarta.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.SEVERE;
import static javax.ws.rs.core.MediaType.APPLICATION_FORM_URLENCODED;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;

/**
* @author Gaurav Gupta
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import javax.ws.rs.client.ClientRequestContext;
import javax.ws.rs.client.ClientRequestFilter;
import javax.ws.rs.client.ClientResponseContext;
import javax.ws.rs.client.ClientResponseFilter;
import javax.ws.rs.core.Cookie;
import javax.ws.rs.core.NewCookie;
import jakarta.ws.rs.client.ClientRequestContext;
import jakarta.ws.rs.client.ClientRequestFilter;
import jakarta.ws.rs.client.ClientResponseContext;
import jakarta.ws.rs.client.ClientResponseFilter;
import jakarta.ws.rs.core.Cookie;
import jakarta.ws.rs.core.NewCookie;

public class NaiveCookieManager implements ClientRequestFilter, ClientResponseFilter {
private static Map<String, Cookie> cookies = new ConcurrentHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@
import java.util.Collections;
import java.util.Set;

import javax.enterprise.context.ApplicationScoped;

import fish.payara.security.connectors.openid.api.AccessTokenCallerPrincipal;
import fish.payara.security.connectors.openid.api.BearerGroupsIdentityStore;
import jakarta.enterprise.context.ApplicationScoped;

@ApplicationScoped
public class AccessTokenRoleMapping extends BearerGroupsIdentityStore {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@

import java.security.Principal;

import javax.annotation.security.DeclareRoles;
import javax.annotation.security.RolesAllowed;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;

import fish.payara.security.connectors.annotations.OpenIdAuthenticationDefinition;
import fish.payara.security.connectors.annotations.OpenIdProviderMetadata;
import jakarta.annotation.security.DeclareRoles;
import jakarta.annotation.security.RolesAllowed;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;

@RequestScoped
@OpenIdAuthenticationDefinition(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,18 @@
import java.util.Arrays;
import java.util.Date;

import javax.json.JsonObject;
import javax.json.JsonObjectBuilder;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;

import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTClaimsSet;
import fish.payara.security.openid.idp.AbstractIdProvider;
import fish.payara.security.openid.idp.AuthCode;
import fish.payara.security.openid.idp.Token;
import jakarta.json.JsonObject;
import jakarta.json.JsonObjectBuilder;
import jakarta.ws.rs.NotAuthorizedException;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;

@Path("idp")
public class AdfsEmulation extends AbstractIdProvider {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,19 @@
import java.io.IOException;
import java.net.URI;

import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonObject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;

import fish.payara.arquillian.jersey.client.ClientProperties;
import fish.payara.security.openid.idp.LogExceptionOnServerSide;
import fish.payara.security.openid.idp.NaiveCookieManager;
import fish.payara.security.openid.idp.OpenIdDeployment;
import jakarta.json.Json;
import jakarta.json.JsonArray;
import jakarta.json.JsonObject;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientProperties;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit5.ArquillianExtension;
import org.jboss.arquillian.test.api.ArquillianResource;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

package fish.payara.security.openid.adfs;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("")
public class JaxrsApplication extends Application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,16 @@
import java.security.Principal;
import java.util.logging.Logger;

import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.json.Json;
import javax.json.JsonArray;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;

import fish.payara.security.connectors.openid.api.OpenIdContext;
import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonArray;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;

import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static jakarta.ws.rs.core.MediaType.APPLICATION_JSON;

@Path("Callback")
@RequestScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@

package fish.payara.security.openid.adfs;

import javax.enterprise.inject.Model;
import javax.inject.Inject;
import javax.servlet.http.HttpServletRequest;
import jakarta.enterprise.inject.Model;
import jakarta.inject.Inject;
import jakarta.servlet.http.HttpServletRequest;

@Model
public class UrlExtractor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@

package fish.payara.security.openid.idp.simple;

import javax.enterprise.context.RequestScoped;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;

import fish.payara.security.connectors.openid.api.OpenIdConstant;
import jakarta.enterprise.context.RequestScoped;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;

@Path("callback/")
@RequestScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@

package fish.payara.security.openid.idp.simple;

import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("")
public class JaxrsApplication extends Application {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,19 @@

package fish.payara.security.openid.idp.simple;

import javax.enterprise.context.RequestScoped;
import javax.json.JsonObject;
import javax.json.JsonValue;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;

import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.jwk.JWKSet;
import com.nimbusds.jwt.JWT;
import com.nimbusds.jwt.JWTClaimsSet;
import fish.payara.security.openid.idp.AbstractIdProvider;
import fish.payara.security.openid.idp.AuthCode;
import fish.payara.security.openid.idp.Token;
import jakarta.enterprise.context.RequestScoped;
import jakarta.json.JsonObject;
import jakarta.json.JsonValue;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Context;
import jakarta.ws.rs.core.UriInfo;

@Path("simple/")
@RequestScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.json.JsonObject;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType;

import com.nimbusds.jose.JOSEException;
import com.nimbusds.jose.JWSHeader;
import com.nimbusds.jose.crypto.RSASSAVerifier;
Expand All @@ -67,6 +59,13 @@
import com.nimbusds.jwt.SignedJWT;
import fish.payara.security.openid.idp.LogExceptionOnServerSide;
import fish.payara.security.openid.idp.OpenIdDeployment;
import jakarta.json.JsonObject;
import jakarta.ws.rs.client.Client;
import jakarta.ws.rs.client.ClientBuilder;
import jakarta.ws.rs.client.Entity;
import jakarta.ws.rs.client.WebTarget;
import jakarta.ws.rs.core.Form;
import jakarta.ws.rs.core.MediaType;
import org.glassfish.jersey.logging.LoggingFeature;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit5.ArquillianExtension;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@
*/
package fish.payara.security.openid;

import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;

import fish.payara.security.openid.api.AccessTokenCredential;
import fish.payara.security.openid.api.OpenIdState;
import fish.payara.security.openid.api.RefreshToken;
Expand All @@ -53,9 +60,10 @@
import jakarta.enterprise.inject.Typed;
import jakarta.inject.Inject;
import jakarta.json.Json;
import jakarta.json.JsonNumber;
import jakarta.json.JsonObject;
import jakarta.json.JsonReader;
import jakarta.security.auth.callback.Callback;
import jakarta.security.auth.callback.UnsupportedCallbackException;
import jakarta.security.auth.message.callback.CallerPrincipalCallback;
import jakarta.security.enterprise.AuthenticationException;
import jakarta.security.enterprise.AuthenticationStatus;
Expand All @@ -69,26 +77,17 @@
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.Status;

import javax.security.auth.callback.Callback;
import javax.security.auth.callback.UnsupportedCallbackException;
import java.io.IOException;
import java.io.Serializable;
import java.io.StringReader;
import java.util.Optional;
import java.util.logging.Level;
import java.util.logging.Logger;

import static fish.payara.security.openid.OpenIdUtil.isEmpty;
import static fish.payara.security.openid.api.OpenIdConstant.CODE;
import static jakarta.security.enterprise.AuthenticationStatus.*;
import static jakarta.security.enterprise.identitystore.CredentialValidationResult.INVALID_RESULT;
import static jakarta.security.enterprise.identitystore.CredentialValidationResult.NOT_VALIDATED_RESULT;
import static fish.payara.security.openid.api.OpenIdConstant.ERROR_DESCRIPTION_PARAM;
import static fish.payara.security.openid.api.OpenIdConstant.ERROR_PARAM;
import static fish.payara.security.openid.api.OpenIdConstant.EXPIRES_IN;
import static fish.payara.security.openid.api.OpenIdConstant.REFRESH_TOKEN;
import static fish.payara.security.openid.api.OpenIdConstant.STATE;
import static fish.payara.security.openid.api.OpenIdConstant.TOKEN_TYPE;
import static jakarta.security.enterprise.AuthenticationStatus.*;
import static jakarta.security.enterprise.identitystore.CredentialValidationResult.INVALID_RESULT;
import static jakarta.security.enterprise.identitystore.CredentialValidationResult.NOT_VALIDATED_RESULT;
import static java.util.Objects.isNull;
import static java.util.Objects.nonNull;
import static java.util.logging.Level.INFO;
Expand Down
Loading

0 comments on commit a66a183

Please sign in to comment.