// Path: src/main/java/org/cloudfoundry/identity/uaa/api/UaaConnectionFactory.java
// public final class UaaConnectionFactory {
// 	private UaaConnectionFactory() {
// 
// 	}
// 
// 	/**
// 	 * Get a connection object for the given UAA server, from which you can get access to different API operations.
// 	 * 
// 	 * @param uaaUrl the base {@link URL} of the UAA server. May have a path prefix (for example,
// 	 * <code>http://localhost:8080/uaa</code>)
// 	 * @param credentials the {@link OAuth2ProtectedResourceDetails} representing the current user. May be client-only
// 	 * @return the connection entry point
// 	 */
// 	public static UaaConnection getConnection(URL uaaUrl, OAuth2ProtectedResourceDetails credentials) {
// 		UaaConnectionHelper helper = new UaaConnectionHelper(uaaUrl, credentials);
// 		return new UaaConnectionImpl(helper);
// 	}
// }
// 
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/UaaConnection.java
// public interface UaaConnection {
// 	/**
// 	 * @return an entry point for client APIs
// 	 */
// 	public UaaClientOperations clientOperations();
// 
// 	/**
// 	 * @return an entry point for group APIS
// 	 */
// 	public UaaGroupOperations groupOperations();
// 
// 	/**
// 	 * @return an entry point for user APIs
// 	 */
// 	public UaaUserOperations userOperations();
// }


import java.net.URL;
import org.cloudfoundry.identity.uaa.api.UaaConnectionFactory;
import org.cloudfoundry.identity.uaa.api.common.UaaConnection;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
import org.springframework.security.oauth2.common.AuthenticationScheme;
/*
 * 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 org.cloudfoundry.identity.uaa.api.client.test;



/**
 * @author Josh Ghiloni
 */
public abstract class AbstractOperationTest {

	private static final String UAA_BASE_URL = "http://localhost:8080/uaa";

	protected ClientCredentialsResourceDetails getDefaultClientCredentials() {

		ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();
		credentials.setAccessTokenUri(UAA_BASE_URL + "/oauth/token");
		credentials.setClientAuthenticationScheme(AuthenticationScheme.header);
		credentials.setClientId("admin");
		credentials.setClientSecret("adminsecret");

		return credentials;
	}

	protected UaaConnection getConnection() throws Exception {
		return getConnection(getDefaultClientCredentials());
	}

	protected UaaConnection getConnection(ClientCredentialsResourceDetails clientCredentials) throws Exception {
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/UaaConnectionFactory.java
// public final class UaaConnectionFactory {
// 	private UaaConnectionFactory() {
// 
// 	}
// 
// 	/**
// 	 * Get a connection object for the given UAA server, from which you can get access to different API operations.
// 	 * 
// 	 * @param uaaUrl the base {@link URL} of the UAA server. May have a path prefix (for example,
// 	 * <code>http://localhost:8080/uaa</code>)
// 	 * @param credentials the {@link OAuth2ProtectedResourceDetails} representing the current user. May be client-only
// 	 * @return the connection entry point
// 	 */
// 	public static UaaConnection getConnection(URL uaaUrl, OAuth2ProtectedResourceDetails credentials) {
// 		UaaConnectionHelper helper = new UaaConnectionHelper(uaaUrl, credentials);
// 		return new UaaConnectionImpl(helper);
// 	}
// }
// 
// Path: src/main/java/org/cloudfoundry/identity/uaa/api/common/UaaConnection.java
// public interface UaaConnection {
// 	/**
// 	 * @return an entry point for client APIs
// 	 */
// 	public UaaClientOperations clientOperations();
// 
// 	/**
// 	 * @return an entry point for group APIS
// 	 */
// 	public UaaGroupOperations groupOperations();
// 
// 	/**
// 	 * @return an entry point for user APIs
// 	 */
// 	public UaaUserOperations userOperations();
// }


// Path: src/test/java/org/cloudfoundry/identity/uaa/api/client/test/AbstractOperationTest.java
import java.net.URL;
import org.cloudfoundry.identity.uaa.api.UaaConnectionFactory;
import org.cloudfoundry.identity.uaa.api.common.UaaConnection;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
import org.springframework.security.oauth2.common.AuthenticationScheme;

/*
 * 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 org.cloudfoundry.identity.uaa.api.client.test;



/**
 * @author Josh Ghiloni
 */
public abstract class AbstractOperationTest {

	private static final String UAA_BASE_URL = "http://localhost:8080/uaa";

	protected ClientCredentialsResourceDetails getDefaultClientCredentials() {

		ClientCredentialsResourceDetails credentials = new ClientCredentialsResourceDetails();
		credentials.setAccessTokenUri(UAA_BASE_URL + "/oauth/token");
		credentials.setClientAuthenticationScheme(AuthenticationScheme.header);
		credentials.setClientId("admin");
		credentials.setClientSecret("adminsecret");

		return credentials;
	}

	protected UaaConnection getConnection() throws Exception {
		return getConnection(getDefaultClientCredentials());
	}

	protected UaaConnection getConnection(ClientCredentialsResourceDetails clientCredentials) throws Exception {
		return UaaConnectionFactory.getConnection(new URL(UAA_BASE_URL), clientCredentials);