raml-java-parser icon indicating copy to clipboard operation
raml-java-parser copied to clipboard

ClassCastException when trying to cast to OAuth2SecuritySchemeSettings in 0.8 (parser-1.0.8)

Open diablonhn opened this issue 8 years ago • 0 comments

There is currently no way to get the OAuth2SecuritySchemeSettings for an oauth scheme because the interface SecuritySchemeSettings has no methods.

Trying to cast SecuritySchemeSettings to OAuth2SecuritySchemeSettings gives a ClassCastException because it is a java.lang.Proxy.

The workaround is to unwrap the proxy:

    java.lang.reflect.Method method = OAuth2SecuritySchemeSettings.class.getMethod("authorizationUri");
    InvocationHandler handler = Proxy.getInvocationHandler(settings);

    FixedUri uri = (FixedUri) handler.invoke(settings, method, new Object[0]);

Aha! Link: https://mulesoft-roadmap.aha.io/features/APIRAML-92

diablonhn avatar May 15 '17 20:05 diablonhn