GateIn Audio Captcha

Version 4

    Status

    Work in progress

     

    Description

    Since GateIn 3.2, we've used gatein simplecaptcha for register portlet, this project is forked from simplecaptcha. However, we only forked image part in the project.

    In fact, visually impaired people may not be able to solve the Captcha challenge. We need do something to integrate audio captcha on this. We forked packages simplecaptcha audio into GateIn simplecaptcha and modified a bit to work on GateIn.

     

    Specification

     

     

    We have a audio captcha builder same as image captcha. The code example create a audio captcha:

    {code}

         AudioCaptcha audioCaptcha = new AudioCaptcha.Builder().addVoice().addAnswer().build();

         // addVoice() make a voice

         // addAnswer() make answer to validate

    {code}

     

    Look into CaptchaServletUtil.writeAudio which to write audio captcha to output stream:

    {code}

         ByteArrayOutputStream baos = new ByteArrayOutputStream(1024);

         AudioSystem.write(sample.getAudioInputStream(), AudioFileFormat.Type.WAVE, baos);

         os.write(baos.toByteArray());

         os.flush();

         os.close();

    {code}

    With sample is sound sample store in AudioCaptcha after build and can get by:

    {code}

         Sample sample = audiocaptcha.getChallenge();    

    {code}


    For validate answer:


    {code}

         String answer = getAnswer();

         //getAnswer() a whatever method get answer from client

         if(audiocaptcha.isCorrect(answer)) {

              doSomething();

         }

    {code}

     

     


    The forked simplecaptcha project can [checkout here|https://github.com/ndkhoiits/Simplecaptcha] and [sample portlet here|https://github.com/ndkhoiits/exo-examples]. Thanks to James Childrens (Simplecaptcha's author) and {user:username=ndkhoiits}