gxandroidpublisher/src/main/java/com/genexus/sd/store/validation/platforms/AndroidPublisherHelper.java
/**
     * Performs all necessary setup steps for running requests against the API.
     *
     * @param applicationName the name of the application: com.example.app
     * @param serviceAccountEmail the Service Account Email (empty if using
     *            installed application)
     * @return the {@Link AndroidPublisher} service
     * @throws GeneralSecurityException
     * @throws IOException
     * @throws StoreConfigurationException 
     */
Performs all necessary setup steps for running requests against the API.
Performs all necessary setup steps for running requests against the API .
public static AndroidPublisher init(String applicationName,
             String serviceAccountEmail, String certPath, String certPassword) throws IOException, GeneralSecurityException, StoreConfigurationException {
		File f = new File(certPath);
		if (!f.isAbsolute()){
			f = new File(getPrivateDirectory(), certPath);
		}
		if (!f.exists()){
			throw new StoreConfigurationException("Google Play Certificate was not found at: " + certPath);
		}
    	FileInputStream is = new FileInputStream(f);
    	PrivateKey privateKey = SecurityUtils.loadPrivateKeyFromKeyStore(
    			SecurityUtils.getPkcs12KeyStore(), 
    			is, 
    			certPassword, "privatekey", certPassword);
    	if (privateKey == null){    		
    		throw new StoreConfigurationException("Private key could not be loaded: " + certPath);
    	}
        newTrustedTransport();
        GoogleCredential credential = new GoogleCredential.Builder()
        .setTransport(HTTP_TRANSPORT)
        .setJsonFactory(JSON_FACTORY)
        .setServiceAccountId(serviceAccountEmail)
        .setServiceAccountScopes(
                Collections.singleton("https://www.googleapis.com/auth/androidpublisher"))
        .setServiceAccountPrivateKey(privateKey)
        .build();
        return new AndroidPublisher.Builder(
                HTTP_TRANSPORT, JSON_FACTORY, credential).setApplicationName(applicationName)
                .build();
    }
public static AndroidPublisher init ( String applicationName , String serviceAccountEmail , String certPath , String certPassword ) throws IOException , GeneralSecurityException , StoreConfigurationException { File f = new File ( certPath ) ; if ( ! f . isAbsolute ( ) ) { f = new File ( getPrivateDirectory ( ) , certPath ) ; } if ( ! f . exists ( ) ) { throw new StoreConfigurationException ( "Google Play Certificate was not found at: " + certPath ) ; } FileInputStream is = new FileInputStream ( f ) ; PrivateKey privateKey = SecurityUtils . loadPrivateKeyFromKeyStore ( SecurityUtils . getPkcs12KeyStore ( ) , is , certPassword , "privatekey" , certPassword ) ; if ( privateKey == null ) { throw new StoreConfigurationException ( "Private key could not be loaded: " + certPath ) ; } newTrustedTransport ( ) ; GoogleCredential credential = new GoogleCredential . Builder ( ) . setTransport ( HTTP_TRANSPORT ) . setJsonFactory ( JSON_FACTORY ) . setServiceAccountId ( serviceAccountEmail ) . setServiceAccountScopes ( Collections . singleton ( "https://www.googleapis.com/auth/androidpublisher" ) ) . setServiceAccountPrivateKey ( privateKey ) . build ( ) ; return new AndroidPublisher . Builder ( HTTP_TRANSPORT , JSON_FACTORY , credential ) . setApplicationName ( applicationName ) . build ( ) ; }
Performs all necessary setup steps for running requests against the API.
Performs all necessary setup steps for running requests against the API .
// Set up and return API client.