Class RocketRestSecureConfig

  • All Implemented Interfaces:
    RocketSSL.SSLConfig

    public class RocketRestSecureConfig
    extends RocketRestConfig
    implements RocketSSL.SSLConfig
    Extended configuration for RocketRest clients requiring custom SSL/TLS certificates.

    This class extends RocketRestConfig to provide support for custom SSL certificates, enabling secure connections to APIs that use self-signed certificates, custom certificate authorities, or require mutual TLS (mTLS) authentication.

    When to Use

    • Connecting to APIs with self-signed SSL certificates
    • Corporate environments with internal certificate authorities
    • Mutual TLS (mTLS) authentication requirements
    • Development/staging environments with non-production certificates

    Basic Usage

    
     RocketRestSecureConfig config = RocketRestSecureConfig
         .secureBuilder("https://secure-api.internal.corp")
         .withCustomCertificate("/path/to/keystore.p12", "keystorePassword")
         .authStrategy(AuthStrategyFactory.createBearerToken("api-token"))
         .build();
    
     RocketRest client = new RocketRest(config);
     SecureData data = client.get("/secure/data", SecureData.class);
     

    With OAuth2 and Custom Certificate

    
     RocketRestSecureConfig config = RocketRestSecureConfig
         .secureBuilder("https://api.internal.corp")
         .withCustomCertificate("client-cert.p12", "certPassword")
         .authStrategy(AuthStrategyFactory.createOAuth2ClientCredentials(
             "client-id",
             "client-secret",
             "https://auth.internal.corp/oauth/token"
         ))
         .tokenUrl("https://auth.internal.corp/oauth/token")
         .defaultOptions(opts -> {
             opts.set(RocketRestOptions.RETRY_ENABLED, true);
             opts.set(RocketRestOptions.MAX_RETRIES, 3);
         })
         .build();
    
     RocketRest client = new RocketRest(config);
     
    Since:
    1.0.0
    Author:
    guinetik <guinetik@gmail.com>
    See Also:
    RocketRestConfig, RocketSSL, RocketRest