Issue 100: split authentication from connection

git-svn-id: http://jclouds.googlecode.com/svn/trunk@1977 3d8758e0-26b5-11de-8745-db77d3ebf521
This commit is contained in:
adrian.f.cole 2009-10-14 01:13:32 +00:00
parent 124bf457f1
commit 03036ca1d0
3 changed files with 62 additions and 16 deletions

View File

@ -32,6 +32,7 @@ import java.util.concurrent.ExecutorService;
import org.jclouds.cloud.CloudContextBuilder;
import org.jclouds.nirvanix.sdn.config.RestSDNAuthenticationModule;
import org.jclouds.nirvanix.sdn.config.RestSDNConnectionModule;
import org.jclouds.nirvanix.sdn.config.SDNContextModule;
import org.jclouds.nirvanix.sdn.reference.SDNConstants;
@ -85,6 +86,7 @@ public class SDNContextBuilder extends CloudContextBuilder<SDNConnection> {
public static void addAuthenticationModule(SDNContextBuilder builder) {
builder.withModule(new RestSDNAuthenticationModule());
builder.withModule(new RestSDNConnectionModule());
}
public static SDNContextBuilder withEndpoint(SDNContextBuilder builder, URI endpoint) {

View File

@ -31,7 +31,6 @@ import javax.inject.Singleton;
import org.jclouds.http.RequiresHttp;
import org.jclouds.nirvanix.sdn.SDN;
import org.jclouds.nirvanix.sdn.SDNAuthentication;
import org.jclouds.nirvanix.sdn.SDNConnection;
import org.jclouds.nirvanix.sdn.SessionToken;
import org.jclouds.nirvanix.sdn.reference.SDNConstants;
import org.jclouds.rest.RestClientFactory;
@ -49,8 +48,6 @@ public class RestSDNAuthenticationModule extends AbstractModule {
@Override
protected void configure() {
bindErrorHandlers();
bindRetryHandlers();
}
@Provides
@ -69,17 +66,4 @@ public class RestSDNAuthenticationModule extends AbstractModule {
return factory.create(SDNAuthentication.class).authenticate(appKey, username, password);
}
@Provides
protected SDNConnection provideConnection(RestClientFactory factory) {
return factory.create(SDNConnection.class);
}
protected void bindErrorHandlers() {
// TODO
}
protected void bindRetryHandlers() {
// TODO retry on 401 by AuthenticateRequest.update()
}
}

View File

@ -0,0 +1,60 @@
/**
*
* Copyright (C) 2009 Global Cloud Specialists, Inc. <info@globalcloudspecialists.com>
*
* ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.jclouds.nirvanix.sdn.config;
import org.jclouds.http.RequiresHttp;
import org.jclouds.nirvanix.sdn.SDNConnection;
import org.jclouds.rest.RestClientFactory;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
/**
* Configures the SDN authentication service connection, including logging and http transport.
*
* @author Adrian Cole
*/
@RequiresHttp
public class RestSDNConnectionModule extends AbstractModule {
@Override
protected void configure() {
bindErrorHandlers();
bindRetryHandlers();
}
@Provides
protected SDNConnection provideConnection(RestClientFactory factory) {
return factory.create(SDNConnection.class);
}
protected void bindErrorHandlers() {
// TODO
}
protected void bindRetryHandlers() {
// TODO retry on 401 by AuthenticateRequest.update()
}
}