Skip to content
Snippets Groups Projects
Commit b31e48a2 authored by Felix Sidokhine's avatar Felix Sidokhine
Browse files

Merge branch 'master' into localuser

# Conflicts:
#	jams-server/src/main/java/module-info.java
#	pom.xml
parents 7a0c1433 eab9b0cb
No related branches found
No related tags found
No related merge requests found
Showing
with 439 additions and 11 deletions
......@@ -73,6 +73,11 @@ public class ADConnector implements AuthenticationSource {
return userProfileService.getUserProfile(queryString,field);
}
@Override
public void setUserProfile(UserProfile userProfile) {
//does nothing as we cannot edit user profiles.
}
@Override
public boolean authenticate(String username, String password) {
try {
......
openapi: 3.0.0
info:
title: Administration API
version: '1.0'
description: "This API is used to provide admin functions which are broader than the user's API and allow modifying users which are not oneself."
servers:
- url: 'http://localhost:8080'
paths:
/api/admin/device:
get:
summary: User device
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/Device'
operationId: get-api-admin-device
requestBody:
description: ''
parameters:
- schema:
type: string
in: query
name: username
- schema:
type: string
in: query
name: deviceId
description: Returns the device information.
put:
summary: ''
operationId: put-api-admin-device
responses:
'200':
description: OK
delete:
summary: ''
operationId: delete-api-admin-device
responses:
'200':
description: OK
parameters:
- schema:
type: string
in: query
name: username
- schema:
type: string
in: query
name: deviceId
description: Revokes a device.
/api/admin/devices:
get:
summary: User devices
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/Device'
operationId: get-api-admin-devices
parameters:
- schema:
type: string
in: query
name: username
/api/admin/directory/entry:
get:
summary: Your GET endpoint
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: '#/components/schemas/UserProfile'
operationId: get-api-admin-directory-entry
description: ''
put:
summary: ''
operationId: put-api-admin-directory-entry
responses:
'200':
description: OK
post:
summary: ''
operationId: post-api-admin-directory-entry
responses:
'200':
description: OK
/api/admin/user:
get:
summary: Your GET endpoint
tags: []
responses: {}
operationId: get-api-admin-user
post:
summary: ''
operationId: post-api-admin-user
responses:
'200':
description: OK
delete:
summary: ''
operationId: delete-api-admin-user
responses:
'200':
description: OK
put:
summary: ''
operationId: put-api-admin-user
responses:
'200':
description: OK
/api/admin/users:
get:
summary: Your GET endpoint
tags: []
responses: {}
operationId: get-api-admin-users
components:
schemas:
Device:
title: Device
type: object
properties:
deviceId:
type: string
displayName:
type: string
certificate:
type: string
description: "The user's Jami device."
UserProfile:
title: UserProfile
type: object
properties:
username:
type: string
firstName:
type: string
lastName:
type: string
phoneNumber:
type: string
phoneNumberExtension:
type: string
mobileNumber:
type: string
faxNumber:
type: string
profilePicture:
type: string
email:
type: string
organization:
type: string
description: "The user's extended information which is not critical to Jami operations, usually provided by LDAP, Active Directory or other backend."
openapi: 3.0.0
info:
title: Install API
version: '1.0'
description: This API is used by the Web-UI installer in order to get JAMS up and running.
servers:
- url: 'http://localhost:3000'
paths:
/api/install/auth:
post:
summary: ''
operationId: post-api-install-auth
responses:
'200':
description: OK
/api/install/ca:
post:
summary: ''
operationId: post-api-install-ca
responses:
'200':
description: OK
/api/install/settings:
post:
summary: ''
operationId: post-api-install-settings
responses:
'200':
description: OK
/api/install/start:
post:
summary: ''
operationId: post-api-install-start
responses:
'200':
description: OK
components:
schemas: {}
openapi: 3.0.0
info:
title: Nameserver API
version: '1.0'
description: This is the Jami-compatible implementation of the nameserver.
servers:
- url: 'http://localhost:8080'
paths:
'/api/nameserver/addr/{addr}':
parameters:
- schema:
type: string
name: addr
in: path
required: true
get:
summary: Address lookup
tags: []
responses: {}
operationId: get-api-nameserver-addr-addr
'/api/nameserver/name/{name}':
parameters:
- schema:
type: string
name: name
in: path
required: true
get:
summary: Name lookup
tags: []
responses:
'200':
description: OK
operationId: get-api-nameserver-name-name
components:
schemas: {}
openapi: 3.0.0
info:
title: Security API
version: '1.0'
servers:
- url: 'http://localhost:8080'
paths:
/api/auth/login:
post:
summary: Login and Receive Auth Token
operationId: post-api-auth-login
responses:
'200':
description: OK
components:
schemas: {}
openapi: 3.0.0
info:
title: User API
version: '1.0'
servers:
- url: 'http://localhost:8080'
paths:
/api/auth/contacts:
get:
summary: Contacts endpoint
tags: []
responses: {}
operationId: get-api-auth-contacts
'/api/auth/device/{deviceId}':
parameters:
- schema:
type: string
name: deviceId
in: path
required: true
get:
summary: Device operations
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: './Admin-API.v1.yaml#/components/schemas/Device'
operationId: get-api-auth-device-deviceId
put:
summary: ''
operationId: put-api-auth-device-deviceId
responses:
'200':
description: OK
post:
summary: ''
operationId: post-api-auth-device-deviceId
responses:
'200':
description: OK
content:
application/json:
schema:
allOf: []
/api/auth/devices:
get:
summary: Get the list of devices
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: './Admin-API.v1.yaml#/components/schemas/Device'
operationId: get-api-auth-devices
/api/auth/directories:
get:
summary: Get the directories connect to JAMS
tags: []
responses: {}
operationId: get-api-auth-directories
/api/auth/directory/entry:
get:
summary: Get the profile of a user
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
$ref: './Admin-API.v1.yaml#/components/schemas/UserProfile'
operationId: get-api-auth-directory-entry
/api/auth/directory/search:
get:
summary: Search the directory
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: './Admin-API.v1.yaml#/components/schemas/UserProfile'
'':
content:
application/json:
schema:
type: array
items:
$ref: './Admin-API.v1.yaml#/components/schemas/UserProfile'
operationId: get-api-auth-directory-search
/api/auth/user:
get:
summary: User endpoint
tags: []
responses: {}
operationId: get-api-auth-user
components:
schemas: {}
securitySchemes:
API Key - 1:
name: API Key
type: apiKey
in: query
......@@ -37,7 +37,7 @@ public class RegisterUserFlow {
return false;
}
datastore.getUserDao().storeObject(user);
log.info("Create the user " + user.getUsername() + " because he did not exist before!");
log.info("Created the user " + user.getUsername() + " because he did not exist before!");
return true;
}
}
......@@ -23,7 +23,6 @@ import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPublicKey;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
......@@ -126,6 +125,7 @@ public class UserAuthenticationModule implements AuthenticationModule {
user.setAccessLevel(AccessLevel.USER);
user.setRealm(key.getRealm());
user.setUserType(key.getType());
//This is legal with a null ONLY because in this case there is no relation with a external server.
RegisterUserFlow.createUser(user,null);
return tokenController.getToken(user);
}
......
......@@ -6,6 +6,7 @@ import lombok.extern.slf4j.Slf4j;
import net.jami.datastore.main.DataStore;
import net.jami.jams.common.dao.SelectStatementBuilder;
import net.jami.jams.common.dao.StatementList;
import net.jami.jams.common.dao.UpdateStatementBuilder;
import net.jami.jams.common.dao.connectivity.SQLConnection;
import java.sql.PreparedStatement;
......@@ -22,11 +23,14 @@ public abstract class AbstractDao<T> {
@Getter @Setter
private Class<T> tClass;
public abstract boolean storeObject(T object);
public abstract boolean deleteObject(LinkedHashMap<String,String> constraints);
public List<T> getObjects(StatementList constraints){
List<T> result = new ArrayList<>();
SQLConnection connection = DataStore.connectionPool.getConnection();
try{
PreparedStatement ps = SelectStatementBuilder.buildStatement(tableName,constraints.getStatements(),connection);
PreparedStatement ps = SelectStatementBuilder.buildStatement(tableName,constraints,connection);
ResultSet rs = ps.executeQuery();
while(rs.next()){
result.add(tClass.getConstructor(ResultSet.class).newInstance(rs));
......@@ -42,7 +46,18 @@ public abstract class AbstractDao<T> {
}
}
public abstract boolean storeObject(T object);
public abstract boolean deleteObject(LinkedHashMap<String,String> constraints);
public boolean updateObject(StatementList update, StatementList constraints){
SQLConnection connection = DataStore.connectionPool.getConnection();
try{
PreparedStatement ps = UpdateStatementBuilder.buildStatement(tableName,update,constraints,connection);
return ps.execute();
}
catch (Exception e){
log.error("An error has occurred while trying to fetch a device: " + e.toString());
return false;
}
finally {
DataStore.connectionPool.returnConnection(connection);
}
}
}
package net.jami.datastore.dao;
import net.jami.jams.common.dao.StatementList;
import net.jami.jams.common.objects.contacts.Contact;
import java.util.LinkedHashMap;
......@@ -15,4 +16,9 @@ public class ContactDao extends AbstractDao<Contact> {
public boolean deleteObject(LinkedHashMap<String, String> constraints) {
return false;
}
@Override
public boolean updateObject(StatementList update, StatementList constraints) {
return false;
}
}
......@@ -2,6 +2,7 @@ package net.jami.datastore.dao;
import lombok.extern.slf4j.Slf4j;
import net.jami.datastore.main.DataStore;
import net.jami.jams.common.dao.StatementList;
import net.jami.jams.common.dao.connectivity.SQLConnection;
import net.jami.jams.common.objects.devices.Device;
......@@ -59,4 +60,9 @@ public class DeviceDao extends AbstractDao<Device> {
public boolean deleteObject(LinkedHashMap<String, String> constraints) {
return false;
}
@Override
public boolean updateObject(StatementList update, StatementList constraints) {
return false;
}
}
......@@ -2,6 +2,7 @@ package net.jami.datastore.dao;
import lombok.extern.slf4j.Slf4j;
import net.jami.datastore.main.DataStore;
import net.jami.jams.common.dao.StatementList;
import net.jami.jams.common.dao.connectivity.SQLConnection;
import net.jami.jams.common.objects.system.SystemAccount;
......@@ -57,4 +58,9 @@ public class SystemDao extends AbstractDao<SystemAccount> {
public boolean deleteObject(LinkedHashMap<String, String> constraints) {
return false;
}
@Override
public boolean updateObject(StatementList update, StatementList constraints) {
return false;
}
}
......@@ -51,6 +51,11 @@ public class DataStore implements AuthenticationSource {
return null;
}
@Override
public void setUserProfile(UserProfile userProfile) {
//TODO: Implement this.
}
@Override
public boolean authenticate(String username, String password) {
StatementList statementList = new StatementList();
......
......@@ -119,3 +119,12 @@ print(token)
response = requests.get("http://localhost:8080/api/nameserver/name/aberaud",headers=header)
print(response.status_code)
print(response.text)
response = requests.get("http://localhost:8080//api/auth/directories",headers=header)
print(response.status_code)
print(response.text)
response = requests.get("http://localhost:8080/api/auth/user",headers=header)
print(response.status_code)
print(response.text)
\ No newline at end of file
......@@ -48,7 +48,7 @@ public class PublicNameServer implements NameServer {
responseData.append((char) con.getInputStream().read());
currentSize++;
}
log.info("Reponse received from public nameserver {} ", responseData.toString());
log.info("Response received from public nameserver {} ", responseData.toString());
return JsonIterator.deserialize(responseData.toString(),NameLookupResponse.class);
}
return null;
......
......@@ -3,8 +3,6 @@ package net.jami.jams.ca.workers;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.cert.ocsp.OCSPReq;
import org.bouncycastle.cert.ocsp.OCSPResp;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
......
......@@ -52,6 +52,7 @@ module jams.common {
exports net.jami.jams.common.authentication.local;
exports net.jami.jams.common.objects.responses;
exports net.jami.jams.common.cryptoengineapi.ocsp;
exports net.jami.jams.common.updater;
requires jdk.crypto.cryptoki;
requires java.base;
requires java.sql;
......
......@@ -7,6 +7,7 @@ public interface AuthenticationSource {
boolean createUser(User user);
UserProfile[] getUserProfile(String queryString, String field);
void setUserProfile(UserProfile userProfile);
boolean authenticate(String username, String password);
AuthenticationSourceInfo getInfo();
boolean test();
......
......@@ -3,5 +3,13 @@ package net.jami.jams.common.authentication;
public enum AuthenticationSourceType {
AD,
LDAP,
LOCAL
LOCAL;
public static AuthenticationSourceType fromString(String str){
if(str.equals("AD")) return AD;
if(str.equals("LDAP")) return LDAP;
if(str.equals("LOCAL")) return LOCAL;
return null;
}
}
......@@ -8,7 +8,6 @@ import net.jami.jams.common.objects.user.User;
import java.security.SecureRandom;
import java.security.cert.X509Certificate;
import java.security.interfaces.RSAPublicKey;
import java.util.HashMap;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment