AeroGear Android 1.1.0 Released

Posted By Hoyt Summers Pittman

I’ve been working with the AeroGear team to prepare a new release for Android and here it is.

New and Noteworthy

  • HTTP Digest Authentication Modules
  • HTTP Basic Authentication Modules
  • HTTP Multipart uploads
  • Configurable Request Builders
  • CI support provided by Travis-CI
  • Also we have begin to make changes necessary for breaking the assumption that JSON is the default serialization format and have introduced several new Interfaces for support this:

    • RequestBuilder
    • ResponseParser

    Internally we still assume JSON is used but that is going to be fixed in 1.2.0.

    As part of this release we have deprecated and cleaned up some APIs.

    • Pipe.getGSON is deprecated and replaced with Pipe.getRequestBuilder
    • A GSONRequestBuilder has been added.
    • Pipe.readWithFilter has been deprecated and replaced with an overloaded Pipe.read method.

    Code samples

    MultipartData

    The MultipartRequestBuilder class can handle normal POJOs. For your binary data it supports serializing byte arrays, InputStreams, and a special class called TypeAndStream which lets you set file type data. Currently the entire request is loaded into memory before it is sent off to the server, so this should not be used with large files or requests.

    MultiPartData.java

    public static class MultiPartData {
      @RecordId
      private String id;
      private InputStream data;        
    
      /*Getters and Setters*/
    }
    

    PipeUsage.java

    public static class MultiPartUsageActivity {      
      public void onCreate() {
        super.onCreate();
        PipeConfig config = new PipeConfig(SAMPLE_URL, MultiPartData.class);
        
        //provide a default MultiPartBuilder
        config.setRequestBuilder(new MultipartRequestBuilder<MultiPartData>());
    
        Pipeline pipeline = new Pipeline(SAMPLE_URL);
        Pipe<MultiPartData> restPipe = pipeline.pipe(MultiPartData.class, config);
        
        MultiPartData data = createData();//pseudo code method
        restPipe.save(data, new MyCallback());//pseudocode callback
    
      }
    }
    

    Digest or Basic Authentication

    Basic and Digest Authentication follow their respective RFC’s. For Digest authentication we extended the AuthenticationModule and added a new method:retryLogin. Classes implement this method if they need to automatically refresh a login (such as with Digest or OAuth). This method is called by AeroGear on its background threads and will block if it is called by the user.

    BasicApplication.java

    public void onCreate() {
      Authenticator authenticator = new Authenticator(SIMPLE_URL);
    
      AuthenticationConfig config = new AuthenticationConfig();
      config.setAuthType(AuthTypes.HTTP_BASIC);
      AuthenticationModule basicAuthModule = authenticator.auth("basic", config);
    
      basic.login("username","password", new MyCallback());
      //By the spec, HTTP Basic does not need to do any server calls.  
      //MyCallback.onSuccess is called immediately.
    }
    

    DigestApplication.java

    public void onCreate() {
      Authenticator authenticator = new Authenticator(SIMPLE_URL);
    
      AuthenticationConfig config = new AuthenticationConfig();
      config.setAuthType(AuthTypes.HTTP_DIGEST);
      AuthenticationModule digestAuthModule = authenticator.auth("basic", config);
    
      basic.login("username","password", new MyCallback());
      //By the spec, HTTP Digest has to make calls to the login endpoint.
      //The call will get the nonce values from the server.
      //Once nonce values are received, the module will generate the credentials 
      //but not send them to the service until another call is made via a Pipe.
    }
    

    Future

    For 1.2.0 we have several big plans. As always these may change and you, the community, are encouraged to speak your mind on our mailing list or our IRC channel.

    • GCM handler APIs
    • Support for the AeroGear Unified Push Service
    • Fully abstracted Requests and Response
    • AAR resources posted to Maven Central
    • Customized login parameters for Authentication Modules

    Getting it

    You can download AeroGear Android from github

    wget https://github.com/aerogear/aerogear-android/archive/1.1.0.tar.gz
    

    or from Maven Central

         <dependency>
            <groupId>org.jboss.aerogear</groupId>
            <artifactId>aerogear-android</artifactId>
            <version>1.1.0</version>
            <type>apklib</type>
         </dependency>
         <dependency>
            <groupId>org.jboss.aerogear</groupId>
            <artifactId>aerogear-android</artifactId>
            <version>1.1.0</version>
            <scope>provided</scope>
            <type>jar</type>
         </dependency>
    
    Jul 23rd, 2013

    No Comments! Be The First!

    Leave a Reply