use of org.stepik.api.objects.auth.TokenInfo in project intellij-plugins by StepicOrg.
the class AbstractAuthorizationPostQuery method execute.
@NotNull
@Override
public TokenInfo execute() {
TokenInfo tokenInfo = super.execute();
StepikAbstractAction action = getStepikAction();
action.getStepikApiClient().setTokenInfo(tokenInfo);
return tokenInfo;
}
use of org.stepik.api.objects.auth.TokenInfo in project intellij-plugins by StepicOrg.
the class StepikAuthManager method setState.
private static void setState(@NotNull StepikAuthState value) {
StepikAuthState oldState = state;
state = value;
if (state == NOT_AUTH) {
stepikApiClient.setTokenInfo(null);
user = null;
long userId = getLastUser();
setTokenInfo(userId, new TokenInfo());
setLastUser(0);
}
if (oldState != state) {
if (state == AUTH) {
Metrics.authenticate(SUCCESSFUL);
}
executor.execute(() -> listeners.forEach(listener -> listener.stateChanged(oldState, state)));
}
}
use of org.stepik.api.objects.auth.TokenInfo in project intellij-plugins by StepicOrg.
the class StepikAuthManager method getTokenInfo.
@NotNull
private static TokenInfo getTokenInfo(long userId, StepikApiClient client) {
if (userId == 0) {
return new TokenInfo();
}
String serviceName = StepikProjectManager.class.getName();
CredentialAttributes attributes = new CredentialAttributes(serviceName, String.valueOf(userId), StepikProjectManager.class, false);
Credentials credentials = PasswordSafe.getInstance().get(attributes);
TokenInfo authInfo = null;
if (credentials != null) {
String password = credentials.getPasswordAsString();
authInfo = client.getJsonConverter().fromJson(password, TokenInfo.class);
}
if (authInfo == null) {
return new TokenInfo();
}
return authInfo;
}
Aggregations