-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5212 from OndroMih/Community-FISH-84-enterprise-ear
FISH-84 Fix for using EL to configure OpenId in EAR
- Loading branch information
Showing
9 changed files
with
358 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
...ra-samples/samples/openid/src/main/java/fish/payara/security/oidc/client/ear/SomeEJB.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package fish.payara.security.oidc.client.ear; | ||
|
||
import javax.ejb.Stateless; | ||
|
||
@Stateless | ||
public class SomeEJB { | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...les/openid/src/main/java/fish/payara/security/oidc/client/eltests/OpenidConfigBeanEL.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
* | ||
* Copyright (c) [2021] Payara Foundation and/or its affiliates. All rights reserved. | ||
* | ||
* The contents of this file are subject to the terms of either the GNU | ||
* General Public License Version 2 only ("GPL") or the Common Development | ||
* and Distribution License("CDDL") (collectively, the "License"). You | ||
* may not use this file except in compliance with the License. You can | ||
* obtain a copy of the License at | ||
* https://github.com/payara/Payara/blob/master/LICENSE.txt | ||
* See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
* When distributing the software, include this License Header Notice in each | ||
* file and include the License file at glassfish/legal/LICENSE.txt. | ||
* | ||
* GPL Classpath Exception: | ||
* The Payara Foundation designates this particular file as subject to the "Classpath" | ||
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License | ||
* file that accompanied this code. | ||
* | ||
* Modifications: | ||
* If applicable, add the following below the License Header, with the fields | ||
* enclosed by brackets [] replaced by your own identifying information: | ||
* "Portions Copyright [year] [name of copyright owner]" | ||
* | ||
* Contributor(s): | ||
* If you wish your version of this file to be governed by only the CDDL or | ||
* only the GPL Version 2, indicate your decision by adding "[Contributor] | ||
* elects to include this software in this distribution under the [CDDL or GPL | ||
* Version 2] license." If you don't indicate a single choice of license, a | ||
* recipient has the option to distribute your version of this file under | ||
* either the CDDL, the GPL Version 2 or to extend the choice of license to | ||
* its licensees as provided above. However, if you add GPL Version 2 code | ||
* and therefore, elected the GPL Version 2 license, then the option applies | ||
* only if the new code is made subject to such option by the copyright | ||
* holder. | ||
*/ | ||
package fish.payara.security.oidc.client.eltests; | ||
|
||
import javax.inject.Named; | ||
|
||
@Named | ||
public class OpenidConfigBeanEL { | ||
|
||
public String getTokenEndpointURL() { | ||
return "http://localhost:8080/openid-server/webresources/oidc-provider"; | ||
} | ||
|
||
} |
74 changes: 74 additions & 0 deletions
74
.../samples/openid/src/main/java/fish/payara/security/oidc/client/eltests/SecuredPageEL.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
* | ||
* Copyright (c) [2021] Payara Foundation and/or its affiliates. All rights reserved. | ||
* | ||
* The contents of this file are subject to the terms of either the GNU | ||
* General Public License Version 2 only ("GPL") or the Common Development | ||
* and Distribution License("CDDL") (collectively, the "License"). You | ||
* may not use this file except in compliance with the License. You can | ||
* obtain a copy of the License at | ||
* https://github.com/payara/Payara/blob/master/LICENSE.txt | ||
* See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
* When distributing the software, include this License Header Notice in each | ||
* file and include the License file at glassfish/legal/LICENSE.txt. | ||
* | ||
* GPL Classpath Exception: | ||
* The Payara Foundation designates this particular file as subject to the "Classpath" | ||
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License | ||
* file that accompanied this code. | ||
* | ||
* Modifications: | ||
* If applicable, add the following below the License Header, with the fields | ||
* enclosed by brackets [] replaced by your own identifying information: | ||
* "Portions Copyright [year] [name of copyright owner]" | ||
* | ||
* Contributor(s): | ||
* If you wish your version of this file to be governed by only the CDDL or | ||
* only the GPL Version 2, indicate your decision by adding "[Contributor] | ||
* elects to include this software in this distribution under the [CDDL or GPL | ||
* Version 2] license." If you don't indicate a single choice of license, a | ||
* recipient has the option to distribute your version of this file under | ||
* either the CDDL, the GPL Version 2 or to extend the choice of license to | ||
* its licensees as provided above. However, if you add GPL Version 2 code | ||
* and therefore, elected the GPL Version 2 license, then the option applies | ||
* only if the new code is made subject to such option by the copyright | ||
* holder. | ||
*/ | ||
package fish.payara.security.oidc.client.eltests; | ||
|
||
import fish.payara.security.annotations.OpenIdAuthenticationDefinition; | ||
import static fish.payara.security.oidc.server.OidcProvider.CLIENT_ID_VALUE; | ||
import static fish.payara.security.oidc.server.OidcProvider.CLIENT_SECRET_VALUE; | ||
import java.io.IOException; | ||
import javax.annotation.security.DeclareRoles; | ||
import javax.servlet.ServletException; | ||
import javax.servlet.annotation.HttpConstraint; | ||
import javax.servlet.annotation.ServletSecurity; | ||
import javax.servlet.annotation.WebServlet; | ||
import javax.servlet.http.HttpServlet; | ||
import javax.servlet.http.HttpServletRequest; | ||
import javax.servlet.http.HttpServletResponse; | ||
|
||
/** | ||
* @author Gaurav Gupta | ||
*/ | ||
@WebServlet("/Secured") | ||
@OpenIdAuthenticationDefinition( | ||
providerURI = "#{openidConfigBeanEL.tokenEndpointURL}", | ||
clientId = CLIENT_ID_VALUE, | ||
clientSecret = CLIENT_SECRET_VALUE, | ||
redirectURI = "${baseURL}/Callback" | ||
) | ||
@DeclareRoles("all") | ||
@ServletSecurity(@HttpConstraint(rolesAllowed = "all")) | ||
public class SecuredPageEL extends HttpServlet { | ||
|
||
@Override | ||
protected void doGet(HttpServletRequest request, HttpServletResponse response) | ||
throws ServletException, IOException { | ||
response.getWriter().println("This is a secured web page"); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...erver/tests/payara-samples/samples/openid/src/main/resources/ear/META-INF/application.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<application xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee/ http://xmlns.jcp.org/xml/ns/javaee/application_8.xsd" version="8"> | ||
<display-name>ElBugExample-ear</display-name> | ||
<module> | ||
<web> | ||
<web-uri>openid-client.war</web-uri> | ||
<context-root>/openid-client</context-root> | ||
</web> | ||
</module> | ||
<module> | ||
<ejb>openid-client-dummy-ejb.jar</ejb> | ||
</module> | ||
</application> |
85 changes: 85 additions & 0 deletions
85
...amples/samples/openid/src/test/java/fish/payara/security/oidc/test/OpenIdELInEarTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
* | ||
* Copyright (c) [2018-2021] Payara Foundation and/or its affiliates. All rights reserved. | ||
* | ||
* The contents of this file are subject to the terms of either the GNU | ||
* General Public License Version 2 only ("GPL") or the Common Development | ||
* and Distribution License("CDDL") (collectively, the "License"). You | ||
* may not use this file except in compliance with the License. You can | ||
* obtain a copy of the License at | ||
* https://github.com/payara/Payara/blob/master/LICENSE.txt | ||
* See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
* When distributing the software, include this License Header Notice in each | ||
* file and include the License file at glassfish/legal/LICENSE.txt. | ||
* | ||
* GPL Classpath Exception: | ||
* The Payara Foundation designates this particular file as subject to the "Classpath" | ||
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License | ||
* file that accompanied this code. | ||
* | ||
* Modifications: | ||
* If applicable, add the following below the License Header, with the fields | ||
* enclosed by brackets [] replaced by your own identifying information: | ||
* "Portions Copyright [year] [name of copyright owner]" | ||
* | ||
* Contributor(s): | ||
* If you wish your version of this file to be governed by only the CDDL or | ||
* only the GPL Version 2, indicate your decision by adding "[Contributor] | ||
* elects to include this software in this distribution under the [CDDL or GPL | ||
* Version 2] license." If you don't indicate a single choice of license, a | ||
* recipient has the option to distribute your version of this file under | ||
* either the CDDL, the GPL Version 2 or to extend the choice of license to | ||
* its licensees as provided above. However, if you add GPL Version 2 code | ||
* and therefore, elected the GPL Version 2 license, then the option applies | ||
* only if the new code is made subject to such option by the copyright | ||
* holder. | ||
*/ | ||
package fish.payara.security.oidc.test; | ||
|
||
import com.gargoylesoftware.htmlunit.WebClient; | ||
import fish.payara.samples.NotMicroCompatible; | ||
import fish.payara.samples.PayaraArquillianTestRunner; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.OperateOnDeployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* | ||
* @author Gaurav Gupta | ||
*/ | ||
@NotMicroCompatible | ||
@RunWith(PayaraArquillianTestRunner.class) | ||
public class OpenIdELInEarTest { | ||
|
||
@OperateOnDeployment("openid-client") | ||
@ArquillianResource | ||
private URL base; | ||
|
||
@Deployment(name = "openid-server") | ||
public static WebArchive createServerDeployment() { | ||
return OpenIdTestUtil.createServerDeployment(); | ||
} | ||
|
||
@Deployment(name = "openid-client") | ||
public static EnterpriseArchive createClientDeployment() { | ||
return OpenIdTestUtil.createClientDeploymentForELInEarTest(); | ||
} | ||
|
||
@Test | ||
@RunAsClient | ||
public void testOpenIdConnect() throws IOException { | ||
WebClient webClient = new WebClient(); | ||
OpenIdTestUtil.testOpenIdConnect(webClient, base); | ||
} | ||
|
||
} |
84 changes: 84 additions & 0 deletions
84
...ara-samples/samples/openid/src/test/java/fish/payara/security/oidc/test/OpenIdELTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/* | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. | ||
* | ||
* Copyright (c) [2018-2021] Payara Foundation and/or its affiliates. All rights reserved. | ||
* | ||
* The contents of this file are subject to the terms of either the GNU | ||
* General Public License Version 2 only ("GPL") or the Common Development | ||
* and Distribution License("CDDL") (collectively, the "License"). You | ||
* may not use this file except in compliance with the License. You can | ||
* obtain a copy of the License at | ||
* https://github.com/payara/Payara/blob/master/LICENSE.txt | ||
* See the License for the specific | ||
* language governing permissions and limitations under the License. | ||
* | ||
* When distributing the software, include this License Header Notice in each | ||
* file and include the License file at glassfish/legal/LICENSE.txt. | ||
* | ||
* GPL Classpath Exception: | ||
* The Payara Foundation designates this particular file as subject to the "Classpath" | ||
* exception as provided by the Payara Foundation in the GPL Version 2 section of the License | ||
* file that accompanied this code. | ||
* | ||
* Modifications: | ||
* If applicable, add the following below the License Header, with the fields | ||
* enclosed by brackets [] replaced by your own identifying information: | ||
* "Portions Copyright [year] [name of copyright owner]" | ||
* | ||
* Contributor(s): | ||
* If you wish your version of this file to be governed by only the CDDL or | ||
* only the GPL Version 2, indicate your decision by adding "[Contributor] | ||
* elects to include this software in this distribution under the [CDDL or GPL | ||
* Version 2] license." If you don't indicate a single choice of license, a | ||
* recipient has the option to distribute your version of this file under | ||
* either the CDDL, the GPL Version 2 or to extend the choice of license to | ||
* its licensees as provided above. However, if you add GPL Version 2 code | ||
* and therefore, elected the GPL Version 2 license, then the option applies | ||
* only if the new code is made subject to such option by the copyright | ||
* holder. | ||
*/ | ||
package fish.payara.security.oidc.test; | ||
|
||
import com.gargoylesoftware.htmlunit.WebClient; | ||
import fish.payara.samples.NotMicroCompatible; | ||
import fish.payara.samples.PayaraArquillianTestRunner; | ||
import java.io.IOException; | ||
import java.net.URL; | ||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.container.test.api.OperateOnDeployment; | ||
import org.jboss.arquillian.container.test.api.RunAsClient; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
/** | ||
* | ||
* @author Gaurav Gupta | ||
*/ | ||
@NotMicroCompatible | ||
@RunWith(PayaraArquillianTestRunner.class) | ||
public class OpenIdELTest { | ||
|
||
@OperateOnDeployment("openid-client") | ||
@ArquillianResource | ||
private URL base; | ||
|
||
@Deployment(name = "openid-server") | ||
public static WebArchive createServerDeployment() { | ||
return OpenIdTestUtil.createServerDeployment(); | ||
} | ||
|
||
@Deployment(name = "openid-client") | ||
public static WebArchive createClientDeployment() { | ||
return OpenIdTestUtil.createClientDeploymentForELTest(); | ||
} | ||
|
||
@Test | ||
@RunAsClient | ||
public void testOpenIdConnect() throws IOException { | ||
WebClient webClient = new WebClient(); | ||
OpenIdTestUtil.testOpenIdConnect(webClient, base); | ||
} | ||
|
||
} |
Oops, something went wrong.