> For the complete documentation index, see [llms.txt](https://tech.x2bee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://tech.x2bee.com/dev-guide/dev-start/markdown/masking.md).

# Masking처리

다음은 Masking 처리에 대한 설명입니다.

변경점

* Masking 처리를 DAO ↔︎ DBMS에서 MessageConverter (응답값 반환 처리 모듈)로 변경하였습니다.
* 기존에 사용되었던 Mybatis 인터셉터 모듈(`<plugin interceptor="com.x2bee.common.base.masking.MybatisMaskingInterceptor"/>`)은 모두 삭제되었습니다.
* 이전처럼 DAO단에서 변환을 처리하면 서비스 레이어에서 비즈니스 로직을 처리할 때 불편하므로, Controller에서 응답값을 반환할 때 MessageConverter에서 마스킹을 적용하도록 변경하였습니다.

***

## 설명

변경된 방식은 Controller에서 응답값을 반환할 때, 응답값을 처리하는 MessageConverter에서 Masking 처리합니다.

예시 DTO:

{% code title="SampleResponse.java" %}

```java
public class SampleResponse {
    private Long id;

    @MaskString(type = MaskingType.NAME_EN)
    private String name;

    private String description;
}
```

{% endcode %}

사용 방법은 기존과 동일하며, @MaskString 애노테이션을 그대로 사용합니다.

***

## 커스텀 MaskingUtils 적용

MaskingUtils 기능은 기본적으로 common 프로젝트에 있는 MaskingUtils 클래스를 사용합니다.

Apibo처럼 기본 MaskingUtils를 변경해서 적용해야 할 경우, 아래 절차를 따르세요.

1. 커스텀 MaskingUtils 클래스 생성

예:

{% code title="BoApiMaskingUtils.java" %}

```
```

{% endcode %}

```java
@Component
public class BoApiMaskingUtils extends MaskingUtils {
    public String getValue(String value, MaskingType type) {
        return getValue(value, type, true);
    }
}
```

위 예시처럼 공통 MaskingUtils 클래스를 상속받고, 마스킹을 실행하는 함수인 `getValue`를 오버라이딩하여 재정의합니다.

2. 설정값에 커스텀 MaskingUtils bean name 지정

application.yml 예:

{% code title="application.yml" %}

```
```

{% endcode %}

\`\`\`yaml masking: utils: bean: boApiMaskingUtils \`\`\` application.yml 파일에서 \`masking.utils.bean\` 설정에 해당 bean name을 정의합니다.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://tech.x2bee.com/dev-guide/dev-start/markdown/masking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
