Skip to content
Snippets Groups Projects
Commit 53e3a929 authored by Daniel's avatar Daniel
Browse files

DOC: Documention source code.

parent be0b606f
Branches
Tags
No related merge requests found
......@@ -859,6 +859,7 @@ class CaosDBComponent extends Component {
@Override
public void handle(final Request request, final Response response) {
long t1 = System.currentTimeMillis();
// The server request ID is just a long random number
request.getAttributes().put("SRID", Utils.getUID());
response.setServerInfo(CaosDBServer.getServerInfo());
super.handle(request, response);
......
......@@ -44,7 +44,7 @@ public class UserSources extends HashMap<String, UserSource> {
public static final String ANONYMOUS_ROLE = "anonymous";
private static final Logger logger = LoggerFactory.getLogger(UserSources.class);
public static final String KEY_DEAULT_REALM = "defaultRealm";
public static final String KEY_DEFAULT_REALM = "defaultRealm";
public static final String KEY_REALMS = "defaultRealm";
public static final String KEY_REALM_CLASS = "class";
......@@ -162,7 +162,7 @@ public class UserSources extends HashMap<String, UserSource> {
}
public static String getDefaultRealm() {
return instance.map.getSectionProperty(Ini.DEFAULT_SECTION_NAME, KEY_DEAULT_REALM);
return instance.map.getSectionProperty(Ini.DEFAULT_SECTION_NAME, KEY_DEFAULT_REALM);
}
public static Set<String> resolve(final PrincipalCollection principals) {
......
......@@ -75,8 +75,8 @@ public abstract class AbstractCaosDBServerResource extends ServerResource {
private final HashMap<String, String> flags = new HashMap<String, String>();
private Long timestamp = null;
private static final XMLParser xmlparser = new XMLParser();
protected String sRID = null;
private String cRID = null;
protected String sRID = null; // Server side request ID
private String cRID = null; // Client side request ID
private String[] requestedItems = null;
private ArrayList<Integer> requestedIDs = new ArrayList<Integer>();
private ArrayList<String> requestedNames = new ArrayList<String>();
......@@ -86,6 +86,11 @@ public abstract class AbstractCaosDBServerResource extends ServerResource {
private static final long serialVersionUID = -6836378704013776849L;
}
/**
* Returns the (probably unique) server request ID.
*
* @return The server request ID.
*/
public String getSRID() {
return this.sRID;
}
......@@ -156,6 +161,19 @@ public abstract class AbstractCaosDBServerResource extends ServerResource {
@Override
protected void doRelease() {}
/**
* Creates the XML root.
*
* <p>The XML root node contains:
*
* <p>
*
* <ul>
* <li>User info as per addUserInfo
* <li>The sRID (server-side request ID)
* <li>A timestamp
* <li>The URI to this resource.
*/
protected Element generateRootElement() {
final Element retRoot = new Element("Response");
......@@ -413,6 +431,11 @@ public abstract class AbstractCaosDBServerResource extends ServerResource {
return root;
}
/**
* Returns the client request ID, which can be set by the client.
*
* @return The cRID.
*/
public String getCRID() {
return cRID;
}
......
......@@ -292,7 +292,7 @@ public class ServerMessages {
new Message(
MessageType.Error,
0,
"This password is too weak. It should be longer than 8 characters and contain at least one number, one symbol, one uppercase letter and one lowercase letter. ");
"This password is too weak. It should be longer than 8 characters and sufficiently random. ");
public static final Message AFFILIATION_ERROR =
new Message(
......
......@@ -252,8 +252,9 @@ public class Utils {
}
/**
* Intended to convert sizes to human readably sizes. TODO: might be broken because of the log
* function above.
* Converts file sizes to human readably sizes.
*
* <p>For example, getReadableByteSize(2048) == "2KiB".
*/
public static String getReadableByteSize(final Long fssize) {
if (fssize == null) {
......@@ -280,10 +281,10 @@ public class Utils {
/**
* Determines the strength of a password. Currently this just throws an error when the String
* password does not at least contain - An uppercase char - A lowercase char - A number - A
* `password` does not at least contain - An uppercase char - A lowercase char - A number - A
* punctuation char and if the length is not at least 8 characters.
*
* <p>correcthorsebatterystaple would be rejected.
* <p>correcthorsebatterystaple is also rejected.
*
* @param password The password to be checked.
*/
......@@ -297,5 +298,9 @@ public class Utils {
if (!(length && uppercase && lowercase && number && punct)) {
throw ServerMessages.PASSWORD_TOO_WEAK;
}
if (password.equals("correcthorsebatterystaple")) {
throw ServerMessages.PASSWORD_TOO_WEAK;
}
}
}
......@@ -86,9 +86,7 @@ public class TestAbstractCaosDBServerResource {
assertNotNull(userInfo);
}
/**
* Creates a dummy usersources.ini and injects it into the server properties.
*/
/** Creates a dummy usersources.ini and injects it into the server properties. */
private void provideUserSourcesFile() throws IOException {
String usersourcesFileName = tempFolder.newFile("usersources.ini").getAbsolutePath();
String usersourcesContent =
......
......@@ -2,7 +2,7 @@
* ** header v3.0
* This file is a part of the CaosDB Project.
*
* Copyright (C) 2018 Research Group Biomedical Physics,
* Copyright (C) 2019 Research Group Biomedical Physics,
* Max-Planck-Institute for Dynamics and Self-Organization Göttingen
*
* This program is free software: you can redistribute it and/or modify
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment