Skip to content

Commit

Permalink
Merge pull request #364 from gcheng/mooncake
Browse files Browse the repository at this point in the history
Update STS end point handling logic in service bus configuration.
  • Loading branch information
Albert Cheng committed Jun 11, 2013
2 parents e419ce6 + 63e3fc9 commit bb2dc56
Showing 1 changed file with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* Copyright Microsoft Corporation
*
*
* 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.
Expand All @@ -15,29 +15,30 @@

package com.microsoft.windowsazure.services.serviceBus.implementation;

import com.microsoft.windowsazure.services.core.utils.ConnectionStringSyntaxException;

import java.net.URI;
import java.net.URISyntaxException;

import com.microsoft.windowsazure.services.core.utils.ConnectionStringSyntaxException;

/**
* Class that encapsulates all the various settings needed
* to connect to Service Bus, provided via either a
* connection string or via separate configuration variables.
* <p/>
* The connection string is looked for first, falling back
* to separate config values if not found.
* The connection string is looked for first, falling back to separate config values if not found.
*/
class ServiceBusConnectionSettings {
private String uri;
private String wrapUri;
private String wrapName;
private String wrapPassword;

public ServiceBusConnectionSettings(String connectionString, String uri, String wrapUri, String wrapName, String wrapPassword) throws ConnectionStringSyntaxException, URISyntaxException {
public ServiceBusConnectionSettings(String connectionString, String uri, String wrapUri, String wrapName,
String wrapPassword) throws ConnectionStringSyntaxException, URISyntaxException {
if (connectionString != null) {
parseConnectionString(connectionString);
} else {
}
else {
this.uri = uri;
this.wrapUri = wrapUri;
this.wrapName = wrapName;
Expand All @@ -61,7 +62,8 @@ public String getWrapPassword() {
return wrapPassword;
}

private boolean parseConnectionString(String connectionString) throws URISyntaxException, ConnectionStringSyntaxException {
private boolean parseConnectionString(String connectionString) throws URISyntaxException,
ConnectionStringSyntaxException {
ServiceBusConnectionString cs = new ServiceBusConnectionString(connectionString);
setUri(cs);
setWrapUri(cs);
Expand All @@ -79,8 +81,9 @@ private void setWrapUri(ServiceBusConnectionString connectionString) throws URIS
URI hostUri = new URI(uri);
String namespace = hostUri.getHost().split("\\.")[0];
wrapUri = "https://" + namespace + "-sb.accesscontrol.windows.net/WRAPv0.9";
} else {
wrapUri = connectionString.getStsEndpoint();
}
else {
wrapUri = connectionString.getStsEndpoint().replaceAll("\\/$", "") + "/WRAPv0.9";
}
}
}

0 comments on commit bb2dc56

Please sign in to comment.