Search in sources :

Example 1 with Authentication

use of org.apache.inlong.manager.client.api.auth.Authentication in project incubator-inlong by apache.

the class InlongGroupTransfer method createFlinkExtInfo.

public static List<InlongGroupExtInfo> createFlinkExtInfo(FlinkSortBaseConf flinkSortBaseConf) {
    List<InlongGroupExtInfo> extInfos = new ArrayList<>();
    InlongGroupExtInfo sortType = new InlongGroupExtInfo();
    sortType.setKeyName(InlongGroupSettings.SORT_TYPE);
    sortType.setKeyValue(SortType.FLINK.getType());
    extInfos.add(sortType);
    if (flinkSortBaseConf.getAuthentication() != null) {
        Authentication authentication = flinkSortBaseConf.getAuthentication();
        AuthType authType = authentication.getAuthType();
        AssertUtil.isTrue(authType == AuthType.SECRET_AND_TOKEN, String.format("Unsupported authentication:%s for flink", authType.name()));
        final SecretTokenAuthentication secretTokenAuthentication = (SecretTokenAuthentication) authentication;
        InlongGroupExtInfo authTypeExt = new InlongGroupExtInfo();
        authTypeExt.setKeyName(InlongGroupSettings.SORT_AUTHENTICATION_TYPE);
        authTypeExt.setKeyValue(authType.toString());
        extInfos.add(authTypeExt);
        InlongGroupExtInfo authValue = new InlongGroupExtInfo();
        authValue.setKeyName(InlongGroupSettings.SORT_AUTHENTICATION);
        authValue.setKeyValue(secretTokenAuthentication.toString());
        extInfos.add(authValue);
    }
    if (StringUtils.isNotEmpty(flinkSortBaseConf.getServiceUrl())) {
        InlongGroupExtInfo flinkUrl = new InlongGroupExtInfo();
        flinkUrl.setKeyName(InlongGroupSettings.SORT_URL);
        flinkUrl.setKeyValue(flinkSortBaseConf.getServiceUrl());
        extInfos.add(flinkUrl);
    }
    if (MapUtils.isNotEmpty(flinkSortBaseConf.getProperties())) {
        InlongGroupExtInfo flinkProperties = new InlongGroupExtInfo();
        flinkProperties.setKeyName(InlongGroupSettings.SORT_PROPERTIES);
        flinkProperties.setKeyValue(JsonUtils.toJson(flinkSortBaseConf.getProperties()));
        extInfos.add(flinkProperties);
    }
    return extInfos;
}
Also used : TokenAuthentication(org.apache.inlong.manager.client.api.auth.TokenAuthentication) SecretTokenAuthentication(org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication) Authentication(org.apache.inlong.manager.client.api.auth.Authentication) ArrayList(java.util.ArrayList) SecretTokenAuthentication(org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication) AuthType(org.apache.inlong.manager.client.api.auth.Authentication.AuthType) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Example 2 with Authentication

use of org.apache.inlong.manager.client.api.auth.Authentication in project incubator-inlong by apache.

the class InlongGroupTransfer method createPulsarExtInfo.

public static List<InlongGroupExtInfo> createPulsarExtInfo(PulsarBaseConf pulsarBaseConf) {
    List<InlongGroupExtInfo> extInfos = new ArrayList<>();
    if (pulsarBaseConf.getAuthentication() != null) {
        Authentication authentication = pulsarBaseConf.getAuthentication();
        AuthType authType = authentication.getAuthType();
        AssertUtil.isTrue(authType == AuthType.TOKEN, String.format("Unsupported authentication:%s for pulsar", authType.name()));
        TokenAuthentication tokenAuthentication = (TokenAuthentication) authentication;
        InlongGroupExtInfo authTypeExt = new InlongGroupExtInfo();
        authTypeExt.setKeyName(InlongGroupSettings.PULSAR_AUTHENTICATION_TYPE);
        authTypeExt.setKeyValue(tokenAuthentication.getAuthType().toString());
        extInfos.add(authTypeExt);
        InlongGroupExtInfo authValue = new InlongGroupExtInfo();
        authValue.setKeyName(InlongGroupSettings.PULSAR_AUTHENTICATION);
        authValue.setKeyValue(tokenAuthentication.getToken());
        extInfos.add(authValue);
    }
    if (StringUtils.isNotEmpty(pulsarBaseConf.getPulsarAdminUrl())) {
        InlongGroupExtInfo pulsarAdminUrl = new InlongGroupExtInfo();
        pulsarAdminUrl.setKeyName(InlongGroupSettings.PULSAR_ADMIN_URL);
        pulsarAdminUrl.setKeyValue(pulsarBaseConf.getPulsarAdminUrl());
        extInfos.add(pulsarAdminUrl);
    }
    if (StringUtils.isNotEmpty(pulsarBaseConf.getPulsarServiceUrl())) {
        InlongGroupExtInfo pulsarServiceUrl = new InlongGroupExtInfo();
        pulsarServiceUrl.setKeyName(InlongGroupSettings.PULSAR_SERVICE_URL);
        pulsarServiceUrl.setKeyValue(pulsarBaseConf.getPulsarServiceUrl());
        extInfos.add(pulsarServiceUrl);
    }
    return extInfos;
}
Also used : TokenAuthentication(org.apache.inlong.manager.client.api.auth.TokenAuthentication) SecretTokenAuthentication(org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication) Authentication(org.apache.inlong.manager.client.api.auth.Authentication) ArrayList(java.util.ArrayList) TokenAuthentication(org.apache.inlong.manager.client.api.auth.TokenAuthentication) SecretTokenAuthentication(org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication) AuthType(org.apache.inlong.manager.client.api.auth.Authentication.AuthType) InlongGroupExtInfo(org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)

Aggregations

ArrayList (java.util.ArrayList)2 Authentication (org.apache.inlong.manager.client.api.auth.Authentication)2 AuthType (org.apache.inlong.manager.client.api.auth.Authentication.AuthType)2 SecretTokenAuthentication (org.apache.inlong.manager.client.api.auth.SecretTokenAuthentication)2 TokenAuthentication (org.apache.inlong.manager.client.api.auth.TokenAuthentication)2 InlongGroupExtInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupExtInfo)2