From commits-return-50839-apmail-directory-commits-archive=directory.apache.org@directory.apache.org Sat Mar 16 14:13:49 2019 Return-Path: X-Original-To: apmail-directory-commits-archive@www.apache.org Delivered-To: apmail-directory-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 447D418D4F for ; Sat, 16 Mar 2019 14:13:49 +0000 (UTC) Received: (qmail 28638 invoked by uid 500); 16 Mar 2019 14:13:49 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 28599 invoked by uid 500); 16 Mar 2019 14:13:49 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 28589 invoked by uid 99); 16 Mar 2019 14:13:49 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 16 Mar 2019 14:13:49 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id 5F248853B4; Sat, 16 Mar 2019 14:13:48 +0000 (UTC) Date: Sat, 16 Mar 2019 14:13:48 +0000 To: "commits@directory.apache.org" Subject: [directory-fortress-enmasse] branch FC-265 updated: add a switch to turn on / off arbac02 checks. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <155274562834.7258.3985648908245523264@gitbox.apache.org> From: smckinney@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: directory-fortress-enmasse X-Git-Refname: refs/heads/FC-265 X-Git-Reftype: branch X-Git-Oldrev: e66a5e639e3c3d9807bd42676269cac8aa52998a X-Git-Newrev: 0bb634a519302aed0e585ee0be5c6974b92ef0b5 X-Git-Rev: 0bb634a519302aed0e585ee0be5c6974b92ef0b5 X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. smckinney pushed a commit to branch FC-265 in repository https://gitbox.apache.org/repos/asf/directory-fortress-enmasse.git The following commit(s) were added to refs/heads/FC-265 by this push: new 0bb634a add a switch to turn on / off arbac02 checks. 0bb634a is described below commit 0bb634a519302aed0e585ee0be5c6974b92ef0b5 Author: Shawn McKinney AuthorDate: Sat Mar 16 09:13:41 2019 -0500 add a switch to turn on / off arbac02 checks. --- .../apache/directory/fortress/rest/SecUtils.java | 29 ++++++++++------------ 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/apache/directory/fortress/rest/SecUtils.java b/src/main/java/org/apache/directory/fortress/rest/SecUtils.java index 4d3981a..ac8be84 100644 --- a/src/main/java/org/apache/directory/fortress/rest/SecUtils.java +++ b/src/main/java/org/apache/directory/fortress/rest/SecUtils.java @@ -71,10 +71,7 @@ public class SecUtils if (httpRequest == null) { // Improper container config. - fortResponse = new FortResponse(); - fortResponse.setErrorCode(GlobalErrIds.REST_NULL_HTTP_REQ_ERR); - fortResponse.setErrorMessage("initializeSession detected null HTTP Request"); - fortResponse.setHttpStatus(403); + fortResponse = createError( GlobalErrIds.REST_NULL_HTTP_REQ_ERR, "initializeSession detected null HTTP Request", 403); } else { @@ -91,26 +88,26 @@ public class SecUtils } else { - String error = "initializeSession couldn't get a Security Session."; - fortResponse = new FortResponse(); - fortResponse.setErrorCode(GlobalErrIds.USER_SESS_NULL); - fortResponse.setErrorMessage(error); - fortResponse.setHttpStatus(403); - LOG.info(error); + fortResponse = createError( GlobalErrIds.USER_SESS_NULL, "initializeSession couldn't get a Security Session.", 403); } } catch (SecurityException se) { // A problem deserializing the security principal. - String error = "initializeSession caught SecurityException=" + se.getMessage(); - fortResponse = new FortResponse(); - LOG.info(error); - fortResponse.setErrorCode(se.getErrorId()); - fortResponse.setErrorMessage(error); - fortResponse.setHttpStatus(se.getHttpStatus()); + fortResponse = createError( se.getErrorId(), "initializeSession caught SecurityException=" + se.getMessage(), se.getHttpStatus()); } } } return fortResponse; } + + private static FortResponse createError(int errId, String errMsg, int hCode) + { + FortResponse fortResponse = new FortResponse(); + fortResponse.setErrorCode(errId); + fortResponse.setErrorMessage(errMsg); + fortResponse.setHttpStatus(hCode); + LOG.info(errMsg); + return fortResponse; + } } \ No newline at end of file