OAUTH 2.0, JAX-RS CODE ind Winows-API-Aufrufe umsetzen

Nordrhein-Westfalen, Neuss  ‐ Remote
Dieses Projekt ist archiviert und leider nicht (mehr) aktiv.
Sie finden vakante Projekte hier in unserer Projektbörse.

Beschreibung

Uns liegt ein JAVA-Code einer Applikation vor. Leider dürfen wir keine JAVA-Applikation bei unserem Kunden installieren, deshalb suchen wir einen Entwickler, der in der Lage ist, diese Anwendung in Windows-API-Aufrufe umzusetzen.


// Initialize the Keystore...
//
// Use your own Keystore and password here

File keystoreFile = new File (certificateFilename);
char[] password = otp.toCharArray ( );

// Initialize the keystore as a PKCS12 keystore.
KeyStore keyStore = null;
try {
keyStore = KeyStore.getInstance ("PKCS12");
} catch (KeyStoreException e) {
e.printStackTrace ( );
}
try {
keyStore
.load (new FileInputStream (keystoreFile),
password);
System.out.println ("KEYSTORE initialized successfully");
} catch (IOException | NoSuchAlgorithmException | CertificateException e) {
e.printStackTrace ( );
}

// Step 2 - Retrieve the Token from OpenID Endpoint

// Prepare the JAX-RS WebTarget Object for Retrieval of the token from OAuth Endpoint
WebTarget authorizeWebTarget = ClientBuilder
.newBuilder ( )
.keyStore (keyStore, password) // Use the Keystore from Step 1
.build ( )
.target (AUTHORIZE_URI);

// Create the form-based values

// Build a Form for the Post to the Authorization endpoint.
Form form = new Form ( );

form.param ("grant_type", "password");
form.param ("client_id", "securPharm");
form.param ("scope", "openid");

// "application/x-www-form-urlencoded"

//
Response response = authorizeWebTarget
.register (LoggingFilter.class)
.request ( )
.header ("Content-Type", MediaType.APPLICATION_FORM_URLENCODED_TYPE)
.post (
Entity.entity (
form,
MediaType.APPLICATION_FORM_URLENCODED_TYPE
)
);
// Get the token out of the Response.
String token = "";
boolean isAuthorized = false;
if (response.getStatus ( ) == 200) {

StringReader reader = new StringReader (response.readEntity (String.class));
JsonReader jsonReader = Json.createReader (reader);
JsonObject jsonObject = jsonReader.readObject ( );
token = jsonObject.getString ("access_token");
if (!token.isEmpty ( )) {
isAuthorized = true;
}
LocalDateTime expireDateTime = LocalDateTime.now ( )
.plus (jsonObject.getInt ("expires_in"), ChronoUnit.SECONDS);
} else {
System.out.println ("Response from Openid Point was not 200! No token received");
}

System.out.println ("token = " + token);

// The following call is for optionally check the token received in the first step. You can
// retrieve the public signing key of the Auth Server and check the signing of your token.
// Some commonly used libraries for that are Nimbus and JJWT.
Response realmResponse = ClientBuilder
.newBuilder ( )
.keyStore (keyStore, password) // Use the Keystore from Step 1
.build ( )
.target (REALM_URI)
// .register(LoggingFilter.class) // Optionally use a LoggingFilter to show some Call loggings
.request ( )
.get ( );
// Getting
StringReader realmResponseReader = new StringReader (realmResponse.readEntity (String.class));
JsonObject realmObject = Json.createReader (realmResponseReader).readObject ( );
String publicKey = realmObject.getString ("public_key");
System.out.println ("publicKey = " + publicKey);

// With this received public key you may check the signature. Other claims in the token may be proved
// as well. For readability reasons we skip that here.

// Lets do some action and build up a common WebTarget for the base securPharm API URL.

javax.ws.rs.client.Client apiClient = ClientBuilder.newBuilder ( )
.build ( );
WebTarget apiTarget = apiClient.target (BASE_SECURPHARM_API_URI)
.register (LoggingFilter.class); // This time with a logging filter enabled
Start
ab sofort
Von
KIRNBAUER Systementwicklung und EDV-Beratung GmbH
Eingestellt
29.10.2018
Ansprechpartner:
Johann Kirnbauer
Projekt-ID:
1657207
Vertragsart
Freiberuflich
Einsatzart
100 % Remote
Um sich auf dieses Projekt zu bewerben müssen Sie sich einloggen.
Registrieren