Github user ceharris commented on a diff in the pull request:
https://github.com/apache/incubator-guacamole-client/pull/184#discussion_r133654410
--- Diff:
guacamole/src/main/java/org/apache/guacamole/extension/AuthenticationProviderFacade.java
---
@@ -66,58 +65,8 @@
* The AuthenticationProvider subclass to instantiate.
*/
public AuthenticationProviderFacade(Class<? extends
AuthenticationProvider> authProviderClass) {
-
- AuthenticationProvider instance = null;
-
- try {
- // Attempt to instantiate the authentication provider
- instance = authProviderClass.getConstructor().newInstance();
- }
- catch (NoSuchMethodException e) {
- logger.error("The authentication extension in use is not
properly defined. "
- + "Please contact the developers of the extension
or, if you "
- + "are the developer, turn on debug-level
logging.");
- logger.debug("AuthenticationProvider is missing a default
constructor.", e);
- }
- catch (SecurityException e) {
- logger.error("The Java security mananager is preventing
authentication extensions "
- + "from being loaded. Please check the
configuration of Java or your "
- + "servlet container.");
- logger.debug("Creation of AuthenticationProvider disallowed by
security manager.", e);
- }
- catch (InstantiationException e) {
- logger.error("The authentication extension in use is not
properly defined. "
- + "Please contact the developers of the extension
or, if you "
- + "are the developer, turn on debug-level
logging.");
- logger.debug("AuthenticationProvider cannot be instantiated.",
e);
- }
- catch (IllegalAccessException e) {
- logger.error("The authentication extension in use is not
properly defined. "
- + "Please contact the developers of the extension
or, if you "
- + "are the developer, turn on debug-level
logging.");
- logger.debug("Default constructor of AuthenticationProvider is
not public.", e);
- }
- catch (IllegalArgumentException e) {
- logger.error("The authentication extension in use is not
properly defined. "
- + "Please contact the developers of the extension
or, if you "
- + "are the developer, turn on debug-level
logging.");
- logger.debug("Default constructor of AuthenticationProvider
cannot accept zero arguments.", e);
- }
- catch (InvocationTargetException e) {
-
- // Obtain causing error - create relatively-informative stub
error if cause is unknown
- Throwable cause = e.getCause();
- if (cause == null)
- cause = new GuacamoleException("Error encountered during
initialization.");
-
- logger.error("Authentication extension failed to start: {}",
cause.getMessage());
- logger.debug("AuthenticationProvider instantiation failed.",
e);
-
- }
-
- // Associate instance, if any
- authProvider = instance;
-
+ authProvider = ProviderFactory.newInstance("authentication
provider",
+ authProviderClass);
--- End diff --
Pulled it out so that the same logic could be reused by `ListenerFacade`
rather than duplicating it.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---