@Test public void initializePartialServerCodeAndSoftToken() throws Exception { when(serverConfService.isServerCodeInitialized()).thenReturn(false); when(serverConfService.isServerOwnerInitialized()).thenReturn(true); when(tokenService.isSoftwareTokenInitialized()).thenReturn(false); initializationService.initialize(SECURITY_SERVER_CODE, null, null, SOFTWARE_TOKEN_PIN, true); assertTrue(true); }
public void initialize(String securityServerCode, String ownerMemberClass, String ownerMemberCode, String softwareTokenPin, boolean ignoreWarnings) throws AnchorNotFoundException, WeakPinException, UnhandledWarningsException, InvalidCharactersException, SoftwareTokenInitException, InvalidInitParamsException, ServerAlreadyFullyInitializedException { if (!systemService.isAnchorImported()) { throw new AnchorNotFoundException("Configuration anchor was not found."); } boolean isServerCodeInitialized = serverConfService.isServerCodeInitialized(); boolean isServerOwnerInitialized = serverConfService.isServerOwnerInitialized(); boolean isSoftwareTokenInitialized = tokenService.isSoftwareTokenInitialized(); if (isServerCodeInitialized && isServerOwnerInitialized && isSoftwareTokenInitialized) { throw new ServerAlreadyFullyInitializedException("Security server has already been fully initialized"); } verifyInitializationPrerequisites(securityServerCode, ownerMemberClass, ownerMemberCode, softwareTokenPin, isServerCodeInitialized, isServerOwnerInitialized, isSoftwareTokenInitialized); String instanceIdentifier = globalConfFacade.getInstanceIdentifier(); ClientId ownerClientId = null; if (isServerOwnerInitialized) { ownerClientId = serverConfService.getSecurityServerOwnerId(); } else { ownerClientId = ClientId.create(instanceIdentifier, ownerMemberClass, ownerMemberCode); } auditDataHelper.put(OWNER_IDENTIFIER, ownerClientId); auditDataHelper.put(SERVER_CODE, securityServerCode); if (!ignoreWarnings) { checkForWarnings(ownerClientId, securityServerCode); } ServerConfType serverConf = createInitialServerConf(ownerClientId, securityServerCode); if (!isSoftwareTokenInitialized) { initializeSoftwareToken(softwareTokenPin); } serverConfService.saveOrUpdate(serverConf); }
InitializationService { public void initialize(String securityServerCode, String ownerMemberClass, String ownerMemberCode, String softwareTokenPin, boolean ignoreWarnings) throws AnchorNotFoundException, WeakPinException, UnhandledWarningsException, InvalidCharactersException, SoftwareTokenInitException, InvalidInitParamsException, ServerAlreadyFullyInitializedException { if (!systemService.isAnchorImported()) { throw new AnchorNotFoundException("Configuration anchor was not found."); } boolean isServerCodeInitialized = serverConfService.isServerCodeInitialized(); boolean isServerOwnerInitialized = serverConfService.isServerOwnerInitialized(); boolean isSoftwareTokenInitialized = tokenService.isSoftwareTokenInitialized(); if (isServerCodeInitialized && isServerOwnerInitialized && isSoftwareTokenInitialized) { throw new ServerAlreadyFullyInitializedException("Security server has already been fully initialized"); } verifyInitializationPrerequisites(securityServerCode, ownerMemberClass, ownerMemberCode, softwareTokenPin, isServerCodeInitialized, isServerOwnerInitialized, isSoftwareTokenInitialized); String instanceIdentifier = globalConfFacade.getInstanceIdentifier(); ClientId ownerClientId = null; if (isServerOwnerInitialized) { ownerClientId = serverConfService.getSecurityServerOwnerId(); } else { ownerClientId = ClientId.create(instanceIdentifier, ownerMemberClass, ownerMemberCode); } auditDataHelper.put(OWNER_IDENTIFIER, ownerClientId); auditDataHelper.put(SERVER_CODE, securityServerCode); if (!ignoreWarnings) { checkForWarnings(ownerClientId, securityServerCode); } ServerConfType serverConf = createInitialServerConf(ownerClientId, securityServerCode); if (!isSoftwareTokenInitialized) { initializeSoftwareToken(softwareTokenPin); } serverConfService.saveOrUpdate(serverConf); } }
InitializationService { public void initialize(String securityServerCode, String ownerMemberClass, String ownerMemberCode, String softwareTokenPin, boolean ignoreWarnings) throws AnchorNotFoundException, WeakPinException, UnhandledWarningsException, InvalidCharactersException, SoftwareTokenInitException, InvalidInitParamsException, ServerAlreadyFullyInitializedException { if (!systemService.isAnchorImported()) { throw new AnchorNotFoundException("Configuration anchor was not found."); } boolean isServerCodeInitialized = serverConfService.isServerCodeInitialized(); boolean isServerOwnerInitialized = serverConfService.isServerOwnerInitialized(); boolean isSoftwareTokenInitialized = tokenService.isSoftwareTokenInitialized(); if (isServerCodeInitialized && isServerOwnerInitialized && isSoftwareTokenInitialized) { throw new ServerAlreadyFullyInitializedException("Security server has already been fully initialized"); } verifyInitializationPrerequisites(securityServerCode, ownerMemberClass, ownerMemberCode, softwareTokenPin, isServerCodeInitialized, isServerOwnerInitialized, isSoftwareTokenInitialized); String instanceIdentifier = globalConfFacade.getInstanceIdentifier(); ClientId ownerClientId = null; if (isServerOwnerInitialized) { ownerClientId = serverConfService.getSecurityServerOwnerId(); } else { ownerClientId = ClientId.create(instanceIdentifier, ownerMemberClass, ownerMemberCode); } auditDataHelper.put(OWNER_IDENTIFIER, ownerClientId); auditDataHelper.put(SERVER_CODE, securityServerCode); if (!ignoreWarnings) { checkForWarnings(ownerClientId, securityServerCode); } ServerConfType serverConf = createInitialServerConf(ownerClientId, securityServerCode); if (!isSoftwareTokenInitialized) { initializeSoftwareToken(softwareTokenPin); } serverConfService.saveOrUpdate(serverConf); } @Autowired  InitializationService(SystemService systemService, ServerConfService serverConfService,
            TokenService tokenService, GlobalConfFacade globalConfFacade, ClientService clientService,
            SignerProxyFacade signerProxyFacade, AuditDataHelper auditDataHelper); }
