// Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
// 
// 	ACTIVE_DIRECTORY("ad") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// 			return ActiveDirectoryConverter.TO_RESOURCE;
// 		}
// 	},
// 	LDAP("ldap") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, LdapResource> getToResourceMapper() {
// 			return LdapConverter.TO_RESOURCE;
// 		}
// 	},
// 	SAML("saml") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, SamlResource> getToResourceMapper() {
// 			return SamlConverter.TO_RESOURCE;
// 		}
// 	};
// 
// 	private String name;
// 
// 	AuthIntegrationType(String name) {
// 		this.name = name;
// 	}
// 
// 	public abstract Optional<Integration> get(Integration entity);
// 
// 	public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public static Optional<AuthIntegrationType> fromId(String id) {
// 		return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return this.name;
// 	}
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
// 
// 	AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
// 
// 	AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
// 
// 	OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
// 
// 	OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
// 
// 	OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
// 
// 	AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
// 
// 	Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
// 
// 	OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }


import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport;
/*
 * Copyright 2019 EPAM Systems
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.epam.reportportal.auth.endpoint;



@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {

	private final CreateAuthIntegrationHandler createAuthIntegrationHandler;

	private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler;

// Path: src/main/java/com/epam/reportportal/auth/integration/AuthIntegrationType.java
// public enum AuthIntegrationType {
// 
// 	ACTIVE_DIRECTORY("ad") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, ActiveDirectoryResource> getToResourceMapper() {
// 			return ActiveDirectoryConverter.TO_RESOURCE;
// 		}
// 	},
// 	LDAP("ldap") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, LdapResource> getToResourceMapper() {
// 			return LdapConverter.TO_RESOURCE;
// 		}
// 	},
// 	SAML("saml") {
// 		@Override
// 		public Optional<Integration> get(Integration entity) {
// 			return ofNullable(entity);
// 		}
// 
// 		@Override
// 		public Function<Integration, SamlResource> getToResourceMapper() {
// 			return SamlConverter.TO_RESOURCE;
// 		}
// 	};
// 
// 	private String name;
// 
// 	AuthIntegrationType(String name) {
// 		this.name = name;
// 	}
// 
// 	public abstract Optional<Integration> get(Integration entity);
// 
// 	public abstract Function<Integration, ? extends AbstractAuthResource> getToResourceMapper();
// 
// 	public String getName() {
// 		return name;
// 	}
// 
// 	public static Optional<AuthIntegrationType> fromId(String id) {
// 		return Arrays.stream(values()).filter(it -> it.name.equalsIgnoreCase(id)).findAny();
// 	}
// 
// 	@Override
// 	public String toString() {
// 		return this.name;
// 	}
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/CreateAuthIntegrationHandler.java
// public interface CreateAuthIntegrationHandler {
// 
// 	AbstractAuthResource createAuthIntegration(AuthIntegrationType type, UpdateAuthRQ request, ReportPortalUser user);
// 
// 	AbstractAuthResource updateAuthIntegration(AuthIntegrationType type, Long integrationId, UpdateAuthRQ request, ReportPortalUser user);
// 
// 	OAuthRegistrationResource createOrUpdateOauthSettings(String oauthProviderId, OAuthRegistrationResource clientRegistrationResource);
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/DeleteAuthIntegrationHandler.java
// public interface DeleteAuthIntegrationHandler {
// 
// 	OperationCompletionRS deleteAuthIntegrationById(Long integrationId);
// 
// 	OperationCompletionRS deleteOauthSettingsById(String oauthProviderId);
// }
// 
// Path: src/main/java/com/epam/reportportal/auth/integration/handler/GetAuthIntegrationHandler.java
// public interface GetAuthIntegrationHandler {
// 
// 	AbstractAuthResource getIntegrationByType(AuthIntegrationType integrationType);
// 
// 	Map<String, OAuthRegistrationResource> getAllOauthIntegrations();
// 
// 	OAuthRegistrationResource getOauthIntegrationById(String oauthProviderId);
// }


// Path: src/main/java/com/epam/reportportal/auth/endpoint/AuthConfigurationEndpoint.java
import com.epam.reportportal.auth.integration.AuthIntegrationType;
import com.epam.reportportal.auth.integration.handler.CreateAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.DeleteAuthIntegrationHandler;
import com.epam.reportportal.auth.integration.handler.GetAuthIntegrationHandler;
import com.epam.ta.reportportal.commons.ReportPortalUser;
import com.epam.ta.reportportal.exception.ReportPortalException;
import com.epam.ta.reportportal.ws.model.ErrorType;
import com.epam.ta.reportportal.ws.model.OperationCompletionRS;
import com.epam.ta.reportportal.ws.model.integration.auth.AbstractAuthResource;
import com.epam.ta.reportportal.ws.model.integration.auth.UpdateAuthRQ;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.beans.PropertyEditorSupport;

/*
 * Copyright 2019 EPAM Systems
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.epam.reportportal.auth.endpoint;



@RestController
@RequestMapping("/settings/auth")
public class AuthConfigurationEndpoint {

	private final CreateAuthIntegrationHandler createAuthIntegrationHandler;

	private final DeleteAuthIntegrationHandler deleteAuthIntegrationHandler;

	private final GetAuthIntegrationHandler getAuthIntegrationHandler;