Skip to main content

ParentalAIConfig Class Reference

The ParentalAIConfig class holds configuration settings required to initialize the Cirvia Parental SDK. It contains API credentials, endpoint URLs, and debugging options.

Package​

package com.cirvia.parentalai.config;

Class Declaration​

public class ParentalAIConfig

Overview​

ParentalAIConfig is a data container class that stores:

  • API authentication credentials
  • Backend service endpoint URLs
  • Debug logging preferences

This configuration is passed to ParentalAI.init() to establish connection with Cirvia services.

Constructor​

ParentalAIConfig()​

Creates a new configuration instance with all required parameters.

Signature​

public ParentalAIConfig(
String apiKey,
String ingestEndpoint,
String authEndpoint,
boolean debug
)

Parameters​

ParameterTypeRequiredDescription
apiKeyStringYesYour unique API key provided by Cirvia
ingestEndpointStringYesURL for content ingestion API
authEndpointStringYesURL for user authentication API
debugbooleanYesEnable/disable debug logging

Example​

ParentalAIConfig config = new ParentalAIConfig(
"pk_live_1234567890abcdef", // API key from Cirvia partnership
"https://api.cirvia.co/v1/ingest", // Ingest endpoint
"https://api.cirvia.co/auth/login", // Auth endpoint
BuildConfig.DEBUG // Debug only in development
);

Properties​

getApiKey()​

Returns the API key used for authenticating requests to Cirvia services.

Signature​

public String getApiKey()

Returns​

String - The API key configured for this instance

Example​

ParentalAIConfig config = new ParentalAIConfig(apiKey, ingestUrl, authUrl, true);
String key = config.getApiKey();
Log.d("Config", "Using API key: " + key.substring(0, 8) + "...");

getIngestEndpoint()​

Returns the URL endpoint for content ingestion API calls.

Signature​

public String getIngestEndpoint()

Returns​

String - The ingestion endpoint URL

Usage​

This endpoint receives all content monitoring data (text and images) for AI analysis.

Example​

String endpoint = config.getIngestEndpoint();
// Used internally by SDK for: POST {endpoint}/send

getAuthEndpoint()​

Returns the URL endpoint for user authentication API calls.

Signature​

public String getAuthEndpoint()

Returns​

String - The authentication endpoint URL

Usage​

This endpoint handles Google OAuth token exchange and user account management.

Example​

String authUrl = config.getAuthEndpoint();
// Used internally by SDK for: POST {authUrl}/login

isDebug()​

Returns whether debug logging is enabled for the SDK.

Signature​

public boolean isDebug()

Returns​

boolean - true if debug logging is enabled, false otherwise

Usage​

When debug mode is enabled, the SDK logs detailed information about:

  • Authentication flow
  • Content monitoring requests
  • API responses
  • Error details

Example​

if (config.isDebug()) {
Log.d("Config", "Debug mode enabled - verbose logging active");
}

Configuration Patterns​

Environment-Based Configuration​

public class ConfigFactory {

public static ParentalAIConfig createConfig() {
if (BuildConfig.DEBUG) {
return createDevelopmentConfig();
} else {
return createProductionConfig();
}
}

private static ParentalAIConfig createDevelopmentConfig() {
return new ParentalAIConfig(
BuildConfig.CIRVIA_DEV_API_KEY,
"https://dev-api.cirvia.co/v1/ingest",
"https://dev-api.cirvia.co/auth/login",
true // Enable debug logging
);
}

private static ParentalAIConfig createProductionConfig() {
return new ParentalAIConfig(
BuildConfig.CIRVIA_PROD_API_KEY,
"https://api.cirvia.co/v1/ingest",
"https://api.cirvia.co/auth/login",
false // Disable debug logging
);
}
}

Secure Configuration Storage​

In your app's build.gradle:

android {
buildTypes {
debug {
buildConfigField "String", "CIRVIA_API_KEY", "\"${CIRVIA_DEV_API_KEY}\""
buildConfigField "String", "CIRVIA_INGEST_URL", "\"${CIRVIA_DEV_INGEST_URL}\""
buildConfigField "String", "CIRVIA_AUTH_URL", "\"${CIRVIA_DEV_AUTH_URL}\""
}
release {
buildConfigField "String", "CIRVIA_API_KEY", "\"${CIRVIA_PROD_API_KEY}\""
buildConfigField "String", "CIRVIA_INGEST_URL", "\"${CIRVIA_PROD_INGEST_URL}\""
buildConfigField "String", "CIRVIA_AUTH_URL", "\"${CIRVIA_PROD_AUTH_URL}\""
}
}
}

Then in your code:

ParentalAIConfig config = new ParentalAIConfig(
BuildConfig.CIRVIA_API_KEY,
BuildConfig.CIRVIA_INGEST_URL,
BuildConfig.CIRVIA_AUTH_URL,
BuildConfig.DEBUG
);

Using Properties File​

Create assets/cirvia.properties:

api_key=pk_live_1234567890abcdef
ingest_endpoint=https://api.cirvia.co/v1/ingest
auth_endpoint=https://api.cirvia.co/auth/login

Load configuration:

public class ConfigLoader {

public static ParentalAIConfig loadFromAssets(Context context) {
try {
Properties props = new Properties();
props.load(context.getAssets().open("cirvia.properties"));

return new ParentalAIConfig(
props.getProperty("api_key"),
props.getProperty("ingest_endpoint"),
props.getProperty("auth_endpoint"),
BuildConfig.DEBUG
);
} catch (IOException e) {
throw new RuntimeException("Failed to load Cirvia configuration", e);
}
}
}

