Skip to content

Event System

The Byteria SDK provides comprehensive event coverage across all security and operational domains:

Initialization Events:

  • INIT_COMPLETE: SDK initialization successful
  • INIT_FAILED: SDK initialization failed
  • FIRST_INIT: First-time initialization
  • INVALID_APP_KEY: Invalid application key provided

Security Events:

  • THREAT_DETECTED: Security threat identified
  • SECURE_DEVICE: Device verified as secure
  • INVALID_DATE_OR_TIME: Device date/time is invalid
  • SCAN_SUCCESS: Security scan completed
  • SCAN_RESPONSE: Scan results available
  • SCAN_FAILED: Security scan failed
  • RISK_FACTOR_DETECTED: A risk factor was detected during a scan

Network Events:

  • NETWORK_INIT: Network initialization
  • NETWORK_MTLS: mTLS connection established
  • JWT_AUTH_SUCCESS: JWT authentication successful
  • NETWORK_ERROR: Network connectivity error
  • AUTH_FAILED: Authentication failed
  • REQUEST_FAILED: API request failed

Storage Events:

  • KEYSTORE_SUCCESS: Keystore operation successful
  • KEYSTORE_FAILED: Keystore operation failed
  • KEY_EXCHANGE_SUCCESS: Key exchange completed
  • KEYS_FOUND_STORAGE: Existing keys found
  • KEYS_CREATED_NEW: New keys created

Callback Events:

  • CALLBACK_SUCCESS: Callback operation successful
  • CALLBACK_FAILED: Callback operation failed

Complete Event Processing:

public class ComprehensiveEventHandler implements AlphynSecurityListener {
@Override
public void onSuccess(AlphynCallbackResult result) {
logEvent("SUCCESS", result);
// Route to specific handlers based on operation type
switch (result.getOperationType()) {
case INITIALIZATION:
handleInitializationSuccess(result);
break;
case SECURITY_SCAN:
handleSecuritySuccess(result);
break;
case SCAN_RESPONSE:
handleScanResponse(result);
break;
case NETWORK:
// Network events are informational - no action required
Log.d("ByteriaNetwork", result.getOriginalEventType() + ": " + result.getMessage());
break;
case STORAGE:
// Storage events are informational - no action required
Log.d("ByteriaStorage", result.getOriginalEventType() + ": " + result.getMessage());
break;
case CALLBACK:
handleCallbackSuccess(result);
break;
}
}
@Override
public void onFailure(AlphynCallbackResult result) {
logEvent("FAILURE", result);
// Handle failures with appropriate recovery strategies
switch (result.getOperationType()) {
case INITIALIZATION:
handleInitializationFailure(result);
break;
case NETWORK:
// Network failures are handled automatically by SDK with retry logic
Log.w("ByteriaNetwork", "Network issue (SDK handling): " + result.getMessage());
break;
case STORAGE:
// Storage failures are handled automatically by SDK with fallback mechanisms
Log.w("ByteriaStorage", "Storage issue (SDK handling): " + result.getMessage());
break;
default:
handleGenericFailure(result);
break;
}
}
@Override
public void onThreatDetected(AlphynCallbackResult result) {
logEvent("THREAT", result);
// Immediate threat response
ThreatResponse response = evaluateThreat(result);
executeThreatResponse(response);
}
private void logEvent(String category, AlphynCallbackResult result) {
Log.i("ByteriaEvents", String.format("[%s] %s: %s (%s)",
category,
result.getOperationType(),
result.getOriginalEventType(),
result.getMessage()));
}
}

Event Flow Management:

public class EventLifecycleManager {
private final Map<AlphynEventType, Long> eventTimestamps = new HashMap<>();
private final List<EventListener> listeners = new ArrayList<>();
public void trackEvent(AlphynCallbackResult result) {
AlphynEventType eventType = result.getOriginalEventType();
long timestamp = System.currentTimeMillis();
// Record event timing
eventTimestamps.put(eventType, timestamp);
// Analyze event patterns
analyzeEventPattern(eventType, timestamp);
// Notify listeners
notifyEventListeners(result);
}
private void analyzeEventPattern(AlphynEventType eventType, long timestamp) {
// Implement event pattern analysis
Long lastEvent = eventTimestamps.get(eventType);
if (lastEvent != null) {
long interval = timestamp - lastEvent;
Log.d("EventAnalysis", String.format("Event %s interval: %dms",
eventType, interval));
}
}
public interface EventListener {
void onEventProcessed(AlphynCallbackResult result);
}
}