From 1d943a5ccca1686b1eba8e30150a271a57ab2b99 Mon Sep 17 00:00:00 2001 From: Wataru Sawami Date: Mon, 9 Jul 2018 17:18:16 +0900 Subject: [PATCH] #231 Make PluginException correspond to PersoniumCoreAuthnException. --- pom.xml | 4 +-- .../core/PersoniumCoreAuthnException.java | 18 +++++++++++++ .../core/PersoniumCoreException.java | 25 ------------------- .../io/personium/core/model/DavRsCmp.java | 4 ++- .../core/rs/cell/TokenEndPointResource.java | 14 +++++------ .../resources/personium-messages.properties | 15 ++++------- 6 files changed, 35 insertions(+), 45 deletions(-) diff --git a/pom.xml b/pom.xml index 7ee953ca3..4389c0490 100644 --- a/pom.xml +++ b/pom.xml @@ -40,12 +40,12 @@ io.personium personium-plugin-base - 1.0.5 + 1.0.6-SNAPSHOT io.personium personium-plugins - 1.0.4 + 1.0.5-SNAPSHOT io.personium diff --git a/src/main/java/io/personium/core/PersoniumCoreAuthnException.java b/src/main/java/io/personium/core/PersoniumCoreAuthnException.java index 902cfb41e..5cc01054b 100644 --- a/src/main/java/io/personium/core/PersoniumCoreAuthnException.java +++ b/src/main/java/io/personium/core/PersoniumCoreAuthnException.java @@ -31,6 +31,7 @@ import io.personium.core.auth.OAuth2Helper.Scheme; import io.personium.core.utils.EscapeControlCode; import io.personium.plugin.base.PluginMessageUtils.Severity; +import io.personium.plugin.base.auth.AuthPluginException; /** * ログメッセージ作成クラス. @@ -247,6 +248,23 @@ public static PersoniumCoreAuthnException create(String code, String error) { return new PersoniumCoreAuthnException(code, severity, message, statusCode, error, null); } + /** + * Factory method. + * @param authPluginException AuthPluginException + * @return PersoniumCoreAuthnException + */ + public static PersoniumCoreAuthnException create(AuthPluginException authPluginException) { + int statusCode = authPluginException.getStatusCode(); + Severity severity = decideSeverity(statusCode); + StringBuilder builder = new StringBuilder(); + builder.append("PR").append(statusCode).append("-PA-0001"); + String errorCode = builder.toString(); + String message = PersoniumCoreMessageUtils.getMessage(errorCode); + message = MessageFormat.format(message, authPluginException.getMessage()); + String oAuthError = authPluginException.getOAuthError(); + return new PersoniumCoreAuthnException(errorCode, severity, message, statusCode, oAuthError, null); + } + /** * メッセージをパラメタ置換したものを作成して返します. エラーメッセージ上の $1 $2 等の表現がパラメタ置換用キーワードです。 * @param params 付加メッセージ diff --git a/src/main/java/io/personium/core/PersoniumCoreException.java b/src/main/java/io/personium/core/PersoniumCoreException.java index 11ce5ec89..e35aabeed 100644 --- a/src/main/java/io/personium/core/PersoniumCoreException.java +++ b/src/main/java/io/personium/core/PersoniumCoreException.java @@ -27,7 +27,6 @@ import io.personium.core.exceptions.ODataErrorMessage; import io.personium.core.utils.EscapeControlCode; -import io.personium.plugin.base.PluginException; import io.personium.plugin.base.PluginMessageUtils.Severity; /** @@ -953,17 +952,6 @@ public static class Common { * Pluginエラー. */ public static class Plugin { - // "PL-0001" is used only with create(PluginException). -// /** -// * プラグイン作者が定義したエラー. -// */ -// public static final PersoniumCoreException PLUGIN_DEFINED_ERROR = create("PL-0001"); - - /** - * プラグイン認証失敗. - */ - public static final PersoniumCoreException PLUGIN_AUTHN_FAILED = create("PR400-PL-0001"); - /** * プラグイン内部でキャッチされず、外に出てきてしまった非チェック例外に対応. */ @@ -1114,19 +1102,6 @@ public static PersoniumCoreException create(String code) { return new PersoniumCoreException(code, severity, message, statusCode); } - /** - * Factory method. - * @param pluginException PluginException - * @return PersoniumCoreException - */ - public static PersoniumCoreException create(PluginException pluginException) { - int statusCode = pluginException.getStatusCode(); - Severity severity = decideSeverity(statusCode); - String message = PersoniumCoreMessageUtils.getMessage("PL-0001"); - message = MessageFormat.format(message, pluginException.getMessage()); - return new PersoniumCoreException("PL-0001", severity, message, statusCode); - } - /** * レスポンスコードからログレベルの判定. * @param statusCode ステータスコード diff --git a/src/main/java/io/personium/core/model/DavRsCmp.java b/src/main/java/io/personium/core/model/DavRsCmp.java index 835e37314..1bcd65af9 100644 --- a/src/main/java/io/personium/core/model/DavRsCmp.java +++ b/src/main/java/io/personium/core/model/DavRsCmp.java @@ -570,12 +570,14 @@ static final org.apache.wink.webdav.model.Response createDavResponse(final Strin Element element = WebDAVModelHelper.createElement(qname); element.setTextContent(dCmp.getCellStatus()); ret.setPropertyOk(element); + } else if (DavCmp.TYPE_NULL.equals(type)) { + // If TYPE_NULL, not display anything. + ret.getHref().remove(href); } else { // Collection Resource Resourcetype colRt = of.createResourcetype(); colRt.setCollection(of.createCollection()); ret.setPropertyOk(colRt); - } // Processing ACL diff --git a/src/main/java/io/personium/core/rs/cell/TokenEndPointResource.java b/src/main/java/io/personium/core/rs/cell/TokenEndPointResource.java index 6b72edca4..f81689a7a 100644 --- a/src/main/java/io/personium/core/rs/cell/TokenEndPointResource.java +++ b/src/main/java/io/personium/core/rs/cell/TokenEndPointResource.java @@ -84,8 +84,8 @@ import io.personium.core.rs.PersoniumCoreApplication; import io.personium.core.utils.UriUtils; import io.personium.plugin.base.Plugin; -import io.personium.plugin.base.PluginException; import io.personium.plugin.base.auth.AuthPlugin; +import io.personium.plugin.base.auth.AuthPluginException; import io.personium.plugin.base.auth.AuthenticatedIdentity; /** @@ -305,8 +305,8 @@ private Response callAuthPlugins(String grantType, MultivaluedMap