Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@

import org.eclipse.daanse.xmla.api.discover.DiscoverService;
import org.eclipse.daanse.xmla.api.execute.ExecuteService;
import org.eclipse.daanse.xmla.api.session.SessionService;

public interface XmlaService {

DiscoverService discover();

ExecuteService execute();

SessionService session();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* SmartCity Jena - initial
* Stefan Bischof (bipolis.org) - initial
*/
package org.eclipse.daanse.xmla.api.session;

import java.util.Optional;

import org.eclipse.daanse.xmla.api.UserPrincipal;
import org.eclipse.daanse.xmla.api.xmla.BeginSession;
import org.eclipse.daanse.xmla.api.xmla.EndSession;
import org.eclipse.daanse.xmla.api.xmla.Session;

public interface SessionService {

Optional<Session> beginSession(BeginSession beginSession, UserPrincipal userPrincipal);

boolean checkSession(Session session, UserPrincipal userPrincipal);

void endSession(EndSession endSession, UserPrincipal userPrincipal);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* SmartCity Jena - initial
* Stefan Bischof (bipolis.org) - initial
*/

@org.osgi.annotation.bundle.Export
@org.osgi.annotation.versioning.Version("0.0.1")
package org.eclipse.daanse.xmla.api.session;
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2025 Contributors to the Eclipse Foundation.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* SmartCity Jena - initial
* Stefan Bischof (bipolis.org) - initial
*/
package org.eclipse.daanse.xmla.client.soapmessage;

import java.util.Optional;

import org.eclipse.daanse.xmla.api.UserPrincipal;
import org.eclipse.daanse.xmla.api.session.SessionService;
import org.eclipse.daanse.xmla.api.xmla.BeginSession;
import org.eclipse.daanse.xmla.api.xmla.EndSession;
import org.eclipse.daanse.xmla.api.xmla.Session;

public class SessionServiceImpl implements SessionService {

@Override
public Optional<Session> beginSession(BeginSession beginSession, UserPrincipal userPrincipal) {
return Optional.empty();
}

@Override
public boolean checkSession(Session session, UserPrincipal userPrincipal) {
return true;
}

@Override
public void endSession(EndSession endSession, UserPrincipal userPrincipal) {

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.daanse.xmla.api.XmlaService;
import org.eclipse.daanse.xmla.api.discover.DiscoverService;
import org.eclipse.daanse.xmla.api.execute.ExecuteService;
import org.eclipse.daanse.xmla.api.session.SessionService;

public class XmlaServiceClientImpl implements XmlaService {

Expand All @@ -38,4 +39,9 @@ public ExecuteService execute() {
return es;
}

@Override
public SessionService session() {
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ public class RequestMetaDataUtils {

public static final String USER_AGENT = "User-agent";

public static RequestMetaData getRequestMetaData(
Map<String, Object> headers,
Optional<Session> ses) {
Optional<String> oUserAgent = get(headers.get(USER_AGENT));
return new RequestMetaDataR(oUserAgent, ses.isPresent() ? Optional.of(ses.get().sessionId()) : Optional.empty());
public static RequestMetaData getRequestMetaData(Map<String, Object> headers, Optional<Session> oSession) {
Optional<String> oUserAgent = getUserAgent(headers.get(USER_AGENT));
return new RequestMetaDataR(oUserAgent,
oSession.isPresent() ? Optional.of(oSession.get().sessionId()) : Optional.empty());
}

private static Optional<String> get(Object o) {
private static Optional<String> getUserAgent(Object o) {
if (o instanceof List list) {
if (list.isEmpty()) {
return Optional.of((String) list.get(0));
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
*/
package org.eclipse.daanse.xmla.server.adapter.soapmessage;

import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.Node;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPElement;
import jakarta.xml.soap.SOAPEnvelope;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPHeader;
import jakarta.xml.soap.SOAPHeaderElement;
import jakarta.xml.soap.SOAPMessage;
import jakarta.xml.soap.SOAPPart;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;

import javax.xml.namespace.QName;

import org.eclipse.daanse.xmla.api.RequestMetaData;
import org.eclipse.daanse.xmla.api.UserPrincipal;
import org.eclipse.daanse.xmla.api.XmlaService;
Expand Down Expand Up @@ -89,7 +87,9 @@
import org.eclipse.daanse.xmla.api.execute.clearcache.ClearCacheResponse;
import org.eclipse.daanse.xmla.api.execute.statement.StatementRequest;
import org.eclipse.daanse.xmla.api.execute.statement.StatementResponse;
import org.eclipse.daanse.xmla.api.xmla.BeginSession;
import org.eclipse.daanse.xmla.api.xmla.Command;
import org.eclipse.daanse.xmla.api.xmla.EndSession;
import org.eclipse.daanse.xmla.api.xmla.Session;
import org.eclipse.daanse.xmla.model.record.UserPrincipalR;
import org.eclipse.daanse.xmla.model.record.discover.PropertiesR;
Expand Down Expand Up @@ -158,14 +158,16 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.xml.namespace.QName;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import jakarta.xml.soap.MessageFactory;
import jakarta.xml.soap.Node;
import jakarta.xml.soap.SOAPBody;
import jakarta.xml.soap.SOAPElement;
import jakarta.xml.soap.SOAPEnvelope;
import jakarta.xml.soap.SOAPException;
import jakarta.xml.soap.SOAPHeader;
import jakarta.xml.soap.SOAPHeaderElement;
import jakarta.xml.soap.SOAPMessage;
import jakarta.xml.soap.SOAPPart;

public class XmlaApiAdapter {
private static final Logger LOGGER = LoggerFactory.getLogger(XmlaApiAdapter.class);
Expand Down Expand Up @@ -203,7 +205,7 @@ public XmlaApiAdapter(XmlaService xmlaService) {
private static final String MDSCHEMA_SETS = "MDSCHEMA_SETS";
private static final String MDSCHEMA_KPIS = "MDSCHEMA_KPIS";
private static final String MDSCHEMA_MEASUREGROUPS = "MDSCHEMA_MEASUREGROUPS";
private Set<String> sessions = new HashSet<>();
private static final QName QN_SESSION = new QName("urn:schemas-microsoft-com:xml-analysis", "Session");

public SOAPMessage handleRequest(SOAPMessage messageRequest, Map<String, Object> headers) {
try {
Expand All @@ -219,18 +221,17 @@ public SOAPMessage handleRequest(SOAPMessage messageRequest, Map<String, Object>
envelopeResponse.addNamespaceDeclaration(Constants.EMPTY.PREFIX, Constants.EMPTY.NS_URN);
envelopeResponse.addNamespaceDeclaration(Constants.XSI.PREFIX, Constants.XSI.NS_URN);

SOAPBody bodyResponse = envelopeResponse.getBody();
Object role = headers.get("ROLE");
Object user = headers.get("USER");
UserPrincipal userPrincipal = new UserPrincipalR(getStringOrNull(user), getRiles(role));
Optional<Session> ses = SessionUtil.getSession(messageRequest.getSOAPHeader(), sessions);
if (ses.isPresent()) {
UserPrincipal userPrincipal = new UserPrincipalR(getStringOrNull(user), getRoles(role));
Optional<Session> oSession =session(messageRequest.getSOAPHeader(),userPrincipal);
if (oSession.isPresent()) {
SOAPHeader header = envelopeResponse.getHeader();
QName session = new QName("urn:schemas-microsoft-com:xml-analysis", "Session");
SOAPHeaderElement sessionElement = header.addHeaderElement(session);
sessionElement.addAttribute(new QName("SessionId"), ses.get().sessionId());
SOAPHeaderElement sessionElement = header.addHeaderElement(QN_SESSION);
sessionElement.addAttribute(new QName("SessionId"), oSession.get().sessionId());
}
RequestMetaData metaData = RequestMetaDataUtils.getRequestMetaData(headers, ses);
RequestMetaData metaData = RequestMetaDataUtils.getRequestMetaData(headers, oSession);
SOAPBody bodyResponse = envelopeResponse.getBody();
handleBody(messageRequest.getSOAPBody(), bodyResponse, metaData, userPrincipal);
return messageResponse;
} catch (SOAPException e) {
Expand All @@ -239,7 +240,7 @@ public SOAPMessage handleRequest(SOAPMessage messageRequest, Map<String, Object>
return null;
}

private List<String> getRiles(Object ob) {
private List<String> getRoles(Object ob) {
if (ob != null && ob instanceof String str) {
return Arrays.asList(str.split(","));
}
Expand All @@ -253,6 +254,31 @@ private String getStringOrNull(Object ob) {
return null;
}

private Optional<Session> session(SOAPHeader soapRequestHeader, UserPrincipal userPrincipal) throws SOAPException {
Optional<Session> oSession = Convert.getSession(soapRequestHeader);
if (oSession.isPresent()) {
boolean checked = xmlaService.session().checkSession(oSession.get(), userPrincipal);
if (checked) {
return oSession;
} else {
Optional.empty();
}
}

Optional<BeginSession> beginSession = Convert.getBeginSession(soapRequestHeader);
if (beginSession.isPresent()) {
return xmlaService.session().beginSession(beginSession.get(), userPrincipal);
}

Optional<EndSession> oEndSession = Convert.getEndSession(soapRequestHeader);
if (oEndSession.isPresent()) {
xmlaService.session().endSession(oEndSession.get(), userPrincipal);
return Optional.empty();
}

return Optional.empty();
}

private void handleBody(SOAPBody body, SOAPBody responseBody, RequestMetaData metaData, UserPrincipal userPrincipal)
throws SOAPException {
SOAPElement node = null;
Expand Down Expand Up @@ -280,6 +306,7 @@ private void handleBody(SOAPBody body, SOAPBody responseBody, RequestMetaData me

}


private void discover(SOAPElement discover, SOAPBody responseBody, RequestMetaData metaData,
UserPrincipal userPrincipal) throws SOAPException {

Expand Down
Loading