2024년 12월 24일 화요일

Letsencrypt 인증서

 [ 출처: https://www.fntec.net/ ] [ https://letsencrypt.org/ ]

 

Letsencrypt 인증서에 도메인 등록하기, 수정하기, 추가하기

 Centos7 버젼을 기준으로 설명합니다.

처음으로 도메인을 등록하는 경우

Letsencrypt를 설치한 후 처음으로 도메인을 등록하는 방법은 다음과 같습니다.

certbot --apache -d 도메인명

만약 서브 도메인을 하나로 묶어서 등록하고자 하는 경우에는 다음과 같이 '-d 도메인명'를 띄어쓰기로 구분하여 뒤에 열거해줍니다.

복수 도메인 등록시

certbot --apache -d aaa.com -d www.aaa.com -d ko.aaa.com -d en.aaa.com -d ja.aaa.com

 참고로 첫번째 도메인이 체인명으로 지정되어 등록되므로 도메인 등록 후 '/etc/letsencrypt/live'에 접속해보면 'aaa.com' 도메인명으로 파일이 생성된 것을 확인할 수 있습니다.

이미 등록한 체인에 도메인을 추가 또는 삭제하는 경우

처음 Letsencrypt에 도메인을 등록할 때와 방법은 매우 비슷합니다. 처음 등록시 'certbot --apache -d 도메인명'와 같은 형식을 취하는데 이미 존재하는 체인에 도메인을 추가 또는 삭제하는 경우에는 'certbot --cert-name 체인명 -d 도메인명'와 같이 입력하면 됩니다.

도메인 추가시 또는 삭제시

certbot --cert-name aaa.com -d aaa.com -d www.aaa.com -d ko.aaa.com -d en.aaa.com -d ja.aaa.com

위의 명령어를 잘 보면 'aaa.com -d aaa.com'와 같이 aaa.com이 2차례 보이는데 이것은 잘 못 입력된 것이 아니라 앞의 aaa.com는 체인명, 뒤의 aaa.com은 도메인명입니다. aaa.com도메인에 인증서를 설정하고 싶다면 잊지말고 도메인 목록 부분에도 넣어줘야 합니다.

도메인명을 입력하는 곳에는 삭제할 도메인은 제거하고 추가할 도메인은 추가해서 이 체인에 등록될 도메인을 모두 적어줘야 합니다. 예를 들어 현재 등록되어 있는 도메인이 aaa.com, www.aaa.com, en.aaa.com인데 en.aaa.com을 삭제하고 ko.aaa.com을 추가하고 싶다면 다음과 같이 실행하면 됩니다.

도메인 추가시 또는 삭제시 예시

certbot --cert-name aaa.com -d aaa.com -d www.aaa.com -d ko.aaa.com

 

Letsencrypt에 등록된 체인명을 모를 때에는?

'/etc/letsencrypt/live'에 접속해보면 생성된 체인이 디렉토리로 존재하므로 유추할 수 있습니다.

Letsencrypt의 특정 체인에 등록된 도메인 목록을 모를 때에는?

체인명만 알고 있다면 도메인명을 대충 아무거나 넣어서 아래와 같이 명령해봅니다.

certbot --cert-name 체인명 -d 도메인명(대충 입력)

그러면 현재 등록된 도메인명이 이러이러한데 당신은 현재 이러이러한 도메인을 새로 등록하거나 삭제하려고 하는데 맞느냐는 확인을 해오므로 이때 등록된 도메인 목록을 알 수있습니다. 물론 이 질문에는 'NO'라고 대답해야 하겠습니다.

certbot --cert-name aaa.com 와 같이 체인명만 적어주면?

'certbot --cert-name 체인명 -d 도메인명'과 같은 형식으로 Letsencrypt의 도메인을 추가 또는 삭제할 수 있으나 도메인명을 빼고 입력하면 다음과 같은 메세지를 볼 수 있습니다.

What would you like to do?

1: Attempt to reinstall this existing certificate

2: Renew & replace the cert (limit ~5 per 7 days)

 

이 때 1번을 선택하면 이미 존재하는 인증서를 재설치하게 되고 2번을 선택하면 갱신 또는 대체 작업이 시작되는데 2번 과정은 7일 이내에 최대 5회까지만 가능하므로 주의가 필요합니다.

2024년 12월 17일 화요일

[ABAP]_Table Control에서 필드 Sort 처리 기능 넣기

 [출처 : https://sapjoy.co.kr/ ]

  DATA SORT_FIELD(30),
         LS_COLS TYPE CXTAB_COLUMN.

    WHEN 'ASC' OR 'DES'.
      READ TABLE TC1-COLS INTO LS_COLS WITH KEY SELECTED 'X'.
      IF SY-SUBRC 0.
        MOVE LS_COLS-SCREEN-NAME+8(20TO SORT_FIELD.
        CASE SAVE_OK.
          WHEN 'ASC'.
            SORT IT_301_S BY (SORT_FIELDASCENDING.
          when 'DESC'.
            SORT IT_301_S BY (SORT_FIELDDESCENDING.
        ENDCASE.
      ELSE.
        MESSAGE I001 WITH 'Select the field you want to sort on.!'.
      ENDIF.

2024년 12월 2일 월요일

[CAMEL]_Apache CAMEL과 SAP RFC 연동

 [ 출처 : https://www.cdata.com/ ]

 

Integrate with SAP Data using Apache Camel2 

Create a simple Java app that uses Apache Camel routing and the CData JDBC Driver to copy SAP data to a JSON file on disk.

Apache Camel is an open source integration framework that allows you to integrate various systems consuming or producing data. When paired with the CData JDBC Driver for SAP ERP, you can write Java apps that use Camel routes that integrate with live SAP data. This article walks through creating an app in NetBeans that connects, queries, and routes SAP data to a JSON file.

With built-in optimized data processing, the CData JDBC Driver offers unmatched performance for interacting with live SAP data. When you issue complex SQL queries to SAP, the driver pushes supported SQL operations, like filters and aggregations, directly to SAP and utilizes the embedded SQL engine to process unsupported operations client-side (often SQL functions and JOIN operations). Its built-in dynamic metadata querying allows you to work with and analyze SAP data using native data types.
 

About SAP Data Integration

CData provides the easiest way to access and integrate live data from SAP. Customers use CData connectivity to:

    Access every edition of SAP, including SAP R/3, SAP NetWeaver, SAP ERP / ECC 6.0, and SAP S/4 HANA on premises data that is exposed by the RFC.
    Perform actions like sending IDoc or IDoc XML files to the server and creating schemas for functions or queries through SQL stored procedures.
    Connect optimally depending on where a customer's SAP instance is hosted.
        Customers using SAP S/4HANA cloud public edition will use SAP NetWeaver Gateway connectivity
        Customers using SAP S/4HANA private edition will use either SAP ERP or SAP NetWeaver Gateway connectivity.

While most users leverage our tools to replicate SAP data to databases or data warehouses, many also integrate live SAP data with analytics tools such as Tableau, Power BI, and Excel.

Getting Started

Creating A New Maven/Java Project

Follow the steps below to create a new Java project and add the appropriate dependencies:

    Open NetBeans and create a new project.
    Select Maven from the categories list and Java Application from the projects list, then click Next.
    Name the project (and adjust any other properties) and click Finish.
    In the source package, create a new Java class (we used App.java for this article) and add the main method to the class.

Adding Project Dependencies

With the project created, we can start adding the dependencies needed to work with live SAP data from our App. If you have not already done so, install Maven in your environment, as it is required to add the JAR file for the CData JDBC Driver to your project.


Installing the CData JDBC Driver for SAP ERP with Maven
1. Download the CData JDBC Driver for SAP ERP installer, unzip the package, and run the JAR file to install the driver.
2. Use Maven to install the JDBC Driver as a connector.

    mvn install:install-file
    -Dfile="C:\Program Files\CData[product_name] 2019\lib\cdata.jdbc.saperp.jar"
    -DgroupId="org.cdata.connectors"
    -DartifactId="cdata-saperp-connector"
    -Dversion="19"
    -Dpackaging=jar

Once the JDBC Driver is installed, we can add dependencies to our project. To add a dependency, you can either edit the pom.xml file or right-click the dependencies folder and click Add Dependency. The properties for each dependency follow, but you can search through the available libraries by typing the name of the dependency in the Query box in the Add Dependency wizard.




























Accessing SAP Data in Java Apps with Camel

After adding the required dependencies, we can use the Java DSL (Domain Specific Language) to create routes with access to live SAP data. Code snippets follow. Download the sample project (zip file) to follow along (make note of the TODO comments).

Start by importing the necessary classes into our main class.

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;
import org.apache.camel.support.SimpleRegistry;
import org.apache.commons.dbcp2.BasicDataSource;
import org.apache.log4j.BasicConfigurator;

Then in the main method, we configure logging, create a new BasicDataSource and add it to the registry, create a new CamelContext, and finally add a route to the context. In this sample, we route SAP data to a JSON file.


Configure Logging

BasicConfigurator.configure();

Create a BasicDataSource

Create a BasicDataSource and set the driver class name (cdata.jdbc.salesforce.SalesforceDriver) and URL (using the required connection properties).

The driver supports connecting to an SAP system using the SAP Java Connector (SAP JCo). Install the files (sapjco3.jar and sapjco3.dll) to the appropriate directory for the hosting application or platform. See the "Getting Started" chapter in the help documentation for information on using the SAP JCo files.

In addition, you can connect to an SAP system using Web services (SOAP). To use Web services, you must enable SOAP access to your SAP system and set the Client, RFCUrl, User, and Password properties, under the Authentication section.

For more information, see this guide on obtaining the connection properties needed to connect to any SAP system.

BasicDataSource basic = new BasicDataSource();
basic.setDriverClassName("cdata.jdbc.saperp.SAPERPDriver");
basic.setUrl("jdbc:saperp:Host=sap.mydomain.com;User=EXT90033;Password=xxx;Client=800;System Number=09;ConnectionType=Classic;Location=C:/mysapschemafolder;");>

The CData JDBC Driver includes a built-in connection string designer to help you configure the connection URL.


Built-in Connection String Designer

For assistance in constructing the JDBC URL, use the connection string designer built into the SAP JDBC Driver. Either double-click the JAR file or execute the jar file from the command line.

java -jar cdata.jdbc.saperp.jar



Fill in the connection properties and copy the connection string to the clipboard.

















Add the BasicDataSource to the Registry and Create a CamelContext

SimpleRegistry reg = new SimpleRegistry();
reg.bind("myDataSource", basic);
 
CamelContext context = new DefaultCamelContext(reg);


Add Routing to the CamelContext

The routing below uses a timer component to run one time and passes a SQL query to the JDBC Driver. The results are marshaled as JSON (and formatted for pretty print) and passed to a file component to write to disk as a JSON file.

context.addRoutes(new RouteBuilder() {
@Override
public void configure() {
from("timer://foo?repeatCount=1")
.setBody(constant("SELECT * FROM Account LIMIT 10"))
.to("jdbc:myDataSource")
.marshal().json(true)
.to("file:C:\\Users\\USER\\Documents?fileName=account.json");
}
});

Managing the CamelContext Lifecycle

With the route defined, start the CamelContext to begin the lifecycle. In this example, we wait 10 seconds and then shut down the context.

context.start();
Thread.sleep(10000);
context.stop();

 

Free Trial, Sample Project & Technical Support

Now, you have a working Java application that uses Camel to route data from SAP to a JSON file. Download a free, 30-day trial of the CData JDBC Driver for SAP ERP and the sample project (make note of the TODO comments) and start working with your live SAP data in Apache Camel. Reach out to our Support Team if you have any questions.

 

 

 

 

 [ 출처 : https://camel.apache.org/ ]

SAP NetWeaver

Since Camel 2.12

Only producer is supported

The SAP Netweaver integrates with the SAP NetWeaver Gateway using HTTP transports.

This camel component supports only producer endpoints.

Maven users will need to add the following dependency to their pom.xml for this component:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-sap-netweaver</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>

URI format

The URI scheme for a sap netweaver gateway component is as follows

sap-netweaver:https://host:8080/path?username=foo&password=secret

Prerequisites

You would need to have an account on the SAP NetWeaver system to be able to leverage this component. SAP provides a demo setup where you can request an account.

This component uses the basic authentication scheme for logging into SAP NetWeaver.

Configuring Options

Camel components are configured on two separate levels:

  • component level

  • endpoint level

Configuring Component Options

At the component level, you set general and shared configurations that are, then, inherited by the endpoints. It is the highest configuration level.

For example, a component may have security settings, credentials for authentication, urls for network connection and so forth.

Some components only have a few options, and others may have many. Because components typically have pre-configured defaults that are commonly used, then you may often only need to configure a few options on a component; or none at all.

You can configure components using:

  • the Component DSL.

  • in a configuration file (application.properties, *.yaml files, etc).

  • directly in the Java code.

Configuring Endpoint Options

You usually spend more time setting up endpoints because they have many options. These options help you customize what you want the endpoint to do. The options are also categorized into whether the endpoint is used as a consumer (from), as a producer (to), or both.

Configuring endpoints is most often done directly in the endpoint URI as path and query parameters. You can also use the Endpoint DSL and DataFormat DSL as a type safe way of configuring endpoints and data formats in Java.

A good practice when configuring options is to use Property Placeholders.

Property placeholders provide a few benefits:

  • They help prevent using hardcoded urls, port numbers, sensitive information, and other settings.

  • They allow externalizing the configuration from the code.

  • They help the code to become more flexible and reusable.

The following two sections list all the options, firstly for the component followed by the endpoint.

Component Options

The SAP NetWeaver component supports 2 options, which are listed below.

Name Description Default Type

lazyStartProducer (producer)

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

autowiredEnabled (advanced)

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

boolean

Endpoint Options

The SAP NetWeaver endpoint is configured using URI syntax:

sap-netweaver:url

With the following path and query parameters:

Path Parameters (1 parameters)

Name Description Default Type

url (producer)

Required Url to the SAP net-weaver gateway server.


String

Query Parameters (6 parameters)

Name Description Default Type

flatternMap (producer)

If the JSON Map contains only a single entry, then flattern by storing that single entry value as the message body.

true

boolean

json (producer)

Whether to return data in JSON format. If this option is false, then XML is returned in Atom format.

true

boolean

jsonAsMap (producer)

To transform the JSON from a String to a Map in the message body.

true

boolean

password (producer)

Required Password for account.


String

username (producer)

Required Username for account.


String

lazyStartProducer (producer (advanced))

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

boolean

Message Headers

The SAP NetWeaver component supports 3 message header(s), which is/are listed below:

Name Description Default Type

CamelNetWeaverCommand (producer)

Constant: COMMAND

Required The command to execute in http://msdn.microsoft.com/en-us/library/cc956153.aspxMS ADO.Net Data Service format.


String

CamelHttpPath (producer)

Constant: HTTP_PATH

The http path.


String

Accept (producer)

Constant: ACCEPT

The media type.


String

Examples

This example is using the flight demo example from SAP, which is available online over the internet here.

In the route below we request the SAP NetWeaver demo server using the following url

https://sapes4.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT

And we want to execute the following command

FlightCollection(carrid='AA',connid='0017',fldate=datetime'2016-04-20T00%3A00%3A00')

To get flight details for the given flight. The command syntax is in MS ADO.Net Data Service format.

We have the following Camel route

from("direct:start")
    .setHeader(NetWeaverConstants.COMMAND, constant(command))
    .toF("sap-netweaver:%s?username=%s&password=%s", url, username, password)
    .to("log:response")
    .to("velocity:flight-info.vm")

Where url, username, password and command are defined as:

    private String username = "P1909969254";
    private String password = "TODO";
    private String url = "https://sapes4.sapdevcenter.com/sap/opu/odata/IWFND/RMTSAMPLEFLIGHT";
    private String command = "FlightCollection(carrid='AA',connid='0017',fldate=datetime'2016-04-20T00%3A00%3A00')";

The password is invalid. You would need to create an account at SAP first to run the demo.

The velocity template is used for formatting the response to a basic HTML page

<html>
  <body>
  Flight information:

  <p/>
  <br/>Airline ID: $body["AirLineID"]
  <br/>Aircraft Type: $body["AirCraftType"]
  <br/>Departure city: $body["FlightDetails"]["DepartureCity"]
  <br/>Departure airport: $body["FlightDetails"]["DepartureAirPort"]
  <br/>Destination city: $body["FlightDetails"]["DestinationCity"]
  <br/>Destination airport: $body["FlightDetails"]["DestinationAirPort"]

  </body>
</html>

When running the application, you get sample output:

Flight information:
Airline ID: AA
Aircraft Type: 747-400
Departure city: new york
Departure airport: JFK
Destination city: SAN FRANCISCO
Destination airport: SFO

Spring Boot Auto-Configuration

When using sap-netweaver with Spring Boot make sure to use the following Maven dependency to have support for auto configuration:

<dependency>
  <groupId>org.apache.camel.springboot</groupId>
  <artifactId>camel-sap-netweaver-starter</artifactId>
  <version>x.x.x</version>
  <!-- use the same version as your Camel core version -->
</dependency>

The component supports 3 options, which are listed below.

Name Description Default Type

camel.component.sap-netweaver.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.sap-netweaver.enabled

Whether to enable auto configuration of the sap-netweaver component. This is enabled by default.


Boolean

camel.component.sap-netweaver.lazy-start-producer

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

Boolean

 

2024년 11월 25일 월요일

[LINUX] 로그 메세지 한도 조정 처리


로그에 아래와 같은 반복 메세지가 표시됨.

imjournal: XXX messages lost due to rate-limiting (20000 allowed within 600 seconds) : 1 Times
짧은 시간에 너무 많은 로그가 쌓여 발생되는 오류로 로그 설정상의 한도를 올려줌.
# vi /etc/rsyslog.conf
$imjournalRatelimitInterval 0
$imjournalRatelimitBurst 0

2024년 6월 24일 월요일

[SAP] Product Route Archiving

Route 삭제는 두 개의 프로그램을 통하여 가능함.
Tcode QSR6


Tcode SARA
PP_PLAN Object에서 삭제하여 대상은 Write에서 진행함.







2024년 5월 30일 목요일

[LDAP]_LDAP 명령어

 

Ldap 명령어
 # ldapsearch -x -D 'cn=vmail,dc=xxxx,dc=xx' -H 'ldap://xx.xx.xx.xx:389' -W -b 'o=domains,dc=xxxx,dc=xx' '(domainName=*)'
 -D 'cn=.....' : 조회를 위한 사용자 정보
 -H 'ldap....' : 로그인 서버 정보
 -b 'o=domains,dc=xxxx,dc=xx' '(domainName=*)'   : 조회시작지점과 조회 조건


Enter LDAP Password:
# extended LDIF
#
# LDAPv3
# base <o=domains,dc=qnct,dc=cn> with scope subtree
# filter: (domainName=*)
# requesting: ALL
#

# xxxx.xx, domains, xxxx.xx
dn: domainName=xxxx.xx,o=domains,dc=xxxx,dc=xx
objectClass: mailDomain
domainName: xxxx.xx
mtaTransport: dovecot
accountSetting: minPasswordLength:8
accountSetting: defaultQuota:1024
enabledService: mail
cn: xxxxxxxxxxxxxxxxxxxxxxxx
accountStatus: active
domainCurrentUserNumber: 194
domainCurrentQuotaSize: 1887436800

# xxx.xxx, domains, xxxx.xx
dn: domainName=xxx.xxx,o=domains,dc=xxxx,dc=xx
objectClass: mailDomain
domainName: xxx.xxx
mtaTransport: dovecot
enabledService: mail
accountSetting: minPasswordLength:8
cn: xxxxxxxx
accountStatus: active
domainCurrentUserNumber: xxx
domainCurrentQuotaSize: 1153433600

# search result
search: 2
result: 0 Success

# numResponses: 3
# numEntries: 2


* LDAP로 항목 추가하기(빨간색이 입력하는 내용임)

# ldapmodify -a -D cn=Manager,dc=xxxx,dc=xx -W -H ldap://xxx.xxx.xxx.xxx:389 -x
Enter LDAP Password: xxxxxxxxxx
dn: mail=xxxx@xxxx.xxx,ou=Users,domainName=xxxx.xxx,o=domains,dc=xxxx,dc=xxx
changetype: modify
add: mailForwardingAddress
mailForwardingAddress: xxxx@xxxx.xxx

<--엔터를 쳐야 modify 메세지가 보임
modifying entry "mail=xxxx@xxxx.xxx,ou=Users,domainName=xxxx.xxx,o=domains,dc=xxxx,dc=xxx"





2024년 5월 9일 목요일

[ABAP]_ABAP 소스 다운로드 프로그램

 [ 소스다운 ]   사용법

프로그램은 charset을 EUC-KR로 적용한 것으로 실행시 한글이 깨질경우 SAPGUI 설정을 

아래와 같이 변경해야 한다.