Examples of ApiKey


Examples of lv.odylab.evemanage.domain.eve.ApiKey

    @Test
    public void testUpdateApiKeysForUser_OneKey_TwoCharacters() throws EveApiException, ApiKeyShouldBeRemovedException {
        Key<User> userKey = new Key<User>(User.class, 1);
        List<ApiKey> apiKeys = new ArrayList<ApiKey>();
        ApiKey apiKey = new ApiKey();
        apiKeys.add(apiKey);
        List<Character> characters = new ArrayList<Character>();
        Character character1 = new Character();
        Character character2 = new Character();
        characters.add(character1);
View Full Code Here

Examples of lv.odylab.evemanage.domain.eve.ApiKey

    @Test
    public void testUpdateApiKeysForUser_OneKey_TwoCharacters_InvalidApiKey() throws EveApiException, ApiKeyShouldBeRemovedException {
        Key<User> userKey = new Key<User>(User.class, 1);
        List<ApiKey> apiKeys = new ArrayList<ApiKey>();
        ApiKey apiKey = new ApiKey();
        apiKeys.add(apiKey);
        apiKey.setCharacterInfos(new ArrayList<ApiKeyCharacterInfo>());
        apiKey.setValid(Boolean.TRUE);
        List<Character> characters = new ArrayList<Character>();
        Character character1 = new Character();
        character1.setCorporationID(1L);
        character1.setCorporationName("corporationName");
        List<String> corporationTitles = new ArrayList<String>();
View Full Code Here

Examples of lv.odylab.evemanage.domain.eve.ApiKey

    }

    @Test
    public void testPopulateCharacterData() throws EveApiException, IOException {
        Key<ApiKey> apiKeyKey = new Key<ApiKey>(ApiKey.class, 1);
        ApiKey apiKey = new ApiKey();
        apiKey.setApiKeyUserID(2L);
        apiKey.setEncodedApiKeyString(Base64.encodeBytes("encryptedApiKey".getBytes()));
        Character character = new Character();
        character.setCharacterID(1L);
        character.setApiKey(apiKeyKey);
        CharacterSheetDto characterSheetDto = new CharacterSheetDto();
        characterSheetDto.setCharacterID(1L);
View Full Code Here

Examples of lv.odylab.evemanage.domain.eve.ApiKey

        verify(apiKeyDao, never()).get(any(Key.class));
    }

    @Test
    public void testPopulateApiKeyData_ValidFull() throws EveApiException, ApiKeyShouldBeRemovedException {
        ApiKey apiKey = new ApiKey();
        apiKey.setApiKeyUserID(1L);
        List<AccountCharacterDto> accountCharacterDtos = new ArrayList<AccountCharacterDto>();
        AccountCharacterDto accountCharacterDto1 = new AccountCharacterDto();
        accountCharacterDto1.setName("character1");
        accountCharacterDto1.setCharacterID(2L);
        accountCharacterDto1.setCorporationName("corporation1");
        accountCharacterDto1.setCorporationID(3L);
        AccountCharacterDto accountCharacterDto2 = new AccountCharacterDto();
        accountCharacterDto2.setName("character2");
        accountCharacterDto2.setCharacterID(4L);
        accountCharacterDto2.setCorporationName("corporation2");
        accountCharacterDto2.setCorporationID(5L);
        accountCharacterDtos.add(accountCharacterDto1);
        accountCharacterDtos.add(accountCharacterDto2);

        when(securityManager.encrypt("apiKeyString".getBytes())).thenReturn("encryptedApiKey".getBytes());
        when(hashCalculator.hashApiKey(1L, "apiKeyString")).thenReturn("apiKeyHash");
        when(eveApiGateway.getApiKeyCharacters("apiKeyString", 1L)).thenReturn(accountCharacterDtos);
        when(eveApiGateway.getAccountBalances("apiKeyString", 1L, 2L)).thenReturn(new ArrayList<AccountBalanceDto>());
        eveApiDataService.populateApiKeyData(apiKey, "apiKeyString");

        assertEquals(Base64.encodeBytes("encryptedApiKey".getBytes()), apiKey.getEncodedApiKeyString());
        assertEquals("apiKeyHash", apiKey.getApiKeyHash());
        List<ApiKeyCharacterInfo> apiKeyCharacterInfos = apiKey.getCharacterInfos();
        assertEquals(2, apiKeyCharacterInfos.size());
        ApiKeyCharacterInfo apiKeyCharacterInfo1 = apiKeyCharacterInfos.get(0);
        assertEquals(Long.valueOf(2), apiKeyCharacterInfo1.getCharacterID());
        assertEquals("character1", apiKeyCharacterInfo1.getName());
        assertEquals(Long.valueOf(3), apiKeyCharacterInfo1.getCorporationID());
        assertEquals("corporation1", apiKeyCharacterInfo1.getCorporationName());
        ApiKeyCharacterInfo apiKeyCharacterInfo2 = apiKeyCharacterInfos.get(1);
        assertEquals(Long.valueOf(4), apiKeyCharacterInfo2.getCharacterID());
        assertEquals("character2", apiKeyCharacterInfo2.getName());
        assertEquals(Long.valueOf(5), apiKeyCharacterInfo2.getCorporationID());
        assertEquals("corporation2", apiKeyCharacterInfo2.getCorporationName());
        assertNotNull(apiKey.getLastCheckDate());
        assertTrue(apiKey.isValid());
        assertEquals("FULL", apiKey.getKeyType());
        assertNotNull(apiKey.getUpdatedDate());
        assertNull(apiKey.getCreatedDate());
    }
View Full Code Here

Examples of lv.odylab.evemanage.domain.eve.ApiKey

        assertNull(apiKey.getCreatedDate());
    }

    @Test
    public void testPopulateApiKeyData_ValidLimitedWithCharacter() throws EveApiException, ApiKeyShouldBeRemovedException {
        ApiKey apiKey = new ApiKey();
        apiKey.setApiKeyUserID(1L);
        List<AccountCharacterDto> accountCharacterDtos = new ArrayList<AccountCharacterDto>();
        AccountCharacterDto accountCharacterDto = new AccountCharacterDto();
        accountCharacterDto.setName("character1");
        accountCharacterDto.setCharacterID(2L);
        accountCharacterDto.setCorporationName("corporation1");
        accountCharacterDto.setCorporationID(3L);
        accountCharacterDtos.add(accountCharacterDto);

        when(securityManager.encrypt("apiKeyString".getBytes())).thenReturn("encryptedApiKey".getBytes());
        when(eveApiGateway.getApiKeyCharacters("apiKeyString", 1L)).thenReturn(accountCharacterDtos);
        when(eveApiGateway.getAccountBalances("apiKeyString", 1L, 2L)).thenThrow(new EveApiException("errorCode"));
        eveApiDataService.populateApiKeyData(apiKey, "apiKeyString");

        assertEquals("LIMITED", apiKey.getKeyType());
    }
View Full Code Here

Examples of lv.odylab.evemanage.domain.eve.ApiKey

        assertEquals("LIMITED", apiKey.getKeyType());
    }

    @Test
    public void testPopulateApiKeyData_ValidLimitedWithoutCharacters() throws EveApiException, ApiKeyShouldBeRemovedException {
        ApiKey apiKey = new ApiKey();
        apiKey.setApiKeyUserID(1L);

        when(securityManager.encrypt("apiKeyString".getBytes())).thenReturn("encryptedApiKey".getBytes());
        when(eveApiGateway.getApiKeyCharacters("apiKeyString", 1L)).thenReturn(new ArrayList<AccountCharacterDto>());
        eveApiDataService.populateApiKeyData(apiKey, "apiKeyString");

        assertEquals("LIMITED", apiKey.getKeyType());
    }
View Full Code Here

Examples of lv.odylab.evemanage.domain.eve.ApiKey

        assertEquals("LIMITED", apiKey.getKeyType());
    }

    @Test
    public void testPopulateApiKeyData_ExistingKey() throws EveApiException, ApiKeyShouldBeRemovedException {
        ApiKey apiKey = new ApiKey();
        apiKey.setApiKeyUserID(1L);
        String encodedApiKeyString = Base64.encodeBytes("encryptedApiKey".getBytes());
        apiKey.setEncodedApiKeyString(encodedApiKeyString);
        apiKey.setApiKeyHash("apiKeyHash");
        apiKey.setKeyType("FULL");

        when(securityManager.decrypt("encryptedApiKey".getBytes())).thenReturn("apiKeyString".getBytes());
        when(eveApiGateway.getApiKeyCharacters("apiKeyString", 1L)).thenReturn(new ArrayList<AccountCharacterDto>());
        eveApiDataService.populateApiKeyData(apiKey);

        assertEquals(encodedApiKeyString, apiKey.getEncodedApiKeyString());
        assertEquals("apiKeyHash", apiKey.getApiKeyHash());
        assertEquals("FULL", apiKey.getKeyType());
    }
