@@ -0,0 +1,2052 @@
+/*%0A * Copyright 2016 EPAM Systems%0A *%0A *%0A * This file is part of EPAM Report Portal.%0A * https://github.com/reportportal/service-authorization%0A *%0A * Report Portal is free software: you can redistribute it and/or modify%0A * it under the terms of the GNU General Public License as published by%0A * the Free Software Foundation, either version 3 of the License, or%0A * (at your option) any later version.%0A *%0A * Report Portal is distributed in the hope that it will be useful,%0A * but WITHOUT ANY WARRANTY; without even the implied warranty of%0A * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the%0A * GNU General Public License for more details.%0A *%0A * You should have received a copy of the GNU General Public License%0A * along with Report Portal.  If not, see %3Chttp://www.gnu.org/licenses/%3E.%0A */%0Apackage com.epam.reportportal.auth;%0A%0Aimport com.epam.ta.reportportal.database.dao.ServerSettingsRepository;%0Aimport org.springframework.beans.factory.annotation.Autowired;%0Aimport org.springframework.security.oauth2.client.resource.OAuth2ProtectedResourceDetails;%0A%0Aimport javax.inject.Provider;%0Aimport java.lang.reflect.InvocationTargetException;%0A%0Aimport static com.google.common.reflect.Reflection.newProxy;%0A%0A/**%0A * Wraps resource details with proxy to be able to update %7B@link OAuth2ProtectedResourceDetails%7D%0A * on the each method call%0A *%0A * @author Andrei Varabyeu%0A */%0Apublic class DatabaseOauthDetailsFactory %7B%0A%0A    @Autowired%0A    private Provider%3CServerSettingsRepository%3E settingsRepository;%0A%0A    public OAuth2ProtectedResourceDetails getResourceDetails() %7B%0A        return newProxy(OAuth2ProtectedResourceDetails.class,%0A                (proxy, method, args) -%3E %7B%0A                    try %7B%0A                        //settingsRepository.findOne(%22default%22);%0A                        OAuth2ProtectedResourceDetails details = null;%0A                        return method.invoke(details, args);%0A                    %7D catch (InvocationTargetException e) %7B%0A                        throw e.getTargetException();%0A                    %7D%0A                %7D);%0A    %7D%0A%0A%7D%0A

add database oauth details factory