- private class TCCreator implements Creator<TokenClient> {
- private TokenClientFactory tcf;
- private final int timeout;
- private final String url,enc_secret;
-
- public TCCreator(PropAccess access) throws CadiException {
- try {
- tcf = TokenClientFactory.instance(access);
- } catch (APIException | GeneralSecurityException | IOException e1) {
- throw new CadiException(e1);
- }
-
- if((url = access.getProperty(Config.AAF_OAUTH2_TOKEN_URL,null))==null) {
- throw new CadiException(Config.AAF_OAUTH2_TOKEN_URL + REQUIRED_FOR_OAUTH2);
- }
-
- try {
- timeout = Integer.parseInt(access.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF));
- } catch (NumberFormatException e) {
- throw new CadiException("Bad format for " + Config.AAF_CONN_TIMEOUT, e);
- }
- if((enc_secret= access.getProperty(Config.AAF_APPPASS,null))==null) {
- throw new CadiException(Config.AAF_APPPASS + REQUIRED_FOR_OAUTH2);
- }
- }
-
- @Override
- public TokenClient create() throws APIException {
- try {
- TokenClient tc = tcf.newClient(url, timeout);
- tc.client_creds(client_id, access.decrypt(enc_secret, true));
- return tc;
- } catch (CadiException | LocatorException | IOException e) {
- throw new APIException(e);
- }
- }
+ private class TCCreator implements Creator<TokenClient> {
+ private TokenClientFactory tcf;
+ private final int timeout;
+ private final String url,enc_secret;
+
+ public TCCreator(PropAccess access) throws CadiException {
+ try {
+ tcf = TokenClientFactory.instance(access);
+ } catch (APIException | GeneralSecurityException | IOException e1) {
+ throw new CadiException(e1);
+ }
+
+ if((url = access.getProperty(Config.AAF_OAUTH2_TOKEN_URL,null))==null) {
+ throw new CadiException(Config.AAF_OAUTH2_TOKEN_URL + REQUIRED_FOR_OAUTH2);
+ }
+
+ try {
+ timeout = Integer.parseInt(access.getProperty(Config.AAF_CONN_TIMEOUT, Config.AAF_CONN_TIMEOUT_DEF));
+ } catch (NumberFormatException e) {
+ throw new CadiException("Bad format for " + Config.AAF_CONN_TIMEOUT, e);
+ }
+ if((enc_secret= access.getProperty(Config.AAF_APPPASS,null))==null) {
+ throw new CadiException(Config.AAF_APPPASS + REQUIRED_FOR_OAUTH2);
+ }
+ }
+
+ @Override
+ public TokenClient create() throws APIException {
+ try {
+ TokenClient tc = tcf.newClient(url, timeout);
+ tc.client_creds(client_id, access.decrypt(enc_secret, true));
+ return tc;
+ } catch (CadiException | LocatorException | IOException e) {
+ throw new APIException(e);
+ }
+ }