View Full Code Here

Examples of lv.odylab.evemanage.domain.eve.ApiKey

        List<Character> detachedCharacters = new ArrayList<Character>();
        List<Character> updatedCharacters = new ArrayList<Character>();
        for (Character character : characters) {
            logger.info("Updating character: {} ({})", character.getName(), character.getCharacterID());
            String previousHash = createCharacterHash(character);
            ApiKey apiKey = characterIdToApiKeyMap.get(character.getCharacterID());
            if (apiKey != null) {
                logger.debug("Character does not have valid API key, will be detached");
                character.setApiKey(new Key<ApiKey>(ApiKey.class, apiKey.getId()));
                eveApiDataService.populateCharacterData(character);
                if (!createCharacterHash(character).equals(previousHash)) {
                    updatedCharacters.add(character);
                }
            } else {
View Full Code Here

Examples of lv.odylab.evemanage.domain.eve.ApiKey

        }
    }

    @Override
    public void importBlueprintsUsingFullApiKey(Long characterID, String level, Long attachedCharacterID, String sharingLevel, Key<User> userKey) throws EveApiException {
        ApiKey fullApiKey = apiKeyDao.getFullForCharacterID(characterID, userKey);
        String fullApiKeyString;
        try {
            byte[] decodedApiKeyBytes = Base64.decode(fullApiKey.getEncodedApiKeyString());
            byte[] decryptedApiKeyBytes = securityManager.decrypt(decodedApiKeyBytes);
            fullApiKeyString = new String(decryptedApiKeyBytes);
        } catch (IOException e) {
            throw new EveManageSecurityException(e);
        }

        if ("CHARACTER".equals(level)) {
            proceedIndustryJobImport(eveApiGateway.getCharacterIndustryJobs(fullApiKeyString, fullApiKey.getApiKeyUserID(), characterID), attachedCharacterID, sharingLevel, userKey);
        } else {
            proceedIndustryJobImport(eveApiGateway.getCorporationIndustryJobs(fullApiKey.getEncodedApiKeyString(), fullApiKey.getApiKeyUserID(), characterID), attachedCharacterID, sharingLevel, userKey);
        }
    }
View Full Code Here

Examples of lv.odylab.evemanage.domain.eve.ApiKey

        Key<ApiKey> apiKeyKey = character.getApiKey();
        if (apiKeyKey == null) {
            logger.debug("Character does not have api key, skipping");
            return;
        }
        ApiKey apiKey;
        try {
            apiKey = apiKeyDao.get(apiKeyKey);
        } catch (NotFoundException e) {
            logger.error("Caught NotFoundException", e);
            logger.error("Api key was not found in datastore despite character having reference to it, this is inconsistency, character: {} ({})", character.getName(), character.getCharacterID());
            throw new EveApiException("Character has invalid api key");
        }

        CharacterSheetDto characterSheetDto = eveApiGateway.getCharacterSheet(decodeApiKeyString(apiKey.getEncodedApiKeyString()), apiKey.getApiKeyUserID(), character.getCharacterID());
        CorporationSheetDto corporationSheetDto = eveApiGateway.getCorporationSheet(characterSheetDto.getCorporationID());
        character.setName(characterSheetDto.getName());
        character.setCorporationID(characterSheetDto.getCorporationID());
        character.setCorporationName(characterSheetDto.getCorporationName());
        character.setCorporationTitles(characterSheetDto.getCorporationTitles());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.