use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class AuthorizationManager method securityCheck.
private void securityCheck(String identity) {
logger.debug("*** Security check ***");
// Add identity
addAuthorizedIdentity(identity);
// Register
logger.debug("Register: " + identity);
Response response = register(identity);
if (response.getClass().equals(RegistrationResponse.class)) {
RegistrationResponse ret = (RegistrationResponse) response;
String auth = ret.getClientId() + ":" + ret.getClientSecret();
logger.debug("ID:SECRET=" + auth);
// Get token
String encodedCredentials = Base64.getEncoder().encodeToString(auth.getBytes());
logger.debug("Authorization Basic " + encodedCredentials);
response = getToken(encodedCredentials);
if (response.getClass().equals(JWTResponse.class)) {
logger.debug("Access token: " + ((JWTResponse) response).getAccessToken());
// Validate token
Response valid = validateToken(((JWTResponse) response).getAccessToken());
if (!valid.getClass().equals(ErrorResponse.class))
logger.debug("PASSED");
else {
ErrorResponse error = (ErrorResponse) valid;
logger.debug("FAILED Code: " + error.getErrorCode() + "Message: " + error.getErrorMessage());
}
} else
logger.debug("FAILED");
} else
logger.debug("FAILED");
logger.debug("**********************");
System.out.println("");
// Add identity
removeAuthorizedIdentity(identity);
}
use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class MessageReceiver method joinChat.
public boolean joinChat() {
if (joined)
return true;
Response ret = subscribe(message);
joined = !ret.isError();
if (joined) {
for (Bindings bindings : ((SubscribeResponse) ret).getBindingsResults().getBindings()) {
listener.onMessageReceived(new Message(bindings.getBindingValue("sender"), message.getBindingValue("receiver"), bindings.getBindingValue("text"), bindings.getBindingValue("time")));
}
}
return joined;
}
use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class MessageReceiver method leaveChat.
public boolean leaveChat() {
if (!joined)
return true;
Response ret = unsubscribe();
joined = !ret.isUnsubscribeResponse();
return !joined;
}
use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class MessageSender method joinChat.
public boolean joinChat() {
if (joined)
return true;
Response ret = subscribe(message);
joined = !ret.isError();
if (joined) {
for (Bindings bindings : ((SubscribeResponse) ret).getBindingsResults().getBindings()) {
listener.onMessageSent(new Message(message.getBindingValue("sender"), bindings.getBindingValue("receiver"), bindings.getBindingValue("text"), bindings.getBindingValue("time")));
}
}
return joined;
}
use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.
the class MessageSender method leaveChat.
public boolean leaveChat() {
if (!joined)
return true;
Response ret = unsubscribe();
joined = !ret.isUnsubscribeResponse();
return !joined;
}
Aggregations