@Test public void getKey() throws Exception { try { keyService.getKey(KEY_NOT_FOUND_KEY_ID); } catch (KeyNotFoundException expected) { } KeyInfo keyInfo = keyService.getKey(AUTH_KEY_ID); assertEquals(AUTH_KEY_ID, keyInfo.getId()); }
public KeyInfo getKey(String keyId) throws KeyNotFoundException { Collection<TokenInfo> tokens = tokenService.getAllTokens(); Optional<KeyInfo> keyInfo = tokens.stream() .map(TokenInfo::getKeyInfo) .flatMap(List::stream) .filter(key -> keyId.equals(key.getId())) .findFirst(); if (!keyInfo.isPresent()) { throw new KeyNotFoundException("key with id " + keyId + " not found"); } return keyInfo.get(); }
KeyService { public KeyInfo getKey(String keyId) throws KeyNotFoundException { Collection<TokenInfo> tokens = tokenService.getAllTokens(); Optional<KeyInfo> keyInfo = tokens.stream() .map(TokenInfo::getKeyInfo) .flatMap(List::stream) .filter(key -> keyId.equals(key.getId())) .findFirst(); if (!keyInfo.isPresent()) { throw new KeyNotFoundException("key with id " + keyId + " not found"); } return keyInfo.get(); } }
KeyService { public KeyInfo getKey(String keyId) throws KeyNotFoundException { Collection<TokenInfo> tokens = tokenService.getAllTokens(); Optional<KeyInfo> keyInfo = tokens.stream() .map(TokenInfo::getKeyInfo) .flatMap(List::stream) .filter(key -> keyId.equals(key.getId())) .findFirst(); if (!keyInfo.isPresent()) { throw new KeyNotFoundException("key with id " + keyId + " not found"); } return keyInfo.get(); } @Autowired  KeyService(TokenService tokenService, SignerProxyFacade signerProxyFacade,
            PossibleActionsRuleEngine possibleActionsRuleEngine,
            ManagementRequestSenderService managementRequestSenderService,
            SecurityHelper securityHelper,
            AuditDataHelper auditDataHelper,
            AuditEventHelper auditEventHelper,
            AuditEventLoggingFacade auditEventLoggingFacade); }
KeyService { public KeyInfo getKey(String keyId) throws KeyNotFoundException { Collection<TokenInfo> tokens = tokenService.getAllTokens(); Optional<KeyInfo> keyInfo = tokens.stream() .map(TokenInfo::getKeyInfo) .flatMap(List::stream) .filter(key -> keyId.equals(key.getId())) .findFirst(); if (!keyInfo.isPresent()) { throw new KeyNotFoundException("key with id " + keyId + " not found"); } return keyInfo.get(); } @Autowired  KeyService(TokenService tokenService, SignerProxyFacade signerProxyFacade,
            PossibleActionsRuleEngine possibleActionsRuleEngine,
            ManagementRequestSenderService managementRequestSenderService,
            SecurityHelper securityHelper,
            AuditDataHelper auditDataHelper,
            AuditEventHelper auditEventHelper,
            AuditEventLoggingFacade auditEventLoggingFacade); KeyInfo getKey(String keyId); KeyInfo getKey(TokenInfo tokenInfo, String keyId); KeyInfo updateKeyFriendlyName(String id, String friendlyName); KeyInfo addKey(String tokenId, String keyLabel); void deleteKeyAndIgnoreWarnings(String keyId); void deleteKey(String keyId, Boolean ignoreWarnings); EnumSet<PossibleActionEnum> getPossibleActionsForKey(String keyId); }
KeyService { public KeyInfo getKey(String keyId) throws KeyNotFoundException { Collection<TokenInfo> tokens = tokenService.getAllTokens(); Optional<KeyInfo> keyInfo = tokens.stream() .map(TokenInfo::getKeyInfo) .flatMap(List::stream) .filter(key -> keyId.equals(key.getId())) .findFirst(); if (!keyInfo.isPresent()) { throw new KeyNotFoundException("key with id " + keyId + " not found"); } return keyInfo.get(); } @Autowired  KeyService(TokenService tokenService, SignerProxyFacade signerProxyFacade,
            PossibleActionsRuleEngine possibleActionsRuleEngine,
            ManagementRequestSenderService managementRequestSenderService,
            SecurityHelper securityHelper,
            AuditDataHelper auditDataHelper,
            AuditEventHelper auditEventHelper,
            AuditEventLoggingFacade auditEventLoggingFacade); KeyInfo getKey(String keyId); KeyInfo getKey(TokenInfo tokenInfo, String keyId); KeyInfo updateKeyFriendlyName(String id, String friendlyName); KeyInfo addKey(String tokenId, String keyLabel); void deleteKeyAndIgnoreWarnings(String keyId); void deleteKey(String keyId, Boolean ignoreWarnings); EnumSet<PossibleActionEnum> getPossibleActionsForKey(String keyId); static final String WARNING_AUTH_KEY_REGISTERED_CERT_DETECTED; }