InitializationService { public void initialize(String securityServerCode, String ownerMemberClass, String ownerMemberCode, String softwareTokenPin, boolean ignoreWarnings) throws AnchorNotFoundException, WeakPinException, UnhandledWarningsException, InvalidCharactersException, SoftwareTokenInitException, InvalidInitParamsException, ServerAlreadyFullyInitializedException { if (!systemService.isAnchorImported()) { throw new AnchorNotFoundException("Configuration anchor was not found."); } boolean isServerCodeInitialized = serverConfService.isServerCodeInitialized(); boolean isServerOwnerInitialized = serverConfService.isServerOwnerInitialized(); boolean isSoftwareTokenInitialized = tokenService.isSoftwareTokenInitialized(); if (isServerCodeInitialized && isServerOwnerInitialized && isSoftwareTokenInitialized) { throw new ServerAlreadyFullyInitializedException("Security server has already been fully initialized"); } verifyInitializationPrerequisites(securityServerCode, ownerMemberClass, ownerMemberCode, softwareTokenPin, isServerCodeInitialized, isServerOwnerInitialized, isSoftwareTokenInitialized); String instanceIdentifier = globalConfFacade.getInstanceIdentifier(); ClientId ownerClientId = null; if (isServerOwnerInitialized) { ownerClientId = serverConfService.getSecurityServerOwnerId(); } else { ownerClientId = ClientId.create(instanceIdentifier, ownerMemberClass, ownerMemberCode); } auditDataHelper.put(OWNER_IDENTIFIER, ownerClientId); auditDataHelper.put(SERVER_CODE, securityServerCode); if (!ignoreWarnings) { checkForWarnings(ownerClientId, securityServerCode); } ServerConfType serverConf = createInitialServerConf(ownerClientId, securityServerCode); if (!isSoftwareTokenInitialized) { initializeSoftwareToken(softwareTokenPin); } serverConfService.saveOrUpdate(serverConf); } @Autowired  InitializationService(SystemService systemService, ServerConfService serverConfService,
            TokenService tokenService, GlobalConfFacade globalConfFacade, ClientService clientService,
            SignerProxyFacade signerProxyFacade, AuditDataHelper auditDataHelper); InitializationStatusDto getSecurityServerInitializationStatus(); void initialize(String securityServerCode, String ownerMemberClass, String ownerMemberCode,
            String softwareTokenPin, boolean ignoreWarnings); }