Configuration Validation​

public class ConfigValidator {

public static void validateConfig(ParentalAIConfig config) {
if (config == null) {
throw new IllegalArgumentException("ParentalAIConfig cannot be null");
}

validateApiKey(config.getApiKey());
validateEndpoint("ingest", config.getIngestEndpoint());
validateEndpoint("auth", config.getAuthEndpoint());
}

private static void validateApiKey(String apiKey) {
if (apiKey == null || apiKey.trim().isEmpty()) {
throw new IllegalArgumentException("API key is required");
}

if (!apiKey.startsWith("pk_")) {
throw new IllegalArgumentException("Invalid API key format");
}

if (apiKey.length() < 20) {
throw new IllegalArgumentException("API key appears to be invalid (too short)");
}
}

private static void validateEndpoint(String name, String endpoint) {
if (endpoint == null || endpoint.trim().isEmpty()) {
throw new IllegalArgumentException(name + " endpoint is required");
}

if (!endpoint.startsWith("https://")) {
throw new IllegalArgumentException(name + " endpoint must use HTTPS");
}

try {
new URL(endpoint);
} catch (MalformedURLException e) {
throw new IllegalArgumentException("Invalid " + name + " endpoint URL", e);
}
}
}

Configuration Examples​

Basic Usage​

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

// Create configuration with partnership credentials
ParentalAIConfig config = new ParentalAIConfig(
"pk_live_your_actual_api_key_here",
"https://api.cirvia.co/v1/ingest",
"https://api.cirvia.co/auth/login",
BuildConfig.DEBUG
);

// Initialize SDK
ParentalAI.init(this, config, this::onSDKReady, this::onSDKDeclined);
}
}

Application Class Setup​

public class MyApplication extends Application {
private ParentalAIConfig cirviaConfig;

@Override
public void onCreate() {
super.onCreate();
initializeCirviaConfig();
}

private void initializeCirviaConfig() {
cirviaConfig = new ParentalAIConfig(
getString(R.string.cirvia_api_key),
getString(R.string.cirvia_ingest_endpoint),
getString(R.string.cirvia_auth_endpoint),
BuildConfig.DEBUG
);

// Validate configuration
ConfigValidator.validateConfig(cirviaConfig);

// Initialize SDK
ParentalAI.init(this, cirviaConfig,
() -> Log.d("App", "Cirvia SDK ready"),
() -> Log.w("App", "Cirvia SDK declined")
);
}

public ParentalAIConfig getCirviaConfig() {
return cirviaConfig;
}
}

Dynamic Configuration​

public class ConfigManager {
private static ParentalAIConfig currentConfig;

public static ParentalAIConfig getConfig(Context context) {
if (currentConfig == null) {
currentConfig = loadConfiguration(context);
}
return currentConfig;
}

private static ParentalAIConfig loadConfiguration(Context context) {
SharedPreferences prefs = context.getSharedPreferences("cirvia", Context.MODE_PRIVATE);

String apiKey = prefs.getString("api_key", BuildConfig.CIRVIA_API_KEY);
String ingestUrl = prefs.getString("ingest_url", BuildConfig.CIRVIA_INGEST_URL);
String authUrl = prefs.getString("auth_url", BuildConfig.CIRVIA_AUTH_URL);
boolean debug = prefs.getBoolean("debug", BuildConfig.DEBUG);

return new ParentalAIConfig(apiKey, ingestUrl, authUrl, debug);
}

public static void updateConfiguration(Context context, ParentalAIConfig newConfig) {
SharedPreferences prefs = context.getSharedPreferences("cirvia", Context.MODE_PRIVATE);
prefs.edit()
.putString("api_key", newConfig.getApiKey())
.putString("ingest_url", newConfig.getIngestEndpoint())
.putString("auth_url", newConfig.getAuthEndpoint())
.putBoolean("debug", newConfig.isDebug())
.apply();

currentConfig = newConfig;
}
}

Security Considerations​

API Key Protection​

  • Never hardcode API keys in source code
  • Use BuildConfig or secure storage for credentials
  • Rotate keys regularly in production
  • Monitor usage for unauthorized access

Endpoint Security​

  • Always use HTTPS for production endpoints
  • Validate URLs before configuration
  • Use certificate pinning for additional security

Debug Mode​

  • Disable in production to prevent sensitive data logging
  • Use conditional compilation to remove debug code entirely
// Safe debug configuration
boolean debugMode = BuildConfig.DEBUG && !isProductionBuild();
ParentalAIConfig config = new ParentalAIConfig(apiKey, ingestUrl, authUrl, debugMode);

Error Handling​

Configuration Errors​

public static ParentalAIConfig createSafeConfig(Context context) {
try {
ParentalAIConfig config = ConfigFactory.createConfig();
ConfigValidator.validateConfig(config);
return config;
} catch (Exception e) {
Log.e("Config", "Failed to create valid configuration", e);

// Return default/fallback configuration
return createFallbackConfig();
}
}

private static ParentalAIConfig createFallbackConfig() {
return new ParentalAIConfig(
"pk_fallback_key",
"https://api.cirvia.co/v1/ingest",
"https://api.cirvia.co/auth/login",
false
);
}
  • ParentalAI - Main SDK class that uses this configuration
  • Logger - Internal logging utility controlled by debug flag

See Also​


Need partnership credentials? Contact info@cirvia.co to obtain your API key and endpoints.