public class JPKIUserCertService
extends java.lang.Object
JPKIUserCertService ucs; try { ucs.method(param); } catch (JPKIUserCertException e) { // 機能特有の例外 int code = e.getErrorCode(); } catch (Exception e) { // その他の例外 }
コンストラクタと説明 |
---|
JPKIUserCertService()
JPKIUserCertServiceオブジェクトを作成します。
|
JPKIUserCertService(byte[] certData)
JPKIUserCertServiceオブジェクトを作成します。
|
修飾子とタイプ | メソッドと説明 |
---|---|
JPKIConfirmResult |
confirm()
利用者証明書有効性確認機能。
|
JPKIUserCertBasicData |
getBasicData()
基本4情報取得機能。
|
JPKICardType |
getCardType()
ICカード種別取得機能。
|
void |
showCertViewer()
証明書表示機能。
|
JPKIUserCertCertStatus |
verifyCert()
官職証明書検証機能。
|
public JPKIUserCertService(byte[] certData)
certData
- 電子証明書データ(DER形式)public JPKIUserCertService()
public void showCertViewer() throws JPKIUserCertException
JPKIUserCertService ucs = new JPKIUserCertService(certData); try { // 証明書表示機能 ucs.showCertViewer(); } catch (JPKIUserCertException e) { // JPKIUserCertException 発生時の処理 int code = e.getErrorCode(); } catch (Exception e) { // その他のException発生時の処理 }
JPKIUserCertException
- 証明書表示処理でエラーが発生した場合public JPKIUserCertBasicData getBasicData() throws JPKIUserCertException
JPKIUserCertService ucs = new JPKIUserCertService(certData); try { // 基本4情報取得機能 JPKIUserCertBasicData res = ucs.getBasicData(); } catch (JPKIUserCertException e) { // JPKIUserCertException 発生時の処理 int code = e.getErrorCode(); } catch (Exception e) { // その他のException発生時の処理 }
JPKIUserCertException
- 基本4情報取得処理でエラーが発生した場合JPKIUserCertBasicData
public JPKIUserCertCertStatus verifyCert() throws JPKIUserCertException
JPKIUserCertService ucs = new JPKIUserCertService(certData); try { // 検証 JPKIUserCertCertStatus res = ucs.verifyCert(); // 検証結果の取得 int code = res.getCertStatus(); switch (code) { // 検証成功 case JPKIUserCertCertStatus.JPKI_CVS_OK : break; // 認証パスの構築および検証に失敗 case JPKIUserCertCertStatus.JPKI_CVS_NG : int certPathStatus = res.getCertPathStatus(); break; // 有効性検証に失敗 case JPKIUserCertCertStatus.JPKI_CVS_RESSTATUS_NG : int responseStatus = res.getResponseStatus(); break; default : break; } } catch (JPKIUserCertException e) { // 検証処理に失敗 int code = e.getErrorCode(); } catch (Exception e) { // その他の例外 }
JPKIUserCertException
- 検証処理でエラーが発生した場合JPKIUserCertCertStatus
public JPKIConfirmResult confirm() throws JPKIUserCertException
JPKIUserCertService ucs = new JPKIUserCertService(certData); try{ // 有効性確認 JPKIConfirmResult res = ucs.confirm(); // 結果の取得 int code = res.getCode(); // 結果メッセージの取得 String msg = res.getMessage(); // 結果コードの従った処理 switch (code) { // 有効 case JPKIConfirmResult.JPKI_CONFIRM_OK: // 有効な場合の処理 break; // 無効 (有効期限切れ) case JPKIConfirmResult.JPKI_CLIENT_EXPIRED_ERROR: // 無効 (失効済) case JPKIConfirmResult.JPKI_SERVER_REVOKED_ERROR: // 無効 (失効申請中) case JPKIConfirmResult.JPKI_SERVER_APPLYED_ERROR: // 無効(一時保留) case JPKIConfirmResult.JPKI_SERVER_HOLD_ERROR: // 無効の場合の処理 break; // 有効性確認失敗 default : // 有効性確認中に発生したExceptionの取得 Exception ex = res.getException(); // サーバ要因エラー,HTTP通信エラー if(ex == null){ // ・サーバ要因エラー(JPKIConfirmResultフィールド値:600番台) // ・HTTP通信エラー (HTTPステータスコード:100〜500番台) // の場合の処理 // クライアント要因エラー }else{ switch(ex){ // JPKIUserCertExceptionの場合 case JPKIUserCertException: // エラーコード取得 int code = ex.getErrorCode(); break; // JPKICryptJNIExceptionの場合 case JPKICryptJNIException: // エラーコード取得 int code = ex.getErrorCode(); int wincode = ex.getwinErrorCode(); break; // Java標準Exceptionの場合 case Exception: // Java標準Exceptionの場合の処理 break; // 上記以外の例外の場合 default: // 処理 break; } } break; } } catch(JPKIUserCertException e){ // JPKIUserCertException 発生時の処理 } catch(Exception e){ // その他のException発生時の処理 }
JPKIUserCertException
- 確認処理でエラーが発生した場合JPKIConfirmResult
public JPKICardType getCardType() throws JPKIUserCertException
JPKIUserCertService ucs = new JPKIUserCertService(); try{ // ICカード種別取得 JPKICardType cardType = ucs.getCardType(); // 結果の取得 int id = cardType.getID(); if (id == JPKICardType.JPKI_CARD_ID_JYUKI) { // 住基カードの場合 } else if (id == JPKICardType.JPKI_CARD_ID_BANGO) { // 個人番号カードの場合 } else if (id == JPKICardType.JPKI_CARD_ID_UNKNOWN) { // 不明の場合 } } catch(JPKIUserCertException e){ // JPKIUserCertException 発生時の処理 } catch(Exception e){ // その他のException発生時の処理 }
JPKIUserCertException
- ICカード種別取得処理でエラーが発生した場合JPKICardType