InitializationService { public void initialize(String securityServerCode, String ownerMemberClass, String ownerMemberCode, String softwareTokenPin, boolean ignoreWarnings) throws AnchorNotFoundException, WeakPinException, UnhandledWarningsException, InvalidCharactersException, SoftwareTokenInitException, InvalidInitParamsException, ServerAlreadyFullyInitializedException { if (!systemService.isAnchorImported()) { throw new AnchorNotFoundException("Configuration anchor was not found."); } boolean isServerCodeInitialized = serverConfService.isServerCodeInitialized(); boolean isServerOwnerInitialized = serverConfService.isServerOwnerInitialized(); boolean isSoftwareTokenInitialized = tokenService.isSoftwareTokenInitialized(); if (isServerCodeInitialized && isServerOwnerInitialized && isSoftwareTokenInitialized) { throw new ServerAlreadyFullyInitializedException("Security server has already been fully initialized"); } verifyInitializationPrerequisites(securityServerCode, ownerMemberClass, ownerMemberCode, softwareTokenPin, isServerCodeInitialized, isServerOwnerInitialized, isSoftwareTokenInitialized); String instanceIdentifier = globalConfFacade.getInstanceIdentifier(); ClientId ownerClientId = null; if (isServerOwnerInitialized) { ownerClientId = serverConfService.getSecurityServerOwnerId(); } else { ownerClientId = ClientId.create(instanceIdentifier, ownerMemberClass, ownerMemberCode); } auditDataHelper.put(OWNER_IDENTIFIER, ownerClientId); auditDataHelper.put(SERVER_CODE, securityServerCode); if (!ignoreWarnings) { checkForWarnings(ownerClientId, securityServerCode); } ServerConfType serverConf = createInitialServerConf(ownerClientId, securityServerCode); if (!isSoftwareTokenInitialized) { initializeSoftwareToken(softwareTokenPin); } serverConfService.saveOrUpdate(serverConf); } @Autowired  InitializationService(SystemService systemService, ServerConfService serverConfService,
            TokenService tokenService, GlobalConfFacade globalConfFacade, ClientService clientService,
            SignerProxyFacade signerProxyFacade, AuditDataHelper auditDataHelper); InitializationStatusDto getSecurityServerInitializationStatus(); void initialize(String securityServerCode, String ownerMemberClass, String ownerMemberCode,
            String softwareTokenPin, boolean ignoreWarnings); static final String WARNING_INIT_UNREGISTERED_MEMBER; static final String WARNING_INIT_SERVER_ID_EXISTS; static final String WARNING_SERVERCODE_EXISTS; static final String WARNING_SERVER_OWNER_EXISTS; static final String WARNING_SOFTWARE_TOKEN_INITIALIZED; static final String METADATA_PIN_MIN_LENGTH; static final String METADATA_PIN_MIN_CHAR_CLASSES; static final String ERROR_METADATA_SERVERCODE_NOT_PROVIDED; static final String ERROR_METADATA_MEMBER_CLASS_NOT_PROVIDED; static final String ERROR_METADATA_MEMBER_CODE_NOT_PROVIDED; static final String ERROR_METADATA_PIN_NOT_PROVIDED; static final String ERROR_METADATA_SERVERCODE_EXISTS; static final String ERROR_METADATA_MEMBER_CLASS_EXISTS; static final String ERROR_METADATA_MEMBER_CODE_EXISTS; static final String ERROR_METADATA_PIN_EXISTS; }