ClientSocketConnectionParameters.java
/*
** Module : ClientSocketConnectionParameters.java
** Abstract : Implementation of the OpenEdge.Net.ServerConnection.ClientSocketConnectionParameters
** builtin class.
**
** Copyright (c) 2019-2023, Golden Code Development Corporation.
**
** -#- -I- --Date-- ---------------------------------------Description----------------------------------------
** 001 CA 20190905 Created the first version, by converting the legacy skeleton .cls file and using that
** output.
** 002 CA 20191024 Added method support levels and updated the class support level.
** 003 MP 20200528 Added properties exactly as 4gl class
** CA 20210219 OO input parameter definitions for functions/procedures must not register with ObjectOps
** - TypeFactory.initInput will take care of this.
** 004 CA 20210221 Fixed 'qualified', 'extent' and 'returns' annotations at the legacy signature.
** 005 ME 20210322 Implement missing functionality (OE12.2).
** CA 20210609 Set the EXTENT for legacy properties or variables.
** 006 CA 20230817 Removed ObjectOps.register, as this registration is handled by runtime.
** 007 ME 20230503 Reconvert skeleton, add new setter methods for extent properties (#6410).
** 008 CA 20231113 The 'execute' method must be annotated with LegacySignature Type.Execute, and also can be
** dropped if is a no-op.
*/
/*
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU Affero General Public License as
** published by the Free Software Foundation, either version 3 of the
** License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU Affero General Public License for more details.
**
** You may find a copy of the GNU Affero GPL version 3 at the following
** location: https://www.gnu.org/licenses/agpl-3.0.en.html
**
** Additional terms under GNU Affero GPL version 3 section 7:
**
** Under Section 7 of the GNU Affero GPL version 3, the following additional
** terms apply to the works covered under the License. These additional terms
** are non-permissive additional terms allowed under Section 7 of the GNU
** Affero GPL version 3 and may not be removed by you.
**
** 0. Attribution Requirement.
**
** You must preserve all legal notices or author attributions in the covered
** work or Appropriate Legal Notices displayed by works containing the covered
** work. You may not remove from the covered work any author or developer
** credit already included within the covered work.
**
** 1. No License To Use Trademarks.
**
** This license does not grant any license or rights to use the trademarks
** Golden Code, FWD, any Golden Code or FWD logo, or any other trademarks
** of Golden Code Development Corporation. You are not authorized to use the
** name Golden Code, FWD, or the names of any author or contributor, for
** publicity purposes without written authorization.
**
** 2. No Misrepresentation of Affiliation.
**
** You may not represent yourself as Golden Code Development Corporation or FWD.
**
** You may not represent yourself for publicity purposes as associated with
** Golden Code Development Corporation, FWD, or any author or contributor to
** the covered work, without written authorization.
**
** 3. No Misrepresentation of Source or Origin.
**
** You may not represent the covered work as solely your work. All modified
** versions of the covered work must be marked in a reasonable way to make it
** clear that the modified work is not originating from Golden Code Development
** Corporation or FWD. All modified versions must contain the notices of
** attribution required in this license.
*/
package com.goldencode.p2j.oo.net.serverconnection;
import com.goldencode.p2j.util.*;
import com.goldencode.p2j.util.BlockManager.Action;
import com.goldencode.p2j.util.BlockManager.Condition;
import com.goldencode.p2j.oo.core.serverconnection.IconnectionParameters;
import com.goldencode.p2j.oo.lang.*;
import com.goldencode.p2j.oo.core.Assert;
import com.goldencode.p2j.oo.core.serverconnection.FormatMaskEnum;
import com.goldencode.p2j.oo.net.Uri;
import static com.goldencode.p2j.util.BlockManager.*;
import static com.goldencode.p2j.util.InternalEntry.Type;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static com.goldencode.p2j.report.ReportConstants.*;
import static com.goldencode.p2j.util.ArrayAssigner.*;
/**
* Business logic (converted to Java from the 4GL source code
* in OpenEdge/Net/ServerConnection/ClientSocketConnectionParameters.cls).
*/
@LegacyResource(resource = "OpenEdge.Net.ServerConnection.ClientSocketConnectionParameters")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public class ClientSocketConnectionParameters
extends BaseObject
implements IconnectionParameters
{
@LegacySignature(type = Type.PROPERTY, name = "FormatMask")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
private object<? extends FormatMaskEnum> formatMask = TypeFactory.object(FormatMaskEnum.class);
@LegacySignature(type = Type.PROPERTY, name = "SslCiphers", extent = SourceNameMapper.DYNAMIC_EXTENT)
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
private character[] sslCiphers = TypeFactory.characterExtent();
@LegacySignature(type = Type.PROPERTY, name = "SslProtocols", extent = SourceNameMapper.DYNAMIC_EXTENT)
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
private character[] sslProtocols = TypeFactory.characterExtent();
@LegacySignature(type = Type.PROPERTY, name = "URI")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
private object<? extends Uri> uri = TypeFactory.object(Uri.class);
@LegacySignature(type = Type.PROPERTY, name = "VerifyHost")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
private logical verifyHost = TypeFactory.logical();
@LegacySignature(type = Type.PROPERTY, name = "ReuseSession")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
private logical reuseSession = TypeFactory.logical();
@LegacySignature(type = Type.PROPERTY, name = "ServerNameIndicator")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
private character serverNameIndicator = TypeFactory.character();
@LegacySignature(type = Type.EXECUTE)
public void __net_serverconnection_ClientSocketConnectionParameters_execute__()
{
onBlockLevel(Condition.ERROR, Action.THROW);
}
@LegacySignature(returns = "OBJECT", qualified = "OpenEdge.Core.ServerConnection.FormatMaskEnum", type = Type.GETTER, name = "FormatMask")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public object<? extends FormatMaskEnum> getFormatMask()
{
return function(ClientSocketConnectionParameters.class, this, "FormatMask", object.class, new Block((Body) () ->
{
if (formatMask.isUnknown())
formatMask.assign(FormatMaskEnum.custom);
returnNormal(formatMask);
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "SslCiphers", parameters =
{
@LegacyParameter(name = "idx", type = "INT64", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public character getSslCiphers(final int64 _idx)
{
int64 idx = TypeFactory.initInput(_idx);
return function(ClientSocketConnectionParameters.class, this, "SslCiphers", character.class, new Block((Body) () ->
{
returnNormal(subscript(sslCiphers, idx));
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "SslCiphers", extent = -1)
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public character[] getSslCiphers()
{
return extentFunction(ClientSocketConnectionParameters.class, this, "SslCiphers", character.class, 0, new Block((Body) () ->
{
returnExtentNormal(sslCiphers);
}));
}
@LegacySignature(type = Type.SETTER, name = "SslCiphers", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT"),
@LegacyParameter(name = "idx", type = "INT64", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setSslCiphers(final character _var, final int64 _idx)
{
character var = TypeFactory.initInput(_var);
int64 idx = TypeFactory.initInput(_idx);
internalProcedure(ClientSocketConnectionParameters.class, this, "SslCiphers", new Block((Body) () ->
{
assignSingle(sslCiphers, idx, var);
}));
}
@LegacySignature(type = Type.SETTER, name = "SslCiphers", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", extent = -1, mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setSslCiphers(final character[] _var)
{
character[] var = TypeFactory.initInput(_var);
internalProcedure(ClientSocketConnectionParameters.class, this, "SslCiphers", new Block((Body) () ->
{
sslCiphers = (character[]) assignMulti(sslCiphers, var);
}));
}
@LegacySignature(type = Type.SETTER, name = "SslCiphers", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setAllSslCiphers(final character _var)
{
character var = TypeFactory.initInput(_var);
internalProcedure(ClientSocketConnectionParameters.class, this, "SslCiphers", new Block((Body) () ->
{
assignMulti(sslCiphers, var);
}));
}
@LegacySignature(returns = "INTEGER", type = Type.LENGTH, name = "SslCiphers")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public integer lengthOfSslCiphers()
{
return function(ClientSocketConnectionParameters.class, this, "length-of-SslCiphers", integer.class, new Block((Body) () ->
{
returnNormal(ArrayAssigner.lengthOf(sslCiphers));
}));
}
@LegacySignature(type = Type.RESIZE, name = "SslCiphers", parameters =
{
@LegacyParameter(name = "size", type = "INT64", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void resizeSslCiphers(final int64 _size)
{
int64 size = TypeFactory.initInput(_size);
internalProcedure(ClientSocketConnectionParameters.class, this, "resize-SslCiphers", new Block((Body) () ->
{
sslCiphers = ArrayAssigner.resize(sslCiphers, size);
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "SslProtocols", parameters =
{
@LegacyParameter(name = "idx", type = "INT64", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public character getSslProtocols(final int64 _idx)
{
int64 idx = TypeFactory.initInput(_idx);
return function(ClientSocketConnectionParameters.class, this, "SslProtocols", character.class, new Block((Body) () ->
{
returnNormal(subscript(sslProtocols, idx));
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "SslProtocols", extent = -1)
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public character[] getSslProtocols()
{
return extentFunction(ClientSocketConnectionParameters.class, this, "SslProtocols", character.class, 0, new Block((Body) () ->
{
returnExtentNormal(sslProtocols);
}));
}
@LegacySignature(type = Type.SETTER, name = "SslProtocols", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT"),
@LegacyParameter(name = "idx", type = "INT64", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setSslProtocols(final character _var, final int64 _idx)
{
character var = TypeFactory.initInput(_var);
int64 idx = TypeFactory.initInput(_idx);
internalProcedure(ClientSocketConnectionParameters.class, this, "SslProtocols", new Block((Body) () ->
{
assignSingle(sslProtocols, idx, var);
}));
}
@LegacySignature(type = Type.SETTER, name = "SslProtocols", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", extent = -1, mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setSslProtocols(final character[] _var)
{
character[] var = TypeFactory.initInput(_var);
internalProcedure(ClientSocketConnectionParameters.class, this, "SslProtocols", new Block((Body) () ->
{
sslProtocols = (character[]) assignMulti(sslProtocols, var);
}));
}
@LegacySignature(type = Type.SETTER, name = "SslProtocols", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setAllSslProtocols(final character _var)
{
character var = TypeFactory.initInput(_var);
internalProcedure(ClientSocketConnectionParameters.class, this, "SslProtocols", new Block((Body) () ->
{
assignMulti(sslProtocols, var);
}));
}
@LegacySignature(returns = "INTEGER", type = Type.LENGTH, name = "SslProtocols")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public integer lengthOfSslProtocols()
{
return function(ClientSocketConnectionParameters.class, this, "length-of-SslProtocols", integer.class, new Block((Body) () ->
{
returnNormal(ArrayAssigner.lengthOf(sslProtocols));
}));
}
@LegacySignature(type = Type.RESIZE, name = "SslProtocols", parameters =
{
@LegacyParameter(name = "size", type = "INT64", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void resizeSslProtocols(final int64 _size)
{
int64 size = TypeFactory.initInput(_size);
internalProcedure(ClientSocketConnectionParameters.class, this, "resize-SslProtocols", new Block((Body) () ->
{
sslProtocols = ArrayAssigner.resize(sslProtocols, size);
}));
}
@LegacySignature(returns = "OBJECT", qualified = "OpenEdge.Net.URI", type = Type.GETTER, name = "URI")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public object<? extends Uri> getUri()
{
return function(ClientSocketConnectionParameters.class, this, "URI", object.class, new Block((Body) () ->
{
returnNormal(uri);
}));
}
@LegacySignature(type = Type.SETTER, name = "URI", parameters =
{
@LegacyParameter(qualified = "OpenEdge.Net.URI", name = "var", type = "OBJECT", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setUri(final object<? extends Uri> _var)
{
object<? extends Uri> var = TypeFactory.initInput(_var);
internalProcedure(ClientSocketConnectionParameters.class, this, "URI", new Block((Body) () ->
{
Assert.notNull(var, new character("Socket connection URI"));
uri.assign(var);
}));
}
@LegacySignature(returns = "LOGICAL", type = Type.GETTER, name = "VerifyHost")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public logical getVerifyHost()
{
return function(ClientSocketConnectionParameters.class, this, "VerifyHost", logical.class, new Block((Body) () ->
{
returnNormal(verifyHost);
}));
}
@LegacySignature(type = Type.SETTER, name = "VerifyHost", parameters =
{
@LegacyParameter(name = "var", type = "LOGICAL", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setVerifyHost(final logical _var)
{
logical var = TypeFactory.initInput(_var);
internalProcedure(ClientSocketConnectionParameters.class, this, "VerifyHost", new Block((Body) () ->
{
verifyHost.assign(var);
}));
}
@LegacySignature(returns = "LOGICAL", type = Type.GETTER, name = "ReuseSession")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public logical getReuseSession()
{
return function(ClientSocketConnectionParameters.class, this, "ReuseSession", logical.class, new Block((Body) () ->
{
returnNormal(reuseSession);
}));
}
@LegacySignature(type = Type.SETTER, name = "ReuseSession", parameters =
{
@LegacyParameter(name = "var", type = "LOGICAL", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setReuseSession(final logical _var)
{
logical var = TypeFactory.initInput(_var);
internalProcedure(ClientSocketConnectionParameters.class, this, "ReuseSession", new Block((Body) () ->
{
reuseSession.assign(var);
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.GETTER, name = "ServerNameIndicator")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public character getServerNameIndicator()
{
return function(ClientSocketConnectionParameters.class, this, "ServerNameIndicator", character.class, new Block((Body) () ->
{
returnNormal(serverNameIndicator);
}));
}
@LegacySignature(type = Type.SETTER, name = "ServerNameIndicator", parameters =
{
@LegacyParameter(name = "var", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void setServerNameIndicator(final character _var)
{
character var = TypeFactory.initInput(_var);
internalProcedure(ClientSocketConnectionParameters.class, this, "ServerNameIndicator", new Block((Body) () ->
{
serverNameIndicator.assign(var);
}));
}
@LegacySignature(type = Type.CONSTRUCTOR)
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void __net_serverconnection_ClientSocketConnectionParameters_constructor__()
{
internalProcedure(ClientSocketConnectionParameters.class, this, "__net_serverconnection_ClientSocketConnectionParameters_constructor__", new Block((Body) () ->
{
__lang_BaseObject_constructor__();
verifyHost.assign(true);
reuseSession.assign(true);
}));
}
@LegacySignature(type = Type.CONSTRUCTOR, parameters =
{
@LegacyParameter(name = "p1", type = "CHARACTER", mode = "INPUT"),
@LegacyParameter(name = "p2", type = "CHARACTER", mode = "INPUT"),
@LegacyParameter(name = "p3", type = "INTEGER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void __net_serverconnection_ClientSocketConnectionParameters_constructor__(final character _p1, final character _p2, final integer _p3)
{
character p1 = TypeFactory.initInput(_p1);
character p2 = TypeFactory.initInput(_p2);
integer p3 = TypeFactory.initInput(_p3);
internalProcedure(ClientSocketConnectionParameters.class, this, "__net_serverconnection_ClientSocketConnectionParameters_constructor__", new Block((Body) () ->
{
__net_serverconnection_ClientSocketConnectionParameters_constructor__();
Assert.notNullOrEmpty(p1, new character("URI scheme"));
Assert.notNullOrEmpty(p2, new character("Host name"));
Assert.isPositive(p3, new character("Port"));
this.uri.assign(ObjectOps.newInstance(Uri.class, "III", p1, p2, p3));
}));
}
@LegacySignature(type = Type.CONSTRUCTOR, parameters =
{
@LegacyParameter(name = "p1", type = "OBJECT", qualified = "openedge.net.uri", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public void __net_serverconnection_ClientSocketConnectionParameters_constructor__(final object<? extends Uri> _p1)
{
object<? extends Uri> p1 = TypeFactory.initInput(_p1);
internalProcedure(ClientSocketConnectionParameters.class, this, "__net_serverconnection_ClientSocketConnectionParameters_constructor__", new Block((Body) () ->
{
__net_serverconnection_ClientSocketConnectionParameters_constructor__();
Assert.notNull(p1, new character("URI"));
this.uri.assign(p1);
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.METHOD, name = "GetConnectionString")
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_FULL)
public character getConnectionString()
{
return function(ClientSocketConnectionParameters.class, this, "GetConnectionString", character.class, new Block((Body) () -> {
Assert.notNull(uri, new character("URI"));
Assert.notNullOrEmpty(uri.ref().getHost(), new character("Host name"));
integer port = uri.ref().getPort();
String scheme = uri.ref().getScheme().getValue();
if (port.isUnknown() && !uri.ref().getScheme().isUnknown())
{
if ("http".equalsIgnoreCase(scheme))
port.assign(80);
else if ("https".equalsIgnoreCase(scheme))
port.assign(443);
}
Assert.notNullOrZero(port, new character("Port"));
if (port.intValue() > 65535)
{
undoThrow(AppError.newInstance(String.format("Port is too large: %d", port.intValue()), 0));
}
StringBuilder sb = new StringBuilder(String.format("-H %s -S %d ", uri.ref().getHost().getValue(), port.intValue()));
if ("https".equalsIgnoreCase(scheme))
sb.append("-ssl");
if (verifyHost.isUnknown() || !verifyHost.booleanValue())
sb.append(" -nohostverify");
if (reuseSession.isUnknown() || !reuseSession.booleanValue())
sb.append(" -nosessionreuse");
// QUIRK: in 4GL any unknown entry will result in '?' to be appended
List<String> protocols = Arrays.stream(sslProtocols).filter(p -> !p.isUnknown()).map(p -> p.getValue()).collect(Collectors.toList());
if (protocols.size() > 0)
sb.append(" -sslprotocols ").append(String.join(",", protocols));
// QUIRK: in 4GL any unknown entry will result in '?' to be appended
List<String> ciphers = Arrays.stream(sslCiphers).filter(p -> !p.isUnknown()).map(p -> p.getValue()).collect(Collectors.toList());
if (ciphers.size() > 0)
sb.append(" -sslciphers ").append(String.join(",", ciphers));
if (!TextOps.isEmpty(serverNameIndicator))
sb.append(" -servername ").append(serverNameIndicator.getValue());
returnNormal(new character(sb.toString().trim()));
}));
}
@LegacySignature(returns = "CHARACTER", type = Type.METHOD, name = "GetConnectionString", parameters =
{
@LegacyParameter(name = "p1", type = "CHARACTER", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_PARTIAL)
public character getConnectionString(final character _p1)
{
return getConnectionString();
}
@LegacySignature(returns = "CHARACTER", type = Type.METHOD, name = "GetConnectionString", parameters =
{
@LegacyParameter(name = "p1", type = "OBJECT", qualified = "openedge.core.serverconnection.formatmaskenum", mode = "INPUT")
})
@LegacyResourceSupport(supportLvl = CVT_LVL_FULL|RT_LVL_PARTIAL)
public character getConnectionString(final object<? extends FormatMaskEnum> _p1)
{
return getConnectionString();
}
}