Search in sources :

Example 11 with CommonsHashSet

use of com.helger.commons.collection.impl.CommonsHashSet in project phoss-smp by phax.

the class PageSecureTransportProfiles method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPTransportProfileManager aTransportProfileMgr = SMPMetaManager.getTransportProfileMgr();
    aNodeList.addChild(info("This page lets you create custom transport profiles that can be used in service information endpoints."));
    final ICommonsList<ISMPTransportProfile> aList = aTransportProfileMgr.getAllSMPTransportProfiles();
    final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
    aToolbar.addChild(new BootstrapButton().addChild("Create new transport profile").setOnClick(createCreateURL(aWPEC)).setIcon(EDefaultIcon.NEW));
    final ICommonsSet<String> aExistingIDs = new CommonsHashSet<>(aList, ISMPTransportProfile::getID);
    if (!aExistingIDs.containsAll(DEFAULT_PROFILE_IDS)) {
        // Show button only on demand
        aToolbar.addChild(new BootstrapButton().addChild("Ensure all default transport profiles").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_ENSURE_DEFAULT)).setIcon(EDefaultIcon.PLUS));
    }
    aNodeList.addChild(aToolbar);
    final HCTable aTable = new HCTable(new DTCol("ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Name"), new DTCol("Deprecated?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final ISMPTransportProfile aCurObject : aList) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getID()));
        aRow.addCell(aCurObject.getName());
        aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isDeprecated(), aDisplayLocale));
        aRow.addCell(createEditLink(aWPEC, aCurObject, "Edit " + aCurObject.getID()), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject, "Copy " + aCurObject.getID()), new HCTextNode(" "), isActionAllowed(aWPEC, EWebPageFormAction.DELETE, aCurObject) ? createDeleteLink(aWPEC, aCurObject, "Delete " + aCurObject.getID()) : createEmptyAction());
    }
    final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
    aNodeList.addChild(aTable).addChild(aDataTables);
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) HCTable(com.helger.html.hc.html.tabular.HCTable) ISMPTransportProfileManager(com.helger.phoss.smp.domain.transportprofile.ISMPTransportProfileManager) ISMPTransportProfile(com.helger.peppol.smp.ISMPTransportProfile) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) HCTextNode(com.helger.html.hc.impl.HCTextNode) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) DataTables(com.helger.photon.uictrls.datatables.DataTables) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)

Example 12 with CommonsHashSet

use of com.helger.commons.collection.impl.CommonsHashSet in project phase4 by phax.

the class MainVerifySignature method _verifyAndDecrypt.

