Skip to content

Commit 9ee7618

Browse files
committed
Initial commit
0 parents  commit 9ee7618

22 files changed

+1231
-0
lines changed

.classpath

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
4+
<attributes>
5+
<attribute name="maven.pomderived" value="true"/>
6+
</attributes>
7+
</classpathentry>
8+
<classpathentry kind="src" output="target/classes" path="src">
9+
<attributes>
10+
<attribute name="optional" value="true"/>
11+
<attribute name="maven.pomderived" value="true"/>
12+
</attributes>
13+
</classpathentry>
14+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
15+
<attributes>
16+
<attribute name="maven.pomderived" value="true"/>
17+
</attributes>
18+
</classpathentry>
19+
<classpathentry kind="output" path="target/classes"/>
20+
</classpath>

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Auto detect text files and perform LF normalization
2+
* text=auto

.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>SchoolAPI</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
21+
<nature>org.eclipse.jdt.core.javanature</nature>
22+
</natures>
23+
</projectDescription>

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# School API
2+
## an open source API for [IServ](https://iserv.de) and [Units](https://www.untis.at) written in Java
3+
4+
### This project can either be used as Java libary for accessing units and iserv data, or can be executed as HTTP web API and access data through json.
5+
6+
#### Features:
7+
- Login with your **IServ account**
8+
- Request a given amount of outstanding **exercises** from iserv
9+
- Send mails via **SMTP**
10+
- Read mails via **IMAP**
11+
- Get all **examens** from calender
12+
- **Session** system
13+
- Runnable as **web API** to use it in **JSON** format in **any language**
14+
- Request **timetable as image** from "Units Vertretungsplan"
15+
16+
#### How to setup:
17+
##### As java dependency / libary:
18+
1. Download the latest release
19+
2. Unzip it and add the .jar file as dependency in your Java or Kotlin project
20+
21+
##### As stand-alone http web API:
22+
1. Download the latest release
23+
2. Move the .jar file inside the .zip to a new folder
24+
3. Create a `start.sh` or `start.bat` file in the same folder, depending on your OS
25+
4. Write `java -jar <jarname>.jar <port>` into the file (replace both variables)
26+
5. (I'ld recommend to use `screen` for linux to organize the console)
27+
28+
#### How to use:
29+
##### Coming soon...
30+
31+
#### How to contribute:
32+
Feel free to create a pull request, as long the code style is respected.
33+
34+
#### Contributers:
35+
- [DevOFVictory](https://github.com/DevOFVictory)

pom.xml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<groupId>SchoolAPI</groupId>
6+
<artifactId>SchoolAPI</artifactId>
7+
<version>0.0.1-SNAPSHOT</version>
8+
<build>
9+
<sourceDirectory>src</sourceDirectory>
10+
<plugins>
11+
<plugin>
12+
<artifactId>maven-compiler-plugin</artifactId>
13+
<version>3.8.0</version>
14+
<configuration>
15+
<source>1.8</source>
16+
<target>1.8</target>
17+
</configuration>
18+
</plugin>
19+
</plugins>
20+
</build>
21+
<dependencies>
22+
<!-- https://mvnrepository.com/artifact/org.jsoup/jsoup -->
23+
<dependency>
24+
<groupId>org.jsoup</groupId>
25+
<artifactId>jsoup</artifactId>
26+
<version>1.13.1</version>
27+
</dependency>
28+
<dependency>
29+
<groupId>javax.mail</groupId>
30+
<artifactId>javax.mail-api</artifactId>
31+
<version>1.6.2</version>
32+
</dependency>
33+
<!-- https://mvnrepository.com/artifact/javax/javaee-api -->
34+
<dependency>
35+
<groupId>javax</groupId>
36+
<artifactId>javaee-api</artifactId>
37+
<version>8.0.1</version>
38+
<scope>provided</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.seleniumhq.selenium</groupId>
42+
<artifactId>selenium-java</artifactId>
43+
<version>3.141.59</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>commons-io</groupId>
47+
<artifactId>commons-io</artifactId>
48+
<version>2.6</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.apache.commons</groupId>
52+
<artifactId>commons-lang3</artifactId>
53+
<version>3.12.0</version>
54+
</dependency>
55+
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
56+
<!-- https://mvnrepository.com/artifact/com.sun.net.httpserver/http -->
57+
<dependency>
58+
<groupId>com.sun.net.httpserver</groupId>
59+
<artifactId>http</artifactId>
60+
<version>20070405</version>
61+
</dependency>
62+
<dependency>
63+
<groupId>com.googlecode.json-simple</groupId>
64+
<artifactId>json-simple</artifactId>
65+
<version>1.1.1</version>
66+
</dependency>
67+
<dependency>
68+
<groupId>com.google.code.gson</groupId>
69+
<artifactId>gson</artifactId>
70+
<version>2.8.7</version>
71+
</dependency>
72+
</dependencies>
73+
74+
</project>
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package de.devofvictory.schoolapi.objects;
2+
3+
import de.devofvictory.schoolapi.objects.exercises.ExerciseManager;
4+
import de.devofvictory.schoolapi.objects.mail.MailManager;
5+
import de.devofvictory.schoolapi.utils.IservUtil;
6+
7+
public class IservSession {
8+
9+
private long connectedSince;
10+
private String[] sessionCookies;
11+
private String iservAddress;
12+
private String username;
13+
private String password;
14+
private boolean isConnected;
15+
16+
private ExerciseManager exerciseManager;
17+
private MailManager mailManager;
18+
19+
public IservSession(String iservAddress, String username, String password) {
20+
this.iservAddress = iservAddress;
21+
this.username = username;
22+
this.password = password;
23+
this.isConnected = false;
24+
}
25+
26+
public long getConnectedSince() {
27+
return connectedSince;
28+
}
29+
30+
public String getUsername() {
31+
return username;
32+
}
33+
34+
public String getPassword() {
35+
return password;
36+
}
37+
38+
public boolean isConnected() {
39+
return isConnected;
40+
}
41+
42+
public String[] getSessionCookies() {
43+
return sessionCookies;
44+
}
45+
46+
public String getIservAddress() {
47+
return iservAddress;
48+
}
49+
50+
public ExerciseManager getExerciseManager() {
51+
if (isConnected) {
52+
return exerciseManager;
53+
}else {
54+
System.out.println("Not connected");
55+
return null;
56+
}
57+
}
58+
59+
public MailManager getMailManager() {
60+
if (isConnected) {
61+
return mailManager;
62+
}else {
63+
System.out.println("Not connected");
64+
return null;
65+
}
66+
}
67+
68+
public String connect() {
69+
70+
try {
71+
String[] cookies = IservUtil.getCookiesFromCredentials(iservAddress, username, password);
72+
73+
if (cookies.length == 3) {
74+
75+
this.sessionCookies = cookies;
76+
this.connectedSince = System.currentTimeMillis();
77+
this.isConnected = true;
78+
79+
this.exerciseManager = new ExerciseManager(iservAddress, cookies);
80+
this.mailManager = new MailManager(iservAddress, username, password);
81+
this.mailManager.login();
82+
83+
return "SUCCESS";
84+
} else if (cookies.length == 1) {
85+
return cookies[0];
86+
}else {
87+
return "Unknown error occured";
88+
}
89+
} catch (Exception ex) {
90+
return "Couldn't connect to mail servers";
91+
}
92+
93+
94+
}
95+
96+
97+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package de.devofvictory.schoolapi.objects.exercises;
2+
3+
import java.text.ParseException;
4+
import java.text.SimpleDateFormat;
5+
import java.util.Date;
6+
7+
public class Exercise {
8+
9+
private String name;
10+
private String link;
11+
private String deadlineTime;
12+
private String teacher;
13+
private String startTime;
14+
private String fullText;
15+
16+
17+
public String getName() {
18+
return name;
19+
}
20+
public void setName(String name) {
21+
this.name = name;
22+
}
23+
public String getLink() {
24+
return link;
25+
}
26+
public void setLink(String link) {
27+
this.link = link;
28+
}
29+
public String getFullText() {
30+
return fullText;
31+
}
32+
33+
public void setFullText(String fullText) {
34+
this.fullText = fullText;
35+
}
36+
public String getDeadlineTime() {
37+
return deadlineTime;
38+
}
39+
public void setDeadlineTime(String deadlineTime) {
40+
this.deadlineTime = deadlineTime;
41+
}
42+
public String getTeacher() {
43+
return teacher;
44+
}
45+
public void setTeacher(String teacher) {
46+
this.teacher = teacher;
47+
}
48+
public String getStartTime() {
49+
return startTime;
50+
}
51+
public void setStartTime(String startTime) {
52+
this.startTime = startTime;
53+
}
54+
55+
public Date getDeadlineAsDate() {
56+
if (deadlineTime != null) {
57+
58+
SimpleDateFormat format = new SimpleDateFormat("dd.MM.yyyy HH:mm");
59+
try {
60+
Date date = format.parse(getDeadlineTime());
61+
return date;
62+
} catch (ParseException e) {
63+
e.printStackTrace();
64+
return null;
65+
}
66+
67+
}else {
68+
return null;
69+
}
70+
}
71+
72+
73+
74+
}

0 commit comments

Comments
 (0)