X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;ds=sidebyside;f=netconf%2Fcallhome-provider%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fcallhome%2Fmount%2FCallHomeAuthProviderImpl.java;h=eda8ba2dd6b34ca47d23864ce15755789bd0f36c;hb=d7e246d3d5500415a0b09d1337465657abccc630;hp=9a345b02f3fe1e39ce8e1980fe0aa8f8484291a2;hpb=9bb9a8a0af94da42a2b1a90c38fbf37e68e36ef8;p=netconf.git diff --git a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeAuthProviderImpl.java b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeAuthProviderImpl.java index 9a345b02f3..eda8ba2dd6 100644 --- a/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeAuthProviderImpl.java +++ b/netconf/callhome-provider/src/main/java/org/opendaylight/netconf/callhome/mount/CallHomeAuthProviderImpl.java @@ -8,7 +8,6 @@ package org.opendaylight.netconf.callhome.mount; import com.google.common.collect.Iterables; -import com.google.common.net.InetAddresses; import java.io.IOException; import java.net.InetSocketAddress; import java.net.SocketAddress; @@ -33,6 +32,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf. import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.credentials.Credentials; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.AllowedDevices; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.Global; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.Global.MountPointNamingStrategy; import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.Device; import org.opendaylight.yangtools.concepts.ListenerRegistration; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; @@ -119,10 +119,20 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider, deviceOpReg.close(); } - private static String fromRemoteAddress(final SocketAddress remoteAddress) { + private String fromRemoteAddress(final SocketAddress remoteAddress) { if (remoteAddress instanceof InetSocketAddress) { InetSocketAddress socketAddress = (InetSocketAddress) remoteAddress; - return InetAddresses.toAddrString(socketAddress.getAddress()) + ":" + socketAddress.getPort(); + String ip = socketAddress.getAddress().getHostAddress(); + + final MountPointNamingStrategy strat = globalConfig.getMountPointNamingStrategy(); + switch (strat) { + case IPONLY: + return ip; + case IPPORT: + return ip + ":" + socketAddress.getPort(); + default: + throw new IllegalStateException("Unhandled naming strategy " + strat); + } } return remoteAddress.toString(); } @@ -256,5 +266,11 @@ public class CallHomeAuthProviderImpl implements CallHomeAuthorizationProvider, final Global local = current; return local != null ? local.getCredentials() : null; } + + MountPointNamingStrategy getMountPointNamingStrategy() { + final Global local = current; + final MountPointNamingStrategy strat = local != null ? local.getMountPointNamingStrategy() : null; + return strat == null ? MountPointNamingStrategy.IPPORT : strat; + } } }