@Override
    public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitProcessingException {
        DeploymentUnit deploymentUnit = phaseContext.getDeploymentUnit();
        WarMetaData warMetaData = deploymentUnit.getAttachment(WarMetaData.ATTACHMENT_KEY);
        if (warMetaData == null) {
            return;
        }
        JBossWebMetaData webMetaData = warMetaData.getMergedJBossWebMetaData();
        if (webMetaData == null) {
            webMetaData = new JBossWebMetaData();
            warMetaData.setMergedJBossWebMetaData(webMetaData);
        }

        OidcConfigService configService = OidcConfigService.getInstance();
        boolean subsystemConfigured = configService.isSecureDeployment(deploymentUnit) && configService.isDeploymentConfigured(deploymentUnit);
        if (subsystemConfigured) {
            addOidcAuthDataAndConfig(phaseContext, configService, webMetaData);
        }

        LoginConfigMetaData loginConfig = webMetaData.getLoginConfig();
        if (loginConfig != null && OIDC_AUTH_METHOD.equals(loginConfig.getAuthMethod())) {
            if (! subsystemConfigured) {
                // check for unsupported attributes in the deployment's oidc.json file
                if (deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT) != null) {
                    VirtualFile oidcConfigurationFile = deploymentUnit.getAttachment(Attachments.DEPLOYMENT_ROOT).getRoot().getChild("WEB-INF/oidc.json");
                    if (oidcConfigurationFile.exists()) {
                        try (InputStream is = oidcConfigurationFile.openStream()) {
                            String oidcConfigString = readFromInputStream(is);

                            for (SimpleAttributeDefinition attribute : SecureDeploymentDefinition.NON_DEFAULT_ATTRIBUTES) {
                                if ((!deploymentUnit.enables(attribute)) && oidcConfigString.contains(attribute.getName())) {
                                    throw ROOT_LOGGER.unsupportedAttribute(attribute.getName());
                                }
                            }
                            addJSONDataAsContextParam(oidcConfigString, webMetaData);
                        } catch (IOException e) {
                            throw new RuntimeException(e);
                        }
                    }
                }
            }

            ListenerMetaData listenerMetaData = new ListenerMetaData();
            listenerMetaData.setListenerClass(OidcConfigurationServletListener.class.getName());
            webMetaData.getListeners().add(listenerMetaData);

            ROOT_LOGGER.tracef("Activating OIDC for deployment %s.", deploymentUnit.getName());
            OidcDeploymentMarker.mark(deploymentUnit);
            VirtualHttpServerMechanismFactoryMarkerUtility.virtualMechanismFactoryRequired(deploymentUnit);
        }
    }
@Test
    public void testDeployLoginConfigWithRealmAndNullAuthMethod() throws Exception {
        DeploymentUnit unit = mock(DeploymentUnit.class);
        doReturn(true).when(unit).hasAttachment(WarMetaData.ATTACHMENT_KEY);
        doReturn(new NonNullRealmNullEverythingElseWarMetaData()).when(unit).getAttachment(WarMetaData.ATTACHMENT_KEY);

        DeploymentPhaseContext context = mock(DeploymentPhaseContext.class);
        doReturn(unit).when(context).getDeploymentUnit();

        new OidcActivationProcessor().deploy(context);

        assertTrue("Expect to succeed and reach this point", true);
    }