@Nonnull
private static ESuccess _verifyAndDecrypt(@Nonnull final IAS4CryptoFactory aCryptoFactory, @Nonnull final Document aSOAPDoc, @Nonnull final Locale aLocale, @Nonnull final AS4ResourceHelper aResHelper, @Nonnull final ICommonsList<WSS4JAttachment> aAttachments, @Nonnull final ErrorList aErrorList, @Nonnull final Supplier<WSSConfig> aWSSConfigSupplier) {
    // Signing verification and Decryption
    try {
        // Convert to WSS4J attachments
        final Phase4KeyStoreCallbackHandler aKeyStoreCallback = new Phase4KeyStoreCallbackHandler(aCryptoFactory);
        final WSS4JAttachmentCallbackHandler aAttachmentCallbackHandler = new WSS4JAttachmentCallbackHandler(aAttachments, aResHelper);
        // Resolve the WSS config here to ensure the context matches
        final WSSConfig aWSSConfig = aWSSConfigSupplier.get();
        // Configure RequestData needed for the check / decrypt process!
        final RequestData aRequestData = new RequestData();
        aRequestData.setCallbackHandler(aKeyStoreCallback);
        if (aAttachments.isNotEmpty())
            aRequestData.setAttachmentCallbackHandler(aAttachmentCallbackHandler);
        aRequestData.setSigVerCrypto(aCryptoFactory.getCrypto());
        aRequestData.setDecCrypto(aCryptoFactory.getCrypto());
        aRequestData.setWssConfig(aWSSConfig);
        // Upon success, the SOAP document contains the decrypted content
        // afterwards!
        final WSSecurityEngine aSecurityEngine = new WSSecurityEngine();
        aSecurityEngine.setWssConfig(aWSSConfig);
        final WSHandlerResult aHdlRes = aSecurityEngine.processSecurityHeader(aSOAPDoc, aRequestData);
        final List<WSSecurityEngineResult> aResults = aHdlRes.getResults();
        // Collect all unique used certificates
        final ICommonsSet<X509Certificate> aCertSet = new CommonsHashSet<>();
        // Preferred certificate from BinarySecurityToken
        X509Certificate aPreferredCert = null;
        int nWSS4JSecurityActions = 0;
        for (final WSSecurityEngineResult aResult : aResults) {
            if (LOGGER.isDebugEnabled())
                LOGGER.debug("WSSecurityEngineResult: " + aResult);
            final Integer aAction = (Integer) aResult.get(WSSecurityEngineResult.TAG_ACTION);
            final int nAction = aAction != null ? aAction.intValue() : 0;
            nWSS4JSecurityActions |= nAction;
            final X509Certificate aCert = (X509Certificate) aResult.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
            if (aCert != null) {
                aCertSet.add(aCert);
                if (nAction == WSConstants.BST && aPreferredCert == null)
                    aPreferredCert = aCert;
            }
        }
        // this determines if a signature check or a decryption happened
        final X509Certificate aUsedCert;
        if (aCertSet.size() > 1) {
            if (aPreferredCert == null) {
                LOGGER.warn("Found " + aCertSet.size() + " different certificates in message. Using the first one.");
                if (LOGGER.isDebugEnabled())
                    LOGGER.debug("All gathered certificates: " + aCertSet);
                aUsedCert = aCertSet.getAtIndex(0);
            } else
                aUsedCert = aPreferredCert;
        } else if (aCertSet.size() == 1)
            aUsedCert = aCertSet.getAtIndex(0);
        else
            aUsedCert = null;
        // Remember in State
        // Decrypting the Attachments
        final ICommonsList<WSS4JAttachment> aResponseAttachments = aAttachmentCallbackHandler.getAllResponseAttachments();
        for (final WSS4JAttachment aResponseAttachment : aResponseAttachments) {
            // Always copy to a temporary file, so that decrypted content can be
            // read more than once. By default the stream can only be read once
            // Not nice, but working :)
            final File aTempFile = aResHelper.createTempFile();
            StreamHelper.copyInputStreamToOutputStreamAndCloseOS(aResponseAttachment.getSourceStream(), FileHelper.getBufferedOutputStream(aTempFile));
            aResponseAttachment.setSourceStreamProvider(HasInputStream.multiple(() -> FileHelper.getBufferedInputStream(aTempFile)));
        }
        // Remember in State
        return ESuccess.SUCCESS;
    } catch (final IndexOutOfBoundsException | IllegalStateException | WSSecurityException ex) {
        // Decryption or Signature check failed
        LOGGER.error("Error processing the WSSSecurity Header", ex);
        // TODO we need a way to distinct
        // signature and decrypt WSSecurityException provides no such thing
        aErrorList.add(EEbmsError.EBMS_FAILED_DECRYPTION.getAsError(aLocale));
        return ESuccess.FAILURE;
    } catch (final IOException ex) {
        // Decryption or Signature check failed
        LOGGER.error("IO error processing the WSSSecurity Header", ex);
        aErrorList.add(EEbmsError.EBMS_OTHER.getAsError(aLocale));
        return ESuccess.FAILURE;
    }
}
Also used : WSS4JAttachmentCallbackHandler(com.helger.phase4.attachment.WSS4JAttachmentCallbackHandler) WSSecurityException(org.apache.wss4j.common.ext.WSSecurityException) IOException(java.io.IOException) WSHandlerResult(org.apache.wss4j.dom.handler.WSHandlerResult) WSSecurityEngineResult(org.apache.wss4j.dom.engine.WSSecurityEngineResult) X509Certificate(java.security.cert.X509Certificate) WSSConfig(org.apache.wss4j.dom.engine.WSSConfig) RequestData(org.apache.wss4j.dom.handler.RequestData) WSSecurityEngine(org.apache.wss4j.dom.engine.WSSecurityEngine) Phase4KeyStoreCallbackHandler(com.helger.phase4.servlet.soap.Phase4KeyStoreCallbackHandler) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) File(java.io.File) WSS4JAttachment(com.helger.phase4.attachment.WSS4JAttachment) Nonnull(javax.annotation.Nonnull)

Example 13 with CommonsHashSet

use of com.helger.commons.collection.impl.CommonsHashSet in project peppol-commons by phax.

the class MainCreatePredefinedEnumsFromXML_v8x method _handleProcessIdentifiers.

private static void _handleProcessIdentifiers(final Document aProcessSheet) {
    final PCLProcessesType aList = new GenericJAXBMarshaller<>(PCLProcessesType.class, new QName("dummy")).read(aProcessSheet);
    final ICommonsSet<String> aAllShortcutNames = new CommonsHashSet<>();
    // Create Java source
    try {
        final JDefinedClass jEnum = CM._package(RESULT_PACKAGE_PREFIX + "process")._enum("EPredefinedProcessIdentifier")._implements(IPeppolPredefinedProcessIdentifier.class);
        jEnum.annotate(CodingStyleguideUnaware.class);
        jEnum.javadoc().add(DO_NOT_EDIT);
        // Add metadata
        jEnum.field(JMod.PUBLIC_STATIC_FINAL, CM.ref(String.class), "CODE_LIST_VERSION", JExpr.lit(aList.getVersion()));
        jEnum.field(JMod.PUBLIC_STATIC_FINAL, CM.INT, "CODE_LIST_ENTRY_COUNT", JExpr.lit(aList.getEntryCount().intValue()));
        // enum constants
        for (final PCLProcessType aRow : aList.getProcess()) {
            final String sScheme = aRow.getScheme();
            final String sValue = aRow.getValue();
            final EPeppolCodeListItemState eState = _getState(aRow.getState());
            final boolean bDeprecated = !eState.isActive();
            // Prepend the scheme, if it is non-default
            final String sIDPrefix = PeppolIdentifierHelper.DEFAULT_PROCESS_SCHEME.equals(sScheme) ? "" : sScheme + "-";
            final String sEnumConstName = RegExHelper.getAsIdentifier(sIDPrefix + sValue);
            final JEnumConstant jEnumConst = jEnum.enumConstant(sEnumConstName);
            jEnumConst.arg(JExpr.lit(sScheme));
            jEnumConst.arg(JExpr.lit(sValue));
            jEnumConst.arg(CM.ref(EPeppolCodeListItemState.class).enumConstantRef(eState));
            jEnumConst.javadoc().add("ID: <code>" + sScheme + "::" + sValue + "</code><br>");
            if (bDeprecated) {
                jEnumConst.annotate(Deprecated.class);
                jEnumConst.javadoc().addDeprecated().add("This item should not be used to issue new identifiers!");
            }
            // Also create a shortcut for more readable names
            final String sShortcutName = CodeGenerationHelper.createShortcutProcess(sScheme, sValue);
            if (sShortcutName != null) {
                // Make unique name
                int nNext = 2;
                String sRealShortcutName = sShortcutName;
                while (!aAllShortcutNames.add(sRealShortcutName)) {
                    sRealShortcutName = sShortcutName + nNext;
                    nNext++;
                }
                final JFieldVar aShortcut = jEnum.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, jEnum, sRealShortcutName, jEnumConst);
                aShortcut.javadoc().add("Same as {@link #" + sEnumConstName + "}");
                if (bDeprecated) {
                    aShortcut.annotate(Deprecated.class);
                    aShortcut.javadoc().addDeprecated().add("This item should not be used to issue new identifiers!");
                }
                jEnumConst.javadoc().add("\nSame as {@link #" + sRealShortcutName + "}");
            }
        }
        {
            // Deprecated names
            final JFieldVar aShortcut = jEnum.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, jEnum, "BIS5A_V3", jEnum.fields().get("BIS3_BILLING"));
            aShortcut.annotate(Deprecated.class);
            aShortcut.javadoc().addDeprecated().add("Use BIS3_BILLING instead!");
        }
        // fields
        final JFieldVar fScheme = jEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "m_sScheme");
        final JFieldVar fValue = jEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "m_sValue");
        final JFieldVar fState = jEnum.field(JMod.PRIVATE | JMod.FINAL, EPeppolCodeListItemState.class, "m_eState");
        // Constructor
        final JMethod jCtor = jEnum.constructor(0);
        final JVar jScheme = jCtor.param(JMod.FINAL, String.class, "sScheme");
        jScheme.annotate(Nonnull.class);
        jScheme.annotate(Nonempty.class);
        final JVar jValue = jCtor.param(JMod.FINAL, String.class, "sValue");
        jValue.annotate(Nonnull.class);
        jValue.annotate(Nonempty.class);
        final JVar jState = jCtor.param(JMod.FINAL, EPeppolCodeListItemState.class, "eState");
        jState.annotate(Nonnull.class);
        jCtor.body().assign(fScheme, jScheme).assign(fValue, jValue).assign(fState, jState);
        // public String getScheme ()
        JMethod m = jEnum.method(JMod.PUBLIC, String.class, "getScheme");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fScheme);
        // public String getValue ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getValue");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fValue);
        // public EPeppolCodeListItemState getState ()
        m = jEnum.method(JMod.PUBLIC, EPeppolCodeListItemState.class, "getState");
        m.annotate(Nonnull.class);
        m.body()._return(fState);
        // public PeppolProcessIdentifier getAsProcessIdentifier ()
        m = jEnum.method(JMod.PUBLIC, PeppolProcessIdentifier.class, "getAsProcessIdentifier");
        m.annotate(Nonnull.class);
        m.body()._return(JExpr._new(CM.ref(PeppolProcessIdentifier.class)).arg(JExpr._this()));
        // @Nullable public static EPredefinedProcessIdentifier
        // getFromProcessIdentifierOrNull(@Nullable final IProcessIdentifier
        // aProcessID)
        m = jEnum.method(JMod.PUBLIC | JMod.STATIC, jEnum, "getFromProcessIdentifierOrNull");
        {
            m.annotate(Nullable.class);
            final JVar jParam = m.param(JMod.FINAL, IProcessIdentifier.class, "aProcessID");
            jParam.annotate(Nullable.class);
            final JBlock jIf = m.body()._if(jParam.neNull())._then();
            final JForEach jForEach = jIf.forEach(jEnum, "e", jEnum.staticInvoke("values"));
            jForEach.body()._if(jForEach.var().invoke("hasScheme").arg(jParam.invoke("getScheme")).cand(jForEach.var().invoke("hasValue").arg(jParam.invoke("getValue"))))._then()._return(jForEach.var());
            m.body()._return(JExpr._null());
        }
    } catch (final JCodeModelException ex) {
        LOGGER.warn("Failed to create source", ex);
    }
}
Also used : PCLProcessType(com.helger.xsds.peppol.codelists2.PCLProcessType) JDefinedClass(com.helger.jcodemodel.JDefinedClass) QName(javax.xml.namespace.QName) PeppolProcessIdentifier(com.helger.peppolid.peppol.process.PeppolProcessIdentifier) IProcessIdentifier(com.helger.peppolid.IProcessIdentifier) EPeppolCodeListItemState(com.helger.peppolid.peppol.EPeppolCodeListItemState) JEnumConstant(com.helger.jcodemodel.JEnumConstant) JFieldVar(com.helger.jcodemodel.JFieldVar) JBlock(com.helger.jcodemodel.JBlock) JMethod(com.helger.jcodemodel.JMethod) JForEach(com.helger.jcodemodel.JForEach) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) Nullable(javax.annotation.Nullable) JCodeModelException(com.helger.jcodemodel.JCodeModelException) PCLProcessesType(com.helger.xsds.peppol.codelists2.PCLProcessesType) JVar(com.helger.jcodemodel.JVar)

Example 14 with CommonsHashSet

use of com.helger.commons.collection.impl.CommonsHashSet in project peppol-commons by phax.

the class MainCreatePredefinedEnumsFromXML_v8x method _handleTransportProfileIdentifiers.

private static void _handleTransportProfileIdentifiers(final Document aTPSheet) {
    final PCLTransportProfilesType aList = new GenericJAXBMarshaller<>(PCLTransportProfilesType.class, new QName("dummy")).read(aTPSheet);
    // Create Java source
    try {
        final JDefinedClass jEnum = CM._package(RESULT_PACKAGE_PREFIX + "transportprofile")._enum("EPredefinedTransportProfileIdentifier");
        jEnum._implements(CM.ref(IPredefinedTransportProfileIdentifier.class));
        jEnum.annotate(CodingStyleguideUnaware.class);
        jEnum.javadoc().add(DO_NOT_EDIT);
        // Add metadata
        jEnum.field(JMod.PUBLIC_STATIC_FINAL, CM.ref(String.class), "CODE_LIST_VERSION", JExpr.lit(aList.getVersion()));
        jEnum.field(JMod.PUBLIC_STATIC_FINAL, CM.INT, "CODE_LIST_ENTRY_COUNT", JExpr.lit(aList.getEntryCount().intValue()));
        // enum constants
        final ICommonsSet<String> aAllShortcutNames = new CommonsHashSet<>();
        for (final PCLTransportProfileType aRow : aList.getTransportProfile()) {
            final String sProtocol = aRow.getProtocol();
            final String sProfileVersion = aRow.getProfileVersion();
            final String sProfileID = aRow.getProfileId();
            final String sInitialRelease = aRow.getInitialRelease();
            final EPeppolCodeListItemState eState = _getState(aRow.getState());
            final boolean bDeprecated = !eState.isActive();
            final String sDeprecationRelease = aRow.getDeprecationRelease();
            final LocalDate aRemovalDate = aRow.getRemovalDateLocal();
            // Prepend the scheme, if it is non-default
            final String sEnumConstName = RegExHelper.getAsIdentifier(sProfileID);
            final JEnumConstant jEnumConst = jEnum.enumConstant(sEnumConstName);
            jEnumConst.arg(JExpr.lit(sProtocol));
            jEnumConst.arg(JExpr.lit(sProfileVersion));
            jEnumConst.arg(JExpr.lit(sProfileID));
            jEnumConst.arg(CM.ref(Version.class).staticInvoke("parse").arg(sInitialRelease));
            jEnumConst.arg(CM.ref(EPeppolCodeListItemState.class).enumConstantRef(eState));
            jEnumConst.arg(bDeprecated ? CM.ref(Version.class).staticInvoke("parse").arg(sDeprecationRelease) : JExpr._null());
            jEnumConst.arg(_asExpr(aRemovalDate));
            jEnumConst.javadoc().add("ID: <code>" + sProfileID + "</code><br>");
            jEnumConst.javadoc().addTag(JDocComment.TAG_SINCE).add("code list " + sInitialRelease);
            if (bDeprecated) {
                jEnumConst.annotate(Deprecated.class);
                jEnumConst.javadoc().addDeprecated().add("since " + sDeprecationRelease + " - this item should not be used to issue new identifiers!");
            }
            // Emit shortcut name for better readability
            final String sShortcutName = CodeGenerationHelper.createShortcutTransportProtocolName(sProtocol + "_" + sProfileVersion);
            if (sShortcutName != null) {
                final String sRealShortcutName = sShortcutName;
                if (!aAllShortcutNames.add(sRealShortcutName))
                    throw new IllegalStateException("The Transport Profile shortcut '" + sRealShortcutName + "' is already used - please review the algorithm!");
                final JFieldVar aShortcut = jEnum.field(JMod.PUBLIC | JMod.STATIC | JMod.FINAL, jEnum, sRealShortcutName, jEnumConst);
                aShortcut.javadoc().add("Same as {@link #" + sEnumConstName + "}");
                jEnumConst.javadoc().add("\nSame as {@link #" + sRealShortcutName + "}");
                if (bDeprecated) {
                    aShortcut.annotate(Deprecated.class);
                    aShortcut.javadoc().addDeprecated().add("since " + sDeprecationRelease + " - this item should not be used to issue new identifiers!");
                }
            }
        }
        // fields
        final JFieldVar fProtocol = jEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "m_sProtocol");
        final JFieldVar fProfileVersion = jEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "m_sProfileVersion");
        final JFieldVar fProfileID = jEnum.field(JMod.PRIVATE | JMod.FINAL, String.class, "m_sProfileID");
        final JFieldVar fInitialRelease = jEnum.field(JMod.PRIVATE | JMod.FINAL, Version.class, "m_aInitialRelease");
        final JFieldVar fState = jEnum.field(JMod.PRIVATE | JMod.FINAL, EPeppolCodeListItemState.class, "m_eState");
        final JFieldVar fDeprecationRelease = jEnum.field(JMod.PRIVATE | JMod.FINAL, Version.class, "m_aDeprecationRelease");
        final JFieldVar fRemovalDate = jEnum.field(JMod.PRIVATE | JMod.FINAL, LocalDate.class, "m_aRemovalDate");
        // Constructor
        final JMethod jCtor = jEnum.constructor(0);
        final JVar jProtocol = jCtor.param(JMod.FINAL, String.class, "sProtocol");
        jProtocol.annotate(Nonnull.class);
        jProtocol.annotate(Nonempty.class);
        final JVar jProfileVersion = jCtor.param(JMod.FINAL, String.class, "sProfileVersion");
        jProfileVersion.annotate(Nonnull.class);
        jProfileVersion.annotate(Nonempty.class);
        final JVar jProfileID = jCtor.param(JMod.FINAL, String.class, "sProfileID");
        jProfileID.annotate(Nonnull.class);
        jProfileID.annotate(Nonempty.class);
        final JVar jInitialRelease = jCtor.param(JMod.FINAL, Version.class, "aInitialRelease");
        jInitialRelease.annotate(Nonnull.class);
        final JVar jState = jCtor.param(JMod.FINAL, EPeppolCodeListItemState.class, "eState");
        jState.annotate(Nonnull.class);
        final JVar jDeprecationRelease = jCtor.param(JMod.FINAL, Version.class, "aDeprecationRelease");
        jDeprecationRelease.annotate(Nullable.class);
        final JVar jRemovalDate = jCtor.param(JMod.FINAL, LocalDate.class, "aRemovalDate");
        jRemovalDate.annotate(Nullable.class);
        jCtor.body().assign(fProtocol, jProtocol).assign(fProfileVersion, jProfileVersion).assign(fProfileID, jProfileID).assign(fInitialRelease, jInitialRelease).assign(fState, jState).assign(fDeprecationRelease, jDeprecationRelease).assign(fRemovalDate, jRemovalDate);
        // public String getProtocol()
        JMethod m = jEnum.method(JMod.PUBLIC, String.class, "getProtocol");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fProtocol);
        // public String getProfileVersion ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getProfileVersion");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fProfileVersion);
        // public String getProfileID ()
        m = jEnum.method(JMod.PUBLIC, String.class, "getProfileID");
        m.annotate(Nonnull.class);
        m.annotate(Nonempty.class);
        m.body()._return(fProfileID);
        // public Version getInitialRelease ()
        m = jEnum.method(JMod.PUBLIC, Version.class, "getInitialRelease");
        m.annotate(Nonnull.class);
        m.body()._return(fInitialRelease);
        // public EPeppolCodeListItemState getState ()
        m = jEnum.method(JMod.PUBLIC, EPeppolCodeListItemState.class, "getState");
        m.annotate(Nonnull.class);
        m.body()._return(fState);
        // public Version getDeprecationRelease ()
        m = jEnum.method(JMod.PUBLIC, Version.class, "getDeprecationRelease");
        m.annotate(Nullable.class);
        m.body()._return(fDeprecationRelease);
        // public LocalDate getRemovalDate ()
        m = jEnum.method(JMod.PUBLIC, LocalDate.class, "getRemovalDate");
        m.annotate(Nullable.class);
        m.body()._return(fRemovalDate);
    } catch (final JCodeModelException ex) {
        LOGGER.warn("Failed to create source", ex);
    }
}
Also used : JDefinedClass(com.helger.jcodemodel.JDefinedClass) QName(javax.xml.namespace.QName) LocalDate(java.time.LocalDate) PCLTransportProfilesType(com.helger.xsds.peppol.codelists2.PCLTransportProfilesType) EPeppolCodeListItemState(com.helger.peppolid.peppol.EPeppolCodeListItemState) JEnumConstant(com.helger.jcodemodel.JEnumConstant) Version(com.helger.commons.version.Version) JFieldVar(com.helger.jcodemodel.JFieldVar) IPredefinedTransportProfileIdentifier(com.helger.peppolid.peppol.transportprofile.IPredefinedTransportProfileIdentifier) PCLTransportProfileType(com.helger.xsds.peppol.codelists2.PCLTransportProfileType) JMethod(com.helger.jcodemodel.JMethod) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) JCodeModelException(com.helger.jcodemodel.JCodeModelException) JVar(com.helger.jcodemodel.JVar)

Example 15 with CommonsHashSet

use of com.helger.commons.collection.impl.CommonsHashSet in project ph-web by phax.

the class TLSConfigurationMode method isSupportedCipherSuiteInSSLContext.

public static boolean isSupportedCipherSuiteInSSLContext(@Nonnull final ETLSVersion[] aTLSVersions, @Nonnull @Nonempty final String sCipherSuite) {
    // Check if the cipher suite is available for any TLS version
    for (final ETLSVersion eTLSVersion : aTLSVersions) {
        final SSLContext aSSLCtx = TLS_CONTEXT_MAP.get(eTLSVersion);
        if (aSSLCtx != null) {
            final SSLParameters aParams = aSSLCtx.getSupportedSSLParameters();
            final ICommonsSet<String> aCipherSuites = new CommonsHashSet<>(aParams.getCipherSuites());
            if (aCipherSuites.contains(sCipherSuite)) {
                if (LOGGER.isDebugEnabled())
                    LOGGER.debug("Cipher suite '" + sCipherSuite + "' is supported in TLS version " + eTLSVersion);
                return true;
            }
        }
    }
    if (LOGGER.isDebugEnabled())
        LOGGER.debug("Cipher suite '" + sCipherSuite + "' is not supported by any TLS version");
    return false;
}
Also used : SSLParameters(javax.net.ssl.SSLParameters) SSLContext(javax.net.ssl.SSLContext) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet)

Aggregations

CommonsHashSet (com.helger.commons.collection.impl.CommonsHashSet)15 Locale (java.util.Locale)5 Nonnull (javax.annotation.Nonnull)5 ISimpleURL (com.helger.commons.url.ISimpleURL)4 HCA (com.helger.html.hc.html.textlevel.HCA)4 ICommonsList (com.helger.commons.collection.impl.ICommonsList)3 ICommonsSet (com.helger.commons.collection.impl.ICommonsSet)3 HCRow (com.helger.html.hc.html.tabular.HCRow)3 HCTable (com.helger.html.hc.html.tabular.HCTable)3 HCNodeList (com.helger.html.hc.impl.HCNodeList)3 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)3 IProcessIdentifier (com.helger.peppolid.IProcessIdentifier)3 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)3 BootstrapDTColAction (com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction)3 Map (java.util.Map)3 Nullable (javax.annotation.Nullable)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3 CommonsArrayList (com.helger.commons.collection.impl.CommonsArrayList)2 CommonsHashMap (com.helger.commons.collection.impl.CommonsHashMap)2