Skip to content
This repository has been archived by the owner on Jul 16, 2019. It is now read-only.

Commit

Permalink
RAS-37 Add authority base url and trusted key file location to exampl…
Browse files Browse the repository at this point in the history
…e client.
  • Loading branch information
christian.rijke committed Oct 1, 2015
1 parent 52b995d commit e764b7d
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package org.echocat.marquardt.example.ui;

import javafx.event.Event;
import javafx.fxml.FXML;
import javafx.scene.control.TextField;
import org.echocat.marquardt.client.spring.SpringClient;
Expand All @@ -19,15 +20,17 @@

public class MainSceneController {

public static final String BASE_URI = "http://localhost:8080";
public static final String DEFAULT_BASE_URI = "http://localhost:8080";
public static final String DEFAULT_PUBLIC_KEY_FILES = "keys/auth-public-key.der";

public static final String PUBLIC_KEY_FILE = "keys/auth-public-key.der";
public static final String PRIVATE_KEY_FILE = "keys/auth-private-key.der";


public static final String SUCCESS = "success";
public static final String FAILED = "failed";

private final KeyFileReadingKeyPairProvider _clientKeyProvider;
private KeyFileReadingKeyPairProvider _clientKeyProvider;

@FXML
private TextField _signupEmailField;
Expand Down Expand Up @@ -66,18 +69,31 @@ public class MainSceneController {
@FXML
private TextField _payloadUuidField;

@FXML
private TextField _authorityBaseUrlField;

@FXML
private TextField _trustedKeyFileLocations;

private SpringClient<UserInfo, ExampleRoles> _client;

public MainSceneController() {
_clientKeyProvider = new KeyFileReadingKeyPairProvider(PUBLIC_KEY_FILE, PRIVATE_KEY_FILE);
KeyFileReadingTrustedKeysProvider trustedKeysProvider = new KeyFileReadingTrustedKeysProvider(PUBLIC_KEY_FILE);
_client = new SpringClient<>(BASE_URI, UserInfo.FACTORY, ExampleRoles.FACTORY, _clientKeyProvider, trustedKeysProvider.getPublicKeys());
initializeMarquardtClient(DEFAULT_BASE_URI, DEFAULT_PUBLIC_KEY_FILES);
}

@FXML
private void initialize() {
_clientPublicKeyField.setText(_clientKeyProvider.getPublicKey().toString());
_clientPrivateKeyField.setText(_clientKeyProvider.getPrivateKey().toString());
_authorityBaseUrlField.setText(DEFAULT_BASE_URI);
_trustedKeyFileLocations.setText(DEFAULT_PUBLIC_KEY_FILES);
}

private void initializeMarquardtClient(String baseUri, String publicKeyFiles) {
_clientKeyProvider = new KeyFileReadingKeyPairProvider(PUBLIC_KEY_FILE, PRIVATE_KEY_FILE);
KeyFileReadingTrustedKeysProvider trustedKeysProvider = new KeyFileReadingTrustedKeysProvider(publicKeyFiles);
_client = new SpringClient<>(baseUri, UserInfo.FACTORY, ExampleRoles.FACTORY, _clientKeyProvider, trustedKeysProvider.getPublicKeys());
}

@FXML
Expand Down Expand Up @@ -130,6 +146,13 @@ public void signoutButtonClicked() {
}
}

@FXML
public void settingsApplyButtonClicked() {
String baseUri = _authorityBaseUrlField.getText();
String publicKeyFiles = _trustedKeyFileLocations.getText();
initializeMarquardtClient(baseUri, publicKeyFiles);
}

private void renderCertificate(Certificate<UserInfo> certificate) {
_certificateIssuerPublicKeyField.setText(certificate.getIssuerPublicKey().toString());
_certificateClientPublicKeyField.setText(certificate.getClientPublicKey().toString());
Expand Down
133 changes: 62 additions & 71 deletions example/src/main/resources/ui/exampleclient.fxml
Original file line number Diff line number Diff line change
@@ -1,41 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
* echocat Marquardt Java SDK, Copyright (c) 2015 echocat
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
-->

<?import java.lang.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.shape.*?>
<?import javafx.scene.text.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.shape.Rectangle?>
<?import javafx.scene.text.Font?>
<Pane fx:controller="org.echocat.marquardt.example.ui.MainSceneController" maxHeight="-Infinity"
maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="491.0" prefWidth="600.0"
xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">

<Pane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="622.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1" fx:controller="org.echocat.marquardt.example.ui.MainSceneController">
<children>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="284.0" layoutX="9.0" layoutY="202.0"
stroke="BLACK" strokeType="INSIDE" width="585.0"/>
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="279.0" layoutX="9.0" layoutY="209.0" stroke="BLACK" strokeType="INSIDE" width="585.0" />
<TabPane prefHeight="200.0" prefWidth="600.0" tabClosingPolicy="UNAVAILABLE">
<tabs>
<Tab text="Sign Up">
<content>
<Pane prefHeight="200.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="28.0" prefHeight="17.0" prefWidth="109.0" text="Email"/>
<Label layoutX="14.0" layoutY="58.0" prefHeight="17.0" prefWidth="109.0"
text="Password"/>
<Label layoutX="14.0" layoutY="88.0" prefHeight="17.0" prefWidth="109.0"
text="Response"/>
<Button onMouseClicked="#signupButtonClicked" layoutX="534.0" layoutY="132.0"
mnemonicParsing="false" text="Sign Up"/>
<TextField fx:id="_signupEmailField" layoutX="218.0" layoutY="24.0" prefHeight="25.0"
prefWidth="369.0"/>
<TextField fx:id="_signupPasswordField" layoutX="218.0" layoutY="54.0" prefHeight="25.0"
prefWidth="369.0"/>
<TextField fx:id="_signupResponseField" layoutX="218.0" layoutY="84.0" prefHeight="25.0"
prefWidth="369.0"/>
<Label layoutX="14.0" layoutY="28.0" prefHeight="17.0" prefWidth="109.0" text="Email" />
<Label layoutX="14.0" layoutY="58.0" prefHeight="17.0" prefWidth="109.0" text="Password" />
<Label layoutX="14.0" layoutY="88.0" prefHeight="17.0" prefWidth="109.0" text="Response" />
<Button layoutX="529.0" layoutY="132.0" mnemonicParsing="false" onMouseClicked="#signupButtonClicked" text="Sign Up" />
<TextField fx:id="_signupEmailField" layoutX="218.0" layoutY="24.0" prefHeight="25.0" prefWidth="369.0" />
<TextField fx:id="_signupPasswordField" layoutX="218.0" layoutY="54.0" prefHeight="25.0" prefWidth="369.0" />
<TextField fx:id="_signupResponseField" layoutX="218.0" layoutY="84.0" prefHeight="25.0" prefWidth="369.0" />

</children>
</Pane>
Expand All @@ -45,22 +43,15 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Pane layoutY="1.0" prefHeight="170.0" prefWidth="600.0">
<Pane prefHeight="170.0" prefWidth="600.0">
<children>
<Label layoutX="14.0" layoutY="28.0" prefHeight="17.0" prefWidth="109.0"
text="Email"/>
<Label layoutX="14.0" layoutY="58.0" prefHeight="17.0" prefWidth="109.0"
text="Password"/>
<Label layoutX="14.0" layoutY="88.0" prefHeight="17.0" prefWidth="109.0"
text="Response"/>
<TextField fx:id="_signinEmailField" layoutX="218.0" layoutY="24.0"
prefHeight="25.0" prefWidth="369.0"/>
<TextField fx:id="_signinPasswordField" layoutX="218.0" layoutY="54.0"
prefHeight="25.0" prefWidth="369.0"/>
<TextField fx:id="_signinResponseField" layoutX="218.0" layoutY="84.0"
prefHeight="25.0" prefWidth="369.0"/>
<Button onMouseClicked="#signinButtonClicked" layoutX="534.0" layoutY="132.0"
mnemonicParsing="false" text="Sign In"/>
<Label layoutX="14.0" layoutY="28.0" prefHeight="17.0" prefWidth="109.0" text="Email" />
<Label layoutX="14.0" layoutY="58.0" prefHeight="17.0" prefWidth="109.0" text="Password" />
<Label layoutX="14.0" layoutY="88.0" prefHeight="17.0" prefWidth="109.0" text="Response" />
<TextField fx:id="_signinEmailField" layoutX="218.0" layoutY="24.0" prefHeight="25.0" prefWidth="369.0" />
<TextField fx:id="_signinPasswordField" layoutX="218.0" layoutY="54.0" prefHeight="25.0" prefWidth="369.0" />
<TextField fx:id="_signinResponseField" layoutX="218.0" layoutY="84.0" prefHeight="25.0" prefWidth="369.0" />
<Button layoutX="534.0" layoutY="132.0" mnemonicParsing="false" onMouseClicked="#signinButtonClicked" text="Sign In" />
</children>
</Pane>
</children>
Expand All @@ -71,12 +62,9 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="88.0" prefHeight="17.0" prefWidth="109.0"
text="Response"/>
<Button onMouseClicked="#refreshButtonClicked" layoutX="534.0" layoutY="132.0"
mnemonicParsing="false" text="Refresh"/>
<TextField fx:id="_refreshResponseField" layoutX="218.0" layoutY="84.0"
prefHeight="25.0" prefWidth="369.0"/>
<Label layoutX="14.0" layoutY="88.0" prefHeight="17.0" prefWidth="109.0" text="Response" />
<Button layoutX="530.0" layoutY="132.0" mnemonicParsing="false" onMouseClicked="#refreshButtonClicked" text="Refresh" />
<TextField fx:id="_refreshResponseField" layoutX="218.0" layoutY="84.0" prefHeight="25.0" prefWidth="369.0" />
</children>
</AnchorPane>
</content>
Expand All @@ -85,53 +73,56 @@
<content>
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
<children>
<Label layoutX="14.0" layoutY="88.0" prefHeight="17.0" prefWidth="109.0"
text="Response"/>
<TextField fx:id="_signoutResponseField" layoutX="218.0" layoutY="84.0"
prefHeight="25.0" prefWidth="369.0"/>
<Button onMouseClicked="#signoutButtonClicked" layoutX="534.0" layoutY="132.0"
mnemonicParsing="false" text="Sign Out"/>
<Label layoutX="14.0" layoutY="88.0" prefHeight="17.0" prefWidth="109.0" text="Response" />
<TextField fx:id="_signoutResponseField" layoutX="218.0" layoutY="84.0" prefHeight="25.0" prefWidth="369.0" />
<Button layoutX="524.0" layoutY="132.0" mnemonicParsing="false" onMouseClicked="#signoutButtonClicked" text="Sign Out" />
</children>
</AnchorPane>
</content>
</Tab>
</tabs>
</TabPane>
<Label layoutX="14.0" layoutY="217.0" prefHeight="17.0" prefWidth="190.0" text="Certificate">
<Label layoutX="14.0" layoutY="238.0" text="Issuer Public Key" />
<Label layoutX="14.0" layoutY="266.0" text="Client Public Key" />
<Label layoutX="14.0" layoutY="294.0" text="Role Codes" />
<Label layoutX="14.0" layoutY="322.0" text="Expires At" />
<TextField fx:id="_certificateIssuerPublicKeyField" layoutX="218.0" layoutY="234.0" prefHeight="25.0" prefWidth="369.0" />
<TextField fx:id="_certificateClientPublicKeyField" layoutX="218.0" layoutY="262.0" prefHeight="25.0" prefWidth="369.0" />
<TextField fx:id="_certificateRoleCodesField" layoutX="218.0" layoutY="290.0" prefHeight="25.0" prefWidth="369.0" />
<TextField fx:id="_certificateRoleExpiresAtField" layoutX="218.0" layoutY="318.0" prefHeight="25.0" prefWidth="369.0" />

<Label layoutX="14.0" layoutY="357.0" prefHeight="17.0" prefWidth="190.0" text="Payload">
<font>
<Font name="System Bold" size="12.0"/>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="238.0" text="Issuer Public Key"/>
<Label layoutX="14.0" layoutY="266.0" text="Client Public Key"/>
<Label layoutX="14.0" layoutY="297.0" text="Role Codes"/>
<Label layoutX="13.0" layoutY="326.0" text="Expires At"/>
<TextField fx:id="_certificateIssuerPublicKeyField" layoutX="218.0" layoutY="234.0" prefHeight="25.0"
prefWidth="369.0"/>
<TextField fx:id="_certificateClientPublicKeyField" layoutX="218.0" layoutY="262.0" prefHeight="25.0"
prefWidth="369.0"/>
<TextField fx:id="_certificateRoleCodesField" layoutX="218.0" layoutY="293.0" prefHeight="25.0" prefWidth="369.0"/>
<TextField fx:id="_certificateRoleExpiresAtField" layoutX="218.0" layoutY="322.0" prefHeight="25.0"
prefWidth="369.0"/>
<Label layoutX="14.0" layoutY="378.0" text="UUID" />
<TextField fx:id="_payloadUuidField" layoutX="218.0" layoutY="374.0" prefHeight="25.0" prefWidth="369.0" />

<Label layoutX="14.0" layoutY="347.0" prefHeight="17.0" prefWidth="190.0" text="Payload">
<Label layoutX="14.0" layoutY="413.0" prefHeight="17.0" prefWidth="190.0" text="Client Key Pair">
<font>
<Font name="System Bold" size="12.0"/>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="368.0" text="UUID"/>
<TextField fx:id="_payloadUuidField" layoutX="218.0" layoutY="364.0" prefHeight="25.0"
prefWidth="369.0"/>

<Label layoutX="14.0" layoutY="406.0" prefHeight="17.0" prefWidth="190.0" text="Client Key Pair">
<Label layoutX="14.0" layoutY="434.0" prefHeight="17.0" prefWidth="109.0" text="Client Public Key" />
<Label layoutX="14.0" layoutY="462.0" prefHeight="17.0" prefWidth="109.0" text="Client Private Key" />
<TextField fx:id="_clientPublicKeyField" layoutX="218.0" layoutY="430.0" prefHeight="25.0" prefWidth="369.0" />
<TextField fx:id="_clientPrivateKeyField" layoutX="218.0" layoutY="458.0" prefHeight="25.0" prefWidth="369.0" />
<Rectangle arcHeight="5.0" arcWidth="5.0" fill="WHITE" height="119.0" layoutX="8.0" layoutY="496.0" stroke="BLACK" strokeType="INSIDE" width="585.0" />
<Label layoutX="14.0" layoutY="528.0" text="Authority URL" />
<TextField fx:id="_authorityBaseUrlField" layoutX="219.0" layoutY="524.0" prefHeight="25.0" prefWidth="369.0" />
<Label layoutX="14.0" layoutY="507.0" prefHeight="17.0" prefWidth="190.0" text="Settings">
<font>
<Font name="System Bold" size="12.0"/>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<Label layoutX="14.0" layoutY="427.0" prefHeight="17.0" prefWidth="109.0" text="Client Public Key"/>
<Label layoutX="14.0" layoutY="456.0" prefHeight="17.0" prefWidth="109.0" text="Client Private Key"/>
<TextField fx:id="_clientPublicKeyField" layoutX="218.0" layoutY="423.0" prefHeight="25.0" prefWidth="369.0"/>
<TextField fx:id="_clientPrivateKeyField" layoutX="218.0" layoutY="452.0" prefHeight="25.0" prefWidth="369.0"/>

<Label layoutX="14.0" layoutY="217.0" prefHeight="17.0" prefWidth="190.0" text="Certificate">
<font>
<Font name="System Bold" size="12.0" />
</font>
</Label>
<TextField fx:id="_trustedKeyFileLocations" layoutX="219.0" layoutY="552.0" prefHeight="25.0" prefWidth="369.0" />
<Label layoutX="14.0" layoutY="556.0" text="Trusted Key File Locations" />
<Button layoutX="540.0" layoutY="583.0" mnemonicParsing="false" onMouseClicked="#settingsApplyButtonClicked" text="Apply" />
</children>
</Pane>

0 comments on commit e764b7d

Please sign in to comment.