{"id":474,"date":"2017-08-04T21:49:39","date_gmt":"2017-08-04T19:49:39","guid":{"rendered":"http:\/\/dekarlab.de\/wp\/?p=474"},"modified":"2020-05-23T15:36:02","modified_gmt":"2020-05-23T13:36:02","slug":"authentication-and-authorizaton-xmla-connect-and-mondrian","status":"publish","type":"post","link":"https:\/\/dekarlab.de\/wp\/?p=474","title":{"rendered":"Authentication and authorizaton for XMLA Connect and Mondrian"},"content":{"rendered":"<p>If you would like to turn on basic authentication for mondrian cubes from excel you need to implement steps below.<br \/>\n<!--more--><br \/>\nFirst step, what you need to do is to impelment Authentication Callback Class. This class is an extension of default AuthenticatingXmlaRequestCallback class, which is provided by mondrian.<\/p>\n<p>XMLA Connect sends from Excel user and password as http request authorization header. We need to read user name and password and auhtenticate against LDAP or database, where users are saved.<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\r\npublic class CustomAuthentication extends AuthenticatingXmlaRequestCallback {\r\n\r\npublic void preAction(HttpServletRequest request, Element[] requestSoapParts, Map&lt;String, Object&gt; context)\r\n            throws Exception {\r\n        String authHeader = request.getHeader(&quot;authorization&quot;);\r\n        String encodedValue = authHeader.split(&quot; &quot;)[1];\r\n        String decodedValue = Base64.base64Decode(encodedValue);\r\n        int k = decodedValue.indexOf(&quot;:&quot;);\r\n        if (k &gt; 0) {\r\n            String user = decodedValue.substring(0, k);\r\n            String password = decodedValue.substring(k + 1, decodedValue.length());\r\n            context.put(XmlaConstants.CONTEXT_XMLA_USERNAME, user);\r\n            context.put(XmlaConstants.CONTEXT_XMLA_PASSWORD, password);\r\n        }\r\n\r\n        super.preAction(request, requestSoapParts, context);\r\n    }\r\n\r\n  \/**\r\n     * Implementation of authentication\r\n     *\/\r\n    @Override\r\n    public String authenticate(String username, String password, String sessionID) {\r\n        try {\r\n            customAuthMethod(username, password);\r\n        } catch (Exception e) {\r\n            throwAuthenticationException(&quot;User: &quot; + username + e.getMessage());\r\n        }\r\n        \/\/role\r\n        return &quot;xmla&quot;;\r\n    }\r\n}\r\n<\/pre>\n<p>Next we need to register this class in web.xml like:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;servlet&gt;\r\n....\r\n                &lt;init-param&gt;\r\n\t\t\t&lt;param-name&gt;Callbacks&lt;\/param-name&gt;\r\n\t\t\t&lt;param-value&gt;CustomAuthentication&lt;\/param-value&gt;\r\n\t\t&lt;\/init-param&gt;\r\n...\r\n&lt;\/servlet&gt;\r\n<\/pre>\n<p>Next step you need to add role in your schema xml for mondrian, where you define cubes:<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;Schema&gt;\r\n...\r\n&lt;Cube&gt;\r\n...\r\n&lt;\/Cube&gt;\r\n\r\n&lt;Role name=&quot;xmla&quot;&gt;\r\n    &lt;SchemaGrant access=&quot;all&quot;&gt;\r\n    &lt;\/SchemaGrant&gt;\r\n&lt;\/Role&gt;\r\n&lt;\/Schema&gt;\r\n<\/pre>\n<p>more details for this step you can find here: <a href=\"http:\/\/mondrian.pentaho.com\/documentation\/schema.php#Defining_roles\">Defining Roles <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you would like to turn on basic authentication for mondrian cubes from excel you need to implement steps below.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0},"categories":[25],"tags":[57,48,52,56],"_links":{"self":[{"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=\/wp\/v2\/posts\/474"}],"collection":[{"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=474"}],"version-history":[{"count":6,"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=\/wp\/v2\/posts\/474\/revisions"}],"predecessor-version":[{"id":521,"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=\/wp\/v2\/posts\/474\/revisions\/521"}],"wp:attachment":[{"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dekarlab.de\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}