Coder Social home page Coder Social logo

Comments (5)

emlun avatar emlun commented on July 30, 2024

Thanks for the suggestion! That sounds reasonable, we can probably make that happen.

from java-u2flib-server.

emlun avatar emlun commented on July 30, 2024

Looking at this again, I feel like there might be little point in introducing a common ancestor exception since the exceptions are used to signal mostly separate failure conditions:

  • U2fBadConfigurationException means there's something wrong in the server configuration.
  • U2fBadInputException means the client's response is malformed.
  • NoEligibleDevicesException means the state of the client's account does not permit initiating an authentication operation, because no devices are registered.
  • DeviceCompromisedException and InvalidDeviceCounterException mean the signature counter returned from the client is or has been invalid.

Can you share one or a few specific examples of ugly code caused by the current exception (non-)hierarchy? That would help decide how we want to go about this.

from java-u2flib-server.

jasonab avatar jasonab commented on July 30, 2024

Sure, let's look at these from my implementor's perspective:

  • U2fBadConfigurationException is absolutely a runtime exception, and there's no reason for any client code to catch it.
  • U2fBadInputException is a runtime exception from you, but it's a checked exception to me. I'm sending you user input that could be anything, and it could fail for any reason. I understand that this is supposed to be coming from the key, but I can't guarantee that, so I have to handle this exception to avoid a 500.
  • NoEligibleDevicesException is properly a checked exception that I have to handle.
  • DeviceCompromisedException is properly a checked exception.

For me, any of the final 3 could be thrown during an authentication flow, and if any of them are thrown, it means authentication failed. I agree that I might need to message them differently, but with the separate types, I have to have multiple catch blocks to differentiate the cause of the error. What would be easier for me is to be able to catch a single "u2f process failed" type exception, with an embedded error code that explains why.

Right now, I have to catch U2fBadInputException and DeviceCompromised exception separately in the same flow, but react the same way.

from java-u2flib-server.

emlun avatar emlun commented on July 30, 2024

Ah yes, I see. I guess my dabbling in Scala had me still thinking in expression-oriented terms rather than Java's statement-oriented paradigm.

from java-u2flib-server.

emlun avatar emlun commented on July 30, 2024

This is now released in version 0.19.0. Please have a look, and let us know if you have any more suggestions for improvements. Thanks!

from java-u2flib-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.