diff --git a/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/section_debitor_statistic.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/section_debitor_statistic.xhtml index 87311b7..18e8e92 100644 --- a/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/section_debitor_statistic.xhtml +++ b/office-alexander-logistics-app/src/main/webapp/pages/workitems/forms/alexander/section_debitor_statistic.xhtml @@ -101,7 +101,7 @@ // update the diagram var ctx = document.getElementById("canvas").getContext("2d"); window.myBar = new Chart(ctx, { - type: 'line', + type: 'bar', data: barChartData, options: { responsive: true, diff --git a/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestIMAPOutlookOAuth.java b/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestIMAPOutlookOAuth.java index 09d5508..0e2145a 100644 --- a/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestIMAPOutlookOAuth.java +++ b/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestIMAPOutlookOAuth.java @@ -45,6 +45,13 @@ public class TestIMAPOutlookOAuth { private static final String CLIENT_ID = "39e9eec5-6939-47dc-9729-3438a9898e63"; private static final String CLIENT_SECRET = "A6x8Q~EWVUyt~gfyTHtIJf4ig.F9tajUpEEXMaCL"; + /* + * Neue Daten + * + * Wert: zDL8Q~iEy8AX~dEmIOHrVv3aBTCZLrHIFmShibZ_ + * Geheime ID: bcaa558a-3300-4498-94e1-2267f418afd5 + */ + @Test public void TestMailboxImixs() { Store store = null; @@ -85,6 +92,8 @@ public class TestIMAPOutlookOAuth { token = getAuthToken(); Assert.assertNotNull(token); store = connect(token, "Imixs_bhv@alexander-logistics.com"); + // store = connect(token, "mgeisler@alexander-logistics.com"); + Assert.assertNotNull(store); if (!store.isConnected()) { diff --git a/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestIMAPOutlookOAuthOld.java b/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestIMAPOutlookOAuthOld.java deleted file mode 100644 index 45ecd66..0000000 --- a/office-alexander-logistics-app/src/test/java/com/alexanderlogistics/TestIMAPOutlookOAuthOld.java +++ /dev/null @@ -1,382 +0,0 @@ -package com.alexanderlogistics; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.Map; -import java.util.Properties; - -import javax.mail.Folder; -import javax.mail.Message; -import javax.mail.MessagingException; -import javax.mail.Session; -import javax.mail.Store; - -import org.apache.http.client.ClientProtocolException; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.ContentType; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.message.BasicHeader; -import org.junit.Test; - -import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.sun.mail.imap.IMAPFolder; - -import junit.framework.Assert; - - -/** - * This test shows how to access outlook via oauth2 - * - * See: https://www.java-forum.org/thema/javamail-mit-oauth2-an-o365.199133/ - * - * @author rsoika - * - */ -public class TestIMAPOutlookOAuth { - - @Test - public void TestMailboxImixs() { - Store store = null; - String token = null; - try { - // try to connect... - token = getAuthToken(); - Assert.assertNotNull(token); - store = connect(token, "imixs@alexander-logistics.com"); - Assert.assertNotNull(store); - - if (!store.isConnected()) { - // not connected! - } else { - // read inbox.... - IMAPFolder inbox = (IMAPFolder) store.getFolder("INBOX"); - inbox.open(Folder.READ_WRITE); - // fetches all messages from the INBOX... - Message[] messages = inbox.getMessages(); - System.out.println("..." + messages.length + " new messages found"); - } - } catch (IOException e) { - e.printStackTrace(); - Assert.fail(); - } catch (MessagingException e) { - e.printStackTrace(); - Assert.fail(); - } - - } - - @Test - public void TestMailboxImixsBHV() { - Store store = null; - String token = null; - try { - // try to connect... - token = getAuthToken(); - Assert.assertNotNull(token); - store = connect(token, "Imixs_bhv@alexander-logistics.com"); - Assert.assertNotNull(store); - - if (!store.isConnected()) { - // not connected! - } else { - // read inbox.... - IMAPFolder inbox = (IMAPFolder) store.getFolder("INBOX"); - inbox.open(Folder.READ_WRITE); - // fetches all messages from the INBOX... - Message[] messages = inbox.getMessages(); - System.out.println("..." + messages.length + " new messages found"); - } - } catch (IOException e) { - e.printStackTrace(); - Assert.fail(); - } catch (MessagingException e) { - e.printStackTrace(); - Assert.fail(); - } - - } - - @Test - public void imapAccess2() { - - String userEmailId = "imixs@alexander-logistics.com"; - try { - String oauth2AccessToken = getAuthToken(); - - String host = "outlook.office365.com"; - String port = "993"; - Store store = null; - - String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; - Properties props = new Properties(); - - props.put("mail.imaps.ssl.enable", "true"); - props.put("mail.imaps.sasl.enable", "true"); - props.put("mail.imaps.port", port); - - props.put("mail.imaps.auth.mechanisms", "XOAUTH2"); - props.put("mail.imaps.sasl.mechanisms", "XOAUTH2"); - - props.put("mail.imaps.auth.login.disable", "true"); - props.put("mail.imaps.auth.plain.disable", "true"); - - props.setProperty("mail.imaps.socketFactory.class", SSL_FACTORY); - props.setProperty("mail.imaps.socketFactory.fallback", "false"); - props.setProperty("mail.imaps.socketFactory.port", port); - props.setProperty("mail.imaps.starttls.enable", "true"); - props.put("mail.imaps.auth.plain.disable", "true"); - props.put("mail.debug", "true"); - props.put("mail.debug.auth", "true"); - - Session session = Session.getInstance(props); - session.setDebug(true); - - store = session.getStore("imaps"); - - System.out.println("OAUTH2 IMAP trying to connect with system properties to Host:" + host + ", Port: " - + port + ", userEmailId: " + userEmailId + ", AccessToken: " + oauth2AccessToken); - - store.connect(host, userEmailId, oauth2AccessToken); - System.out.println("IMAP connected with system properties to Host:" + host + ", Port: " + port - + ", userEmailId: " + userEmailId + ", AccessToken: " + oauth2AccessToken); - if (store.isConnected()) { - System.out.println("Connection Established using imap protocol successfully !"); - - IMAPFolder inbox = (IMAPFolder) store.getFolder("INBOX"); - inbox.open(Folder.READ_WRITE); - - // fetches all messages from the INBOX... - Message[] messages = inbox.getMessages(); - System.out.println("..." + messages.length + " new messages found"); - } - } catch (Exception e) { - System.out.println("Store.Connect failed with the errror: " + e.getMessage()); - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - String exceptionAsString = sw.toString(); - System.out.println(exceptionAsString); - Assert.fail(); - } - - } - - /** - * Tests the Imap access - * - * https://stackoverflow.com/questions/73463357/cannot-authenticate-to-imap-on-office365-using-javamail - * - * mail.store.protocol="imap" mail.imap.host="outlook.office365.com" - * mail.imap.port="993" mail.imap.ssl.enable="true" - * mail.imap.starttls.enable="true" mail.imap.auth="true" - * mail.imap.auth.mechanisms="XOAUTH2" mail.imap.user="" - */ - @Test - public void imapAccess3() { - Properties props = new Properties(); - - String mail_bhv = "Imixs_bhv@alexander-logistics.com"; - String mail_imixs = "imixs@alexander-logistics.com"; - - props.put("mail.store.protocol", "imap"); - props.put("mail.imap.host", "outlook.office365.com"); - props.put("mail.imap.port", "993"); - props.put("mail.imap.ssl.enable", "true"); - - props.put("mail.imap.starttls.enable", "true"); - props.put("mail.imap.auth", "true"); - props.put("mail.imap.auth.mechanisms", "XOAUTH2"); - props.put("mail.imap.user", mail_bhv); - - // props.put("mail.imaps.auth.plain.disable","true"); - - props.put("mail.debug", "true"); - props.put("mail.debug.auth", "true"); - try { - - String token = getAuthToken(); - - Session session = Session.getInstance(props); - session.setDebug(true); - System.out.println("info: properties: " + session.getProperties().toString()); - Store store = session.getStore("imap"); - store.connect("outlook.office365.com", mail_imixs, token); - IMAPFolder inbox = (IMAPFolder) store.getFolder("INBOX"); - inbox.open(Folder.READ_WRITE); - Message[] messages = inbox.getMessages(); - System.out.println("..." + messages.length + " new messages found"); - messages[0].getSubject(); - - } catch (Exception e) { - - e.printStackTrace(); - Assert.fail(); - } - } - - /** - * Test the getToken method - */ - @Test - public void testGetToken() { - try { - String token = getAuthToken(); - System.out.println("....access token = " + token); - } catch (Exception e) { - e.printStackTrace(); - Assert.fail(); - } - } - - /** - * This method returns a connection to an javax.mail.store - */ - public Store connect(String oauth2AccessToken, String userEmailId) { - - try { - - String host = "outlook.office365.com"; - String port = "993"; - Store store = null; - - String SSL_FACTORY = "javax.net.ssl.SSLSocketFactory"; - Properties props = new Properties(); - - props.put("mail.imaps.ssl.enable", "true"); - props.put("mail.imaps.sasl.enable", "true"); - props.put("mail.imaps.port", port); - props.put("mail.imaps.auth.mechanisms", "XOAUTH2"); - props.put("mail.imaps.sasl.mechanisms", "XOAUTH2"); - - props.put("mail.imaps.auth.login.disable", "true"); - props.put("mail.imaps.auth.plain.disable", "true"); - - props.setProperty("mail.imaps.socketFactory.class", SSL_FACTORY); - props.setProperty("mail.imaps.socketFactory.fallback", "false"); - props.setProperty("mail.imaps.socketFactory.port", port); - props.setProperty("mail.imaps.starttls.enable", "true"); - - // optional set imap user? - // props.put("mail.imap.user", userEmailId); - - props.put("mail.imaps.auth.plain.disable", "true"); - props.put("mail.debug", "true"); - props.put("mail.debug.auth", "true"); - - Session session = Session.getInstance(props); - session.setDebug(true); - - store = session.getStore("imaps"); - - System.out.println("OAUTH2 IMAP trying to connect with system properties to Host:" + host + ", Port: " - + port + ", userEmailId: " + userEmailId + ", AccessToken: " + oauth2AccessToken); - - store.connect(host, userEmailId, oauth2AccessToken); - if (store.isConnected()) { - System.out.println("Connection Established using imap protocol successfully !"); - return store; - - } - System.out.println("Store.Connect failed!"); - } catch (Exception e) { - System.out.println("Store.Connect failed with the errror: " + e.getMessage()); - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw)); - String exceptionAsString = sw.toString(); - System.out.println(exceptionAsString); - Assert.fail(); - } - - return null; - - } - - /** - * Helper method to receive a Microsoft access Token - * - * https://jwt.ms/ - * - * "OAuth2": { - * - * "Authority": - * https://login.microsoftonline.com/51e2f038-0a96-41be-801d-bb4118aa018e/v2.0, - * - * "ClientId": "39e9eec5-6939-47dc-9729-3438a9898e63", - * - * "ClientSecret": "A6x8Q~EWVUyt~gfyTHtIJf4ig.F9tajUpEEXMaCL" - * - * } - * - * - * @return - * @throws IOException - * @throws ClientProtocolException - */ - public String getAuthToken() throws ClientProtocolException, IOException { - CloseableHttpClient client = HttpClients.createDefault(); - String tanantId = "51e2f038-0a96-41be-801d-bb4118aa018e"; - String clientId = "39e9eec5-6939-47dc-9729-3438a9898e63"; - String client_secret = "A6x8Q~EWVUyt~gfyTHtIJf4ig.F9tajUpEEXMaCL"; - - HttpPost loginPost = new HttpPost("https://login.microsoftonline.com/" + tanantId + "/oauth2/v2.0/token"); - String scopes = "https://outlook.office365.com/.default"; - // scopes="https://outlook.office365.com/IMAP.AccessAsUser.All"; - // scopes="https://graph.microsoft.com/.default"; - // scopes="openid profile offline_access https://outlook.office365.com/SMTP.Send - // https://outlook.office365.com/POP.AccessAsUser.All - // https://outlook.office365.com/IMAP.AccessAsUser.All"; - - String encodedBody = "client_id=" + clientId + "&scope=" + scopes + "&client_secret=" + client_secret - + "&grant_type=client_credentials"; - - loginPost.setEntity(new StringEntity(encodedBody, ContentType.APPLICATION_FORM_URLENCODED)); - - loginPost.addHeader(new BasicHeader("cache-control", "no-cache")); - CloseableHttpResponse loginResponse = client.execute(loginPost); - - InputStream inputStream = loginResponse.getEntity().getContent(); - byte[] response = readAllBytes(inputStream); - ObjectMapper objectMapper = new ObjectMapper(); - JavaType type = objectMapper.constructType( - objectMapper.getTypeFactory().constructParametricType(Map.class, String.class, String.class)); - Map parsed = new ObjectMapper().readValue(response, type); - String result = parsed.get("access_token"); - - System.out.println("....access token = " + result); - return result; - } - - public static byte[] readAllBytes(InputStream inputStream) throws IOException { - final int bufLen = 4 * 0x400; // 4KB - byte[] buf = new byte[bufLen]; - int readLen; - IOException exception = null; - - try { - try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) { - while ((readLen = inputStream.read(buf, 0, bufLen)) != -1) - outputStream.write(buf, 0, readLen); - - return outputStream.toByteArray(); - } - } catch (IOException e) { - exception = e; - throw e; - } finally { - if (exception == null) - inputStream.close(); - else - try { - inputStream.close(); - } catch (IOException e) { - exception.addSuppressed(e); - } - } - } -} \ No newline at end of file diff --git a/pom.xml b/pom.xml index bc06c1c..47435f8 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ 4.6.2-SNAPSHOT 2.3.2 - 2.3.1-SNAPSHOT + 2.3.1 1.0.22 1.1.6-SNAPSHOT 2.2 diff --git a/workflow/sepa-export-3.0.2.bpmn b/workflow/deprecated/sepa-export-3.0.2.bpmn similarity index 100% rename from workflow/sepa-export-3.0.2.bpmn rename to workflow/deprecated/sepa-export-3.0.2.bpmn