Java Code Examples for org.eclipse.microprofile.jwt.tck.container.jaxrs.TCKApplication

The following examples show how to use org.eclipse.microprofile.jwt.tck.container.jaxrs.TCKApplication. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: microprofile-jwt-auth   Source File: PublicKeyAsPEMTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive that includes an embedded PEM public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment()
public static WebArchive createDeployment() throws IOException {
    URL publicKey = PublicKeyAsPEMTest.class.getResource("/publicKey4k.pem");
    // This mp.jwt.verify.publickey value is an embedded PEM key
    URL config = PublicKeyAsPEMTest.class.getResource("/META-INF/microprofile-config-publickey.properties");

    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "PublicKeyAsPEMTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addAsResource(publicKey, "/publicKey.pem")
            .addClass(PublicKeyEndpoint.class)
            .addClass(TCKApplication.class)
            .addClass(SimpleTokenUtils.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(config, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 2
/**
 * Create a CDI aware base web application archive that includes an embedded PEM EC public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment()
public static WebArchive createDeployment() throws IOException {
    // This mp.jwt.verify.publickey value is an embedded PEM key
    URL config = ECPublicKeyAsPEMTest.class.getResource("/META-INF/microprofile-config-ecpublickey.properties");

    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "PublicKeyAsPEMTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addClass(PublicKeyEndpoint.class)
            .addClass(TCKApplication.class)
            .addClass(SimpleTokenUtils.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(config, "microprofile-config.properties");
    return webArchive;
}
 
Example 3
Source Project: microprofile-jwt-auth   Source File: TokenAsCookieTest.java    License: Apache License 2.0 6 votes vote down vote up
@Deployment
public static WebArchive createDeployment() throws IOException {
    Properties configProps = new Properties();
    configProps.setProperty(VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey.pem");
    configProps.setProperty(ISSUER, TCKConstants.TEST_ISSUER);
    configProps.setProperty(TOKEN_HEADER, "Cookie");
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "PublicKeyAsJWKTest JWK microprofile-config.properties");
    StringAsset config = new StringAsset(configSW.toString());

    URL publicKey = InvalidTokenTest.class.getResource("/publicKey.pem");
    return ShrinkWrap
        .create(WebArchive.class, "TokenAsCookie.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(TCKApplication.class)
        .addClass(RolesEndpoint.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
}
 
Example 4
@Deployment
public static WebArchive createDeployment() throws IOException {
    Properties configProps = new Properties();
    configProps.setProperty(VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey.pem");
    configProps.setProperty(ISSUER, TCKConstants.TEST_ISSUER);
    configProps.setProperty(TOKEN_COOKIE, "Authorization");
    configProps.setProperty(TOKEN_COOKIE, "jwt");
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "PublicKeyAsJWKTest JWK microprofile-config.properties");
    StringAsset config = new StringAsset(configSW.toString());

    URL publicKey = InvalidTokenTest.class.getResource("/publicKey.pem");
    return ShrinkWrap
        .create(WebArchive.class, "TokenAsCookie.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(TCKApplication.class)
        .addClass(RolesEndpoint.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
}
 
Example 5
Source Project: microprofile-jwt-auth   Source File: ServletTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL publicKey = ServletTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "ServletTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(EjbEndpoint.class)
        .addClass(ServiceServlet.class)
        .addClass(IService.class)
        .addClass(ServiceEJB.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
        ;
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 6
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL config = RolesAllowedSignEncryptTest.class.getResource("/META-INF/microprofile-config-verify-decrypt.properties");
    URL verifyKey = RolesAllowedSignEncryptTest.class.getResource("/publicKey4k.pem");
    URL decryptKey = RolesAllowedSignEncryptTest.class.getResource("/privateKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "RolesAllowedSignEncryptTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(decryptKey, "/privateKey.pem")
        .addAsResource(verifyKey, "/publicKey4k.pem")
        .addClass(RolesEndpoint.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
    return webArchive;
}
 
Example 7
Source Project: microprofile-jwt-auth   Source File: EjbTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL publicKey = EjbTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "EjbTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(EjbEndpoint.class)
        .addClass(IService.class)
        .addClass(ServiceEJB.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
        ;
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 8
Source Project: tomee   Source File: ExpClaimValidationTest.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Create a CDI aware base web application archive that includes an embedded PEM public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment()
public static WebArchive createDeployment() throws IOException {
    URL publicKey = ExpClaimValidationTest.class.getResource("/publicKey4k.pem");

    Properties configProps = new Properties();
    // Location points to the PEM bundled in the deployment
    configProps.setProperty(Names.VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey4k.pem");
    //configProps.setProperty(Names.REQUIRE_ISS, "true");
    configProps.setProperty(Names.ISSUER, TCKConstants.TEST_ISSUER);
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "IssValidationTest microprofile-config.properties");
    StringAsset configAsset = new StringAsset(configSW.toString());

    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "ExpClaimValidationTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addAsResource(publicKey, "/publicKey4k.pem")
            .addClass(PublicKeyEndpoint.class)
            .addClass(TCKApplication.class)
            .addClass(SimpleTokenUtils.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(configAsset, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 9
/**
 * Create a CDI aware base web application archive that includes an embedded PEM public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /
 * @return the base base web application archive
 * @throws Exception - on resource failure
 */
@Deployment()
public static WebArchive createDeployment() throws Exception {
    URL publicKey = IssNoValidationNoIssTest.class.getResource("/publicKey4k.pem");

    PrivateKey privateKey = TokenUtils.readPrivateKey("/privateKey4k.pem");
    String kid = "publicKey4k";
    HashMap<String, Long> timeClaims = new HashMap<>();
    token = TokenUtils.generateTokenString(privateKey, kid, "/TokenNoIss.json", null, timeClaims);

    // Setup the microprofile-config.properties content
    Properties configProps = new Properties();
    // Location points to the PEM bundled in the deployment
    configProps.setProperty(Names.VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey4k.pem");
    // Don't require validation of iss claim
    //configProps.setProperty(Names.REQUIRE_ISS, "false");
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "IssNoValidationNoIssTest microprofile-config.properties");
    StringAsset configAsset = new StringAsset(configSW.toString());

    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "IssNoValidationNoIssTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addAsResource(publicKey, "/publicKey4k.pem")
        // Include the token for inspection by ApplicationArchiveProcessor
        .add(new StringAsset(token), "MP-JWT")
        .addClass(PublicKeyEndpoint.class)
        .addClass(TCKApplication.class)
        .addClass(SimpleTokenUtils.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(configAsset, "microprofile-config.properties")
        ;
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 10
/**
 * Create a CDI aware base web application archive that includes an embedded PEM public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /
 * @return the base base web application archive
 * @throws Exception - on resource failure
 */
@Deployment()
public static WebArchive createDeployment() throws Exception {
    URL publicKey = IssValidationFailTest.class.getResource("/publicKey4k.pem");

    PrivateKey privateKey = TokenUtils.readPrivateKey("/privateKey4k.pem");
    String kid = "publicKey4k";
    HashMap<String, Long> timeClaims = new HashMap<>();
    token = TokenUtils.generateTokenString(privateKey, kid, "/RequiredClaims.json", null, timeClaims);

    // Setup the microprofile-config.properties content
    Properties configProps = new Properties();
    // Location points to the PEM bundled in the deployment
    configProps.setProperty(Names.VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey4k.pem");
    // Set an invalid mp.jwt.verify.issuer value
    configProps.setProperty(Names.ISSUER, "https://IssValidationFailTest");
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "IssValidationFailTest microprofile-config.properties");
    StringAsset configAsset = new StringAsset(configSW.toString());

    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "IssValidationFailTest.war")
            .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addAsResource(publicKey, "/publicKey.pem")
            .addAsResource(publicKey, "/publicKey4k.pem")
            // Include the token for inspection by ApplicationArchiveProcessor
            .add(new StringAsset(token), "MP-JWT")
            .addClass(PublicKeyEndpoint.class)
            .addClass(TCKApplication.class)
            .addClass(SimpleTokenUtils.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(configAsset, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 11
Source Project: microprofile-jwt-auth   Source File: IssValidationTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a CDI aware base web application archive that includes an embedded PEM public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /
 * @return the base base web application archive
 * @throws Exception - on resource failure
 */
@Deployment()
public static WebArchive createDeployment() throws Exception {
    URL publicKey = IssValidationTest.class.getResource("/publicKey4k.pem");

    PrivateKey privateKey = TokenUtils.readPrivateKey("/privateKey4k.pem");
    String kid = "publicKey4k";
    HashMap<String, Long> timeClaims = new HashMap<>();
    token = TokenUtils.generateTokenString(privateKey, kid, "/RequiredClaims.json", null, timeClaims);

    // Setup the microprofile-config.properties content
    Properties configProps = new Properties();
    // Location points to the PEM bundled in the deployment
    configProps.setProperty(Names.VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey4k.pem");
    //configProps.setProperty(Names.REQUIRE_ISS, "true");
    configProps.setProperty(Names.ISSUER, TCKConstants.TEST_ISSUER);
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "IssValidationTest microprofile-config.properties");
    StringAsset configAsset = new StringAsset(configSW.toString());

    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "IssValidationTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addAsResource(publicKey, "/publicKey4k.pem")
        // Include the token for inspection by ApplicationArchiveProcessor
        .add(new StringAsset(token), "MP-JWT")
        .addClass(PublicKeyEndpoint.class)
        .addClass(TCKApplication.class)
        .addClass(SimpleTokenUtils.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(configAsset, "microprofile-config.properties")
        ;
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 12
/**
 * Create a CDI aware base web application archive that includes an embedded PEM public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /
 * @return the base base web application archive
 * @throws Exception - on resource failure
 */
@Deployment()
public static WebArchive createDeployment() throws Exception {
    URL publicKey = IssNoValidationBadIssTest.class.getResource("/publicKey4k.pem");

    PrivateKey privateKey = TokenUtils.readPrivateKey("/privateKey4k.pem");
    String kid = "publicKey4k";
    HashMap<String, Long> timeClaims = new HashMap<>();
    token = TokenUtils.generateTokenString(privateKey, kid, "/TokenBadIss.json", null, timeClaims);

    // Setup the microprofile-config.properties content
    Properties configProps = new Properties();
    // Location points to the PEM bundled in the deployment
    configProps.setProperty(Names.VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey4k.pem");
    // Don't require validation of iss claim
    //configProps.setProperty(Names.REQUIRE_ISS, "false");
    // The issuer config value should be ignored
    configProps.setProperty(Names.ISSUER, "https://ignore-me");
    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "IssNoValidationBadIssTest microprofile-config.properties");
    StringAsset configAsset = new StringAsset(configSW.toString());

    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "IssNoValidationBadIssTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addAsResource(publicKey, "/publicKey4k.pem")
        // Include the token for inspection by ApplicationArchiveProcessor
        .add(new StringAsset(token), "MP-JWT")
        .addClass(PublicKeyEndpoint.class)
        .addClass(TCKApplication.class)
        .addClass(SimpleTokenUtils.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(configAsset, "microprofile-config.properties")
        ;
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 13
Source Project: microprofile-jwt-auth   Source File: SubjectTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL publicKey = SubjectTest.class.getResource("/publicKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "SubjectTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_0.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(publicKey, "/publicKey.pem")
        .addClass(SubjectEndpoint.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml")
        ;
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}
 
Example 14
/**
 * Create a CDI aware base web application archive
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment(testable=true)
public static WebArchive createDeployment() throws IOException {
    URL config = RolesAllowedEncryptTest.class.getResource("/META-INF/microprofile-config-decrypt.properties");
    URL privateKey = RolesAllowedEncryptTest.class.getResource("/privateKey.pem");
    WebArchive webArchive = ShrinkWrap
        .create(WebArchive.class, "RolesAllowedEncryptTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_2.name()), MpJwtTestVersion.MANIFEST_NAME)
        .addAsResource(privateKey, "/privateKey.pem")
        .addClass(RolesEndpoint.class)
        .addClass(TCKApplication.class)
        .addAsWebInfResource("beans.xml", "beans.xml")
        .addAsManifestResource(config, "microprofile-config.properties");
    return webArchive;
}
 
Example 15
Source Project: thorntail   Source File: TestArchive.java    License: Apache License 2.0 5 votes vote down vote up
public static WebArchive createBase(Class<?> testClass) {
    URL publicKey = TestArchive.class.getResource("/publicKey.pem");
    return ShrinkWrap.create(WebArchive.class, testClass.getSimpleName() + SUFFIX)
            .addAsResource(publicKey, "/publicKey.pem")
            .addClass(TCKApplication.class)
            .addAsWebInfResource(EmptyAsset.INSTANCE, "beans.xml");
}
 
Example 16
/**
 * Create a CDI aware base web application archive that includes an embedded PEM public key
 * that is included as the mp.jwt.verify.publickey property.
 * The root url is /
 * @return the base base web application archive
 * @throws IOException - on resource failure
 */
@Deployment()
public static WebArchive createDeployment() throws IOException {
    URL publicKey = ExpClaimAllowMissingExpValidationTest.class.getResource("/publicKey4k.pem");

    Properties configProps = new Properties();
    // Location points to the PEM bundled in the deployment
    configProps.setProperty(Names.VERIFIER_PUBLIC_KEY_LOCATION, "/publicKey4k.pem");
    //configProps.setProperty(Names.REQUIRE_ISS, "true");
    configProps.setProperty(Names.ISSUER, TCKConstants.TEST_ISSUER);
    configProps.setProperty("mp.jwt.tomee.allow.no-exp", "true");

    StringWriter configSW = new StringWriter();
    configProps.store(configSW, "IssValidationTest microprofile-config.properties");
    StringAsset configAsset = new StringAsset(configSW.toString());

    WebArchive webArchive = ShrinkWrap
            .create(WebArchive.class, "ExpClaimValidationTest.war")
        .addAsManifestResource(new StringAsset(MpJwtTestVersion.MPJWT_V_1_1.name()), MpJwtTestVersion.MANIFEST_NAME)
            .addAsResource(publicKey, "/publicKey4k.pem")
            .addClass(PublicKeyEndpoint.class)
            .addClass(TCKApplication.class)
            .addClass(SimpleTokenUtils.class)
            .addAsWebInfResource("beans.xml", "beans.xml")
            .addAsManifestResource(configAsset, "microprofile-config.properties");
    System.out.printf("WebArchive: %s\n", webArchive.toString(true));
    return webArchive;
}