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

The following examples show how to use org.eclipse.microprofile.jwt.tck.container.jaxrs.TCKApplication. 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 File: PublicKeyAsPEMTest.java    From microprofile-jwt-auth with 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
Source File: ECPublicKeyAsPEMTest.java    From microprofile-jwt-auth with Apache License 2.0 6 votes vote down vote up
/**
 * 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 File: TokenAsCookieTest.java    From microprofile-jwt-auth with 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
Source File: TokenAsCookieIgnoredTest.java    From microprofile-jwt-auth with 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_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 File: ServletTest.java    From microprofile-jwt-auth with 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
Source File: RolesAllowedSignEncryptTest.java    From microprofile-jwt-auth with 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 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 File: EjbTest.java    From microprofile-jwt-auth with 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 File: ExpClaimValidationTest.java    From tomee with 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
Source File: IssNoValidationNoIssTest.java    From microprofile-jwt-auth with 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 = 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
Source File: IssValidationFailTest.java    From microprofile-jwt-auth with 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 = 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 File: IssValidationTest.java    From microprofile-jwt-auth with 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
Source File: IssNoValidationBadIssTest.java    From microprofile-jwt-auth with 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 = 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 File: SubjectTest.java    From microprofile-jwt-auth with 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
Source File: RolesAllowedEncryptTest.java    From microprofile-jwt-auth with 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 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 File: TestArchive.java    From thorntail with 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
Source File: ExpClaimAllowMissingExpValidationTest.java    From tomee with 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 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;
}