콘텐츠로 이동

빠른 시작

  1. 설치합니다. 버전은 정확히 고정하세요. 전체 목록은 GitHub Releases에 있습니다 (API 안정성).

    Maven Central

    Maven Central에서 배포하므로 저장소를 따로 추가하지 않습니다. Java 17 이상, Spring Boot 3.x.

    dependencies {
    implementation "kr.suhsaechan:sejongpeia:<version>"
    }
    <dependency>
    <groupId>kr.suhsaechan</groupId>
    <artifactId>sejongpeia</artifactId>
    <version><!-- 고정할 버전 --></version>
    </dependency>

    <version>에는 최신 버전을 넣으세요. Maven Central 아티팩트 페이지에서 확인하고, 전체 버전 목록은 저장소 목록에 있습니다.

  2. 학생 인증을 호출합니다. 학번과 비밀번호로 통합 인증을 한 번 호출합니다.

    Spring Boot 자동 설정이 SuhSejongAuthEngine 빈을 등록합니다.

    @RestController
    @RequiredArgsConstructor
    public class AuthController {
    private final SuhSejongAuthEngine sejongAuthEngine;
    @PostMapping("/auth/sejong")
    public SejongAuthResult authenticate(@RequestParam String studentId,
    @RequestParam String password) {
    return sejongAuthEngine.authenticate(studentId, password);
    }
    }

    분기는 에러 메시지가 아니라 코드로 합니다. 코드 목록은 에러 코드입니다.

  3. 로그인 없이 쓰는 학교 데이터를 호출합니다. 학과 목록을 받고, 첫 학과의 개설강좌를 조회합니다 (학부). "20"(학부)과 학기 값은 학교 값입니다.

    SejongPublicData publicData = new SejongPublicData(); // Spring에서는 빈으로 주입
    List<Department> departments = publicData.departments("20", "2026", "20");
    List<Lecture> lectures = publicData.lectures("20", "2026", "20", departments.get(0).getCode(), "", "");

    SejongPublicData는 프로세스당 하나만 만드세요. 메모리 캐시(기본 24시간)와 같은 요청 합치기가 인스턴스 안에 있습니다.

Spring Boot는 선택 의존성이라 일반 Java 프로젝트는 받지 않습니다. 포털이 허용하는 오래된 TLS 암호를 JVM이 막고 있어서, main() 맨 앞에서 다른 HTTPS 호출보다 먼저 SejongTlsSupport.ensureLegacyCipherEnabled()를 불러야 합니다.

import kr.suhsaechan.sejongpeia.auth.client.SejongPortalClient;
import kr.suhsaechan.sejongpeia.auth.client.SejongSisClient;
import kr.suhsaechan.sejongpeia.auth.model.SejongAuthResult;
import kr.suhsaechan.sejongpeia.auth.parser.SejongClassicReadingParser;
import kr.suhsaechan.sejongpeia.auth.parser.SejongSisParser;
import kr.suhsaechan.sejongpeia.auth.parser.SejongStudentInfoParser;
import kr.suhsaechan.sejongpeia.auth.service.SuhSejongAuthEngine;
import kr.suhsaechan.sejongpeia.common.config.SejongAuthProperties;
import kr.suhsaechan.sejongpeia.common.util.SejongTlsSupport;
SejongTlsSupport.ensureLegacyCipherEnabled(); // main() 맨 앞, 다른 HTTPS 호출보다 먼저
SejongAuthProperties properties = new SejongAuthProperties();
SuhSejongAuthEngine engine = new SuhSejongAuthEngine(new SejongPortalClient(properties), new SejongStudentInfoParser(),
new SejongClassicReadingParser(), new SejongSisClient(properties), new SejongSisParser());
SejongAuthResult result = engine.authenticate(studentId, password);

늦게 부르면 인증이 CONNECTION_FAILED와 원인 안내 메시지로 실패합니다. 이 설정은 JVM 전체에 적용됩니다. 자세한 이유는 레거시 TLS를 보세요. Spring Boot는 시작할 때 자동으로 처리하고, Python과 Node는 자기 연결의 TLS 설정만 바꿉니다.