/** * Creates a {@link RequestAuthenticator} out of the given {@link AuthenticationScheme}. * * @param scheme the authentication scheme enum defining the request authenticator to be created * @return the corresponding `RequestAuthenticator` for the given `AuthenticationScheme`. Returns `SswsAuthenticator` if * the authentication scheme is undefined. */ @SuppressWarnings("unchecked") public RequestAuthenticator create(AuthenticationScheme scheme, ClientCredentials clientCredentials) { if (scheme == null) { //By default, this factory creates a digest authentication when a scheme is not defined return new SswsAuthenticator(clientCredentials); } try { Class requestAuthenticatorClass = Classes.forName(scheme.getRequestAuthenticatorClassName()); Constructor<RequestAuthenticator> ctor = Classes.getConstructor(requestAuthenticatorClass, ClientCredentials.class); return Classes.instantiate(ctor, clientCredentials); } catch (RuntimeException ex) { String errormessage = "There was an error instantiating " + scheme.getRequestAuthenticatorClassName(); log.error(errormessage, ex); throw new RequestAuthenticationException(errormessage); } }
/** * Creates a {@link RequestAuthenticator} out of the given {@link AuthenticationScheme}. * * @param scheme the authentication scheme enum defining the request authenticator to be created * @return the corresponding `RequestAuthenticator` for the given `AuthenticationScheme`. Returns `SswsAuthenticator` if * the authentication scheme is undefined. */ @SuppressWarnings("unchecked") public RequestAuthenticator create(AuthenticationScheme scheme, ClientCredentials clientCredentials) { if (scheme == null) { //By default, this factory creates a digest authentication when a scheme is not defined return new SswsAuthenticator(clientCredentials); } try { Class requestAuthenticatorClass = Classes.forName(scheme.getRequestAuthenticatorClassName()); Constructor<RequestAuthenticator> ctor = Classes.getConstructor(requestAuthenticatorClass, ClientCredentials.class); return Classes.instantiate(ctor, clientCredentials); } catch (RuntimeException ex) { String errormessage = "There was an error instantiating " + scheme.getRequestAuthenticatorClassName(); log.error(errormessage, ex); throw new RequestAuthenticationException(errormessage); } }