Commit ec6d9484 authored by Dr. Martin Goik's avatar Dr. Martin Goik

Merge branch 'master' of gitlab.mi.hdm-stuttgart.de:goik/GoikLectures

parents a1b3957f d8ae314f
......@@ -558,6 +558,16 @@
</glossdef>
</glossentry>
<glossentry xml:id="glo_NIC">
<glossterm>NIC</glossterm>
<glossdef>
<para><link
xlink:href="https://en.wikipedia.org/wiki/Network_interface_controller">Network
Interface Controller</link></para>
</glossdef>
</glossentry>
<glossentry xml:id="glo_OO">
<glossterm><acronym>OO</acronym></glossterm>
......@@ -703,6 +713,14 @@
</glossdef>
</glossentry>
<glossentry xml:id="glo_SNI">
<glossterm><acronym>SNI</acronym></glossterm>
<glossdef>
<para>Server Name Indication</para>
</glossdef>
</glossentry>
<glossentry xml:id="glo_SNMP">
<glossterm><acronym>SNMP</acronym></glossterm>
......@@ -887,9 +905,20 @@
<glossterm><acronym>TLS</acronym></glossterm>
<glossdef>
<para><link
xlink:href="https://en.wikipedia.org/wiki/Transport_Layer_Security">Transport
Layer Security</link></para>
<para>Transport Layer Security</para>
<itemizedlist>
<listitem>
<para><link
xlink:href="https://en.wikipedia.org/wiki/Transport_Layer_Security">Wikipedia</link></para>
</listitem>
<listitem>
<para><link
xlink:href="https://www.globalsign.com/en/blog/ssl-vs-tls-difference">TLS
<abbrev>vs.</abbrev> SSL</link> distinction</para>
</listitem>
</itemizedlist>
</glossdef>
</glossentry>
......
......@@ -1739,10 +1739,9 @@ velocity = (short) measure; // Explicit double to short conversion</programlisti
<programlisting language="java">int i = -21;
double d = i;</programlisting>
<para>This snippet shows perfectly correct <xref
linkend="glo_Java"/> code. However <xref
linkend="sd1_fig_typeSafety"/> suggests we should not be allowed
to assign an <code language="java"
<para>This snippet shows correct <xref linkend="glo_Java"/> code.
However <xref linkend="sd1_fig_typeSafety"/> suggests we should
not be allowed to assign an <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.1-100-C">int</code>
to a <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.3-100">double</code>
......@@ -1766,48 +1765,70 @@ int i = d; // Error: Incompatible types</programlisting>
<listitem>
<para>Whats the ratio behind this design decision? Hint: What
would happen for larger <code>double</code> values?</para>
would happen for larger <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.3-100">double</code>
values?</para>
</listitem>
</orderedlist>
</question>
<answer>
<para>The first code snippet uses the <emphasis
role="bold">widening conversion</emphasis>: When assigning <code
language="java">d = i</code> the <xref linkend="glo_Java"/>
compiler implicitly converts a four byte <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.1-100-C">int</code>
into an eight byte <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.3-100">double</code>
value.</para>
<orderedlist>
<listitem>
<para>The first code snippet uses the <emphasis
role="bold">widening conversion</emphasis>: When assigning
<code language="java">d = i</code> the <xref
linkend="glo_Java"/> compiler implicitly converts a four byte
<code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.1-100-C">int</code>
into an eight byte <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.3-100">double</code>
value.</para>
<para>Turning a double into an int is more cumbersome: The
expression <code language="java">i = 3.5</code> could be evaluated
by agreeing on a specific rounding prescription. But what about i
= 3457357385783573478955345.45? A <xref linkend="glo_Java"/> <code
language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.1-100-C">int</code>'s
maximum value is <inlineequation>
<m:math display="inline">
<m:mrow>
<m:msup>
<m:mi>2</m:mi>
<para>In contrast there is no automated narrowing from <code
language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.3-100">double</code>
to <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.1-100-C">int</code>
hence causing a compile time error.</para>
</listitem>
<m:mi>31</m:mi>
</m:msup>
<listitem>
<para>Turning a <code language="java">double</code> into an
<code language="java">int</code> is more cumbersome: The
expression e.g. <code language="java">i = 3.5</code> could be
evaluated by agreeing on a specific rounding prescription. But
what about e.g. i = 3457357385783573478955345.45 ? A <xref
linkend="glo_Java"/> <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.1-100-C">int</code>'s
maximum value is <inlineequation>
<m:math display="inline">
<m:mrow>
<m:msup>
<m:mi>2</m:mi>
<m:mo>-</m:mo>
<m:mi>31</m:mi>
</m:msup>
<m:mi>1</m:mi>
</m:mrow>
</m:math>
</inlineequation>exceeding the former <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.3-100">double</code>
value.</para>
<m:mo>-</m:mo>
<para>Conclusion: <xref linkend="glo_Java"/> disallows double to
int assignments unless using a so called cast (explicit type
conversion):</para>
<m:mi>1</m:mi>
</m:mrow>
</m:math>
</inlineequation>unable to accommodate the <code
language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.3-100">double</code>
value in question by far.</para>
<para>Conclusion: <xref linkend="glo_Java"/> disallows <code
language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.3-100">double</code>
to <code language="java"
xlink:href="https://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.1-100-C">int</code>
assignments unless using a so called cast (explicit type
conversion):</para>
</listitem>
</orderedlist>
<para>Caveats using explicit casts:</para>
......@@ -1824,8 +1845,8 @@ System.out.println("Result: " + i);</programlisting></td>
</informaltable>
<para>Notice the result of 2 rather than 3 as you might have
expected assuming some common rounding convention. This does
not happen unless you explicitly use methods like e.g.
expected assuming common rounding convention rules. Rounding
does not happen unless you explicitly use methods like e.g.
<methodname
xlink:href="https://docs.oracle.com/javase/10/docs/api/java/lang/Math.html#round(double)">Math.round()</methodname>.</para>
</listitem>
......@@ -1842,8 +1863,8 @@ System.out.println("Result: " + i);</programlisting></td>
</informaltable>
<para>This truncation of 3 billion to 2147483647 is due to the
latter being the largest possible <code
language="java">int</code> value to je represented in <xref
latter value being the largest possible <code
language="java">int</code> value to be represented in <xref
linkend="glo_Java"/>.</para>
</listitem>
</orderedlist>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<chapter version="5.1" xml:id="sdiApache"
xmlns="http://docbook.org/ns/docbook"
annotations="slide"
xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xila="http://www.w3.org/2001/XInclude/local-attributes"
xmlns:xi="http://www.w3.org/2001/XInclude"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns:ns="http://docbook.org/ns/transclusion"
......@@ -13,29 +15,198 @@
<section xml:id="sdiApachePrelim">
<title>Preliminaries</title>
<para>The following documentation will be helpful:</para>
<itemizedlist>
<listitem>
<para><link xlink:href="https://httpd.apache.org/docs/2.4">Apache HTTP
Server Version 2.4 Documentation</link></para>
</listitem>
</itemizedlist>
<tip>
<para>Whenever searching for <productname>Apache</productname> related
configuration hints always include <quote>2.4</quote> in your query
string: The configuration file syntax has changed considerably in
comparison to <productname>Apache</productname> 2.2.</para>
</tip>
<figure xml:id="sdi_webserver_documentation">
<title>External documentation</title>
<itemizedlist>
<listitem>
<para><link xlink:href="https://httpd.apache.org/docs/2.4">Apache
HTTP Server Version 2.4 Documentation</link></para>
</listitem>
</itemizedlist>
<tip>
<para>Whenever searching for <productname>Apache</productname> related
documentation <emphasis>always</emphasis> include <quote>2.4</quote>
in your query: Configuration file syntax changed considerably with
respect to <productname>Apache</productname> version 2.2.</para>
</tip>
</figure>
<figure xml:id="sdi_webserver_uri2fs">
<title>URI to filesystem mapping</title>
<mediaobject>
<imageobject>
<imagedata fileref="Ref/Webserver/assetMapping.multi.svg"/>
</imageobject>
</mediaobject>
</figure>
<figure xml:id="sdi_webserver_virtualHostPrinciple">
<title>Virtual hosting</title>
<itemizedlist>
<listitem>
<para>One physical host system</para>
</listitem>
<listitem>
<para>Serving multiple sites e.g.:</para>
<itemizedlist>
<listitem>
<para><uri>https://www.foo.org</uri></para>
</listitem>
<listitem>
<para><uri>https://www.second.org</uri></para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</figure>
<figure xml:id="sdi_webserver_virtualHostImplementations">
<title>Implementing virtual hosting</title>
<orderedlist>
<listitem>
<para>Port based virtual hosting</para>
</listitem>
<listitem>
<para>IP based virtual hosting</para>
</listitem>
<listitem>
<para>Name based virtual hosting</para>
<para>Typically using <emphasis role="red">S</emphasis>erver
<emphasis role="red">N</emphasis>ame <emphasis
role="red">I</emphasis>ndication (<xref linkend="glo_SNI"/>)</para>
</listitem>
</orderedlist>
</figure>
<figure xml:id="sdi_webserver_IpBasedVhost">
<title>IP based virtual hosting</title>
<mediaobject>
<imageobject>
<imagedata fileref="Ref/Webserver/ipBasedVirtual.multi.svg"/>
</imageobject>
</mediaobject>
</figure>
<figure xml:id="sdi_webserver_IpBasedVhostProCons">
<title>IP based, pros / cons</title>
<itemizedlist>
<listitem>
<para>Host system: One IP per site to serve</para>
</listitem>
<listitem>
<para>Pro: <xref linkend="glo_TLS"/> handshake without <xref
linkend="glo_SNI"/>.</para>
<para>Supporting older clients.</para>
</listitem>
<listitem>
<para>Downside:</para>
<itemizedlist>
<listitem>
<para>IP address waste</para>
</listitem>
<listitem>
<para>Host system <xref linkend="glo_NIC"/> configuration
required</para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</figure>
<figure xml:id="sdi_webserver_NameBasedVhost">
<title>Name based virtual hosting</title>
<mediaobject>
<imageobject>
<imagedata fileref="Ref/Webserver/nameBasedVirtual.multi.svg"/>
</imageobject>
</mediaobject>
</figure>
<figure xml:id="sdi_webserver_NameBasedVhostProCons">
<title>Name based, pros / cons</title>
<itemizedlist>
<listitem>
<para>Host system: Common IP address</para>
</listitem>
<listitem>
<para>Pro</para>
<itemizedlist>
<listitem>
<para>IP address waste</para>
</listitem>
<listitem>
<para>Host system <xref linkend="glo_NIC"/> configuration
required</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>Cons: Excluding older non <xref linkend="glo_SNI"/> supporting
clients.</para>
<para>(Internet Explorer on <productname>Windows XP</productname>,
Android below V. 2.3)</para>
</listitem>
<listitem>
<para><xref linkend="glo_SNI"/> allows for eavesdropping requested
site's name.</para>
</listitem>
</itemizedlist>
</figure>
<figure xml:id="sdi_webserver_ldapAuth">
<title><xref linkend="glo_LDAP"/> backed authentication</title>
<mediaobject>
<imageobject>
<imagedata fileref="Ref/Webserver/ldapAuth.multi.svg"/>
</imageobject>
</mediaobject>
</figure>
<figure xml:id="sdi_webserver_phpFpm">
<title><abbrev>PHP</abbrev> <abbrev>FPM</abbrev> server</title>
<mediaobject>
<imageobject>
<imagedata fileref="Ref/Webserver/phpFpm.multi.svg"/>
</imageobject>
</mediaobject>
</figure>
</section>
<section xml:id="sdiApacheExercise">
<title>Exercises</title>
<para>The Apache web server <package>apache2</package> software package
may have already been installed depending on other exercises (<xref
linkend="glo_LDAP"/> administration frontend?):</para>
may have already been installed depending on other exercises
<abbrev>e.g.</abbrev> <xref linkend="glo_LDAP"/> administration
frontend:</para>
<screen>aptitude install apache2</screen>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment