private synchronized ScopeValidator getScopeValidator() throws ServerException { if (scopeValidator == null) { try { final String scopeValidatorClassName = getStringSettingValue(OAuth2ProviderService.SCOPE_PLUGIN_CLASS); if (isEmpty(scopeValidatorClassName)) { logger.message("Scope Validator class not set."); throw new ServerException("Scope Validator class not set."); } final Class<?> scopeValidatorClass = Class.forName(scopeValidatorClassName); if (Scope.class.isAssignableFrom(scopeValidatorClass)) { final Scope scopeClass = InjectorHolder.getInstance(scopeValidatorClass.asSubclass(Scope.class)); return new LegacyScopeValidator(scopeClass); } scopeValidator = InjectorHolder.getInstance(scopeValidatorClass.asSubclass(ScopeValidator.class)); } catch (ClassNotFoundException e) { logger.error(e.getMessage()); throw new ServerException(e); } } return scopeValidator; }
private ResponseTypeHandler wrap(String responseTypeName, String responseTypeHandlerClassName) throws UnsupportedResponseTypeException { if (responseTypeHandlerClassName == null || responseTypeHandlerClassName.isEmpty()) { logger.warning( "Requested a response type that is not configured. response_type=" + responseTypeName); throw new UnsupportedResponseTypeException("Response type is not supported"); } else if (responseTypeHandlerClassName.equalsIgnoreCase("none")) { return new NoneResponseTypeHandler(); } try { final Class<?> responseTypeHandlerClass = Class.forName(responseTypeHandlerClassName); if (ResponseType.class.isAssignableFrom(responseTypeHandlerClass)) { ResponseType responseType = InjectorHolder.getInstance(responseTypeHandlerClass.asSubclass(ResponseType.class)); return new LegacyResponseTypeHandler( responseType, realm, getSSOCookieName(), cookieExtractor); } return InjectorHolder.getInstance( responseTypeHandlerClass.asSubclass(ResponseTypeHandler.class)); } catch (ClassNotFoundException e) { logger.error(e.getMessage()); throw new UnsupportedResponseTypeException("Response type is not supported"); } }