/** * Create the bitmask of what the target requires. * * @param tc the transport configuration metadata. * @return an {@code int} representing the transport mechanism required by the target. */ public static int createTargetRequires(TransportConfig tc) { int requires = 0; if (tc != null) { if (tc.getIntegrity().equals(TransportConfig.INTEGRITY_REQUIRED)) { requires = requires | Integrity.value; } if (tc.getConfidentiality().equals(TransportConfig.CONFIDENTIALITY_REQUIRED)) { requires = requires | Confidentiality.value; } if (tc.getDetectMisordering().equalsIgnoreCase(TransportConfig.DETECT_MISORDERING_REQUIRED)) { requires = requires | DetectMisordering.value; } if (tc.getDetectReplay().equalsIgnoreCase(TransportConfig.DETECT_REPLAY_REQUIRED)) { requires = requires | DetectReplay.value; } // no EstablishTrustInTarget required - client decides if (tc.getEstablishTrustInClient() .equals(TransportConfig.ESTABLISH_TRUST_IN_CLIENT_REQUIRED)) { requires = requires | EstablishTrustInClient.value; } } return requires; }
/** * Create the bitmask of what the target supports. * * @param tc the transport configuration metadata. * @return an {@code int} representing the transport mechanisms supported by the target. */ public static int createTargetSupports(TransportConfig tc) { int supports = 0; if (tc != null) { if (!tc.getIntegrity().equals(TransportConfig.INTEGRITY_NONE)) { supports = supports | Integrity.value; } if (!tc.getConfidentiality().equals(TransportConfig.CONFIDENTIALITY_NONE)) { supports = supports | Confidentiality.value; } if (!tc.getDetectMisordering().equalsIgnoreCase(TransportConfig.DETECT_MISORDERING_NONE)) { supports = supports | DetectMisordering.value; } if (!tc.getDetectReplay().equalsIgnoreCase(TransportConfig.DETECT_REPLAY_NONE)) { supports = supports | DetectReplay.value; } if (!tc.getEstablishTrustInTarget().equals(TransportConfig.ESTABLISH_TRUST_IN_TARGET_NONE)) { supports = supports | EstablishTrustInTarget.value; } if (!tc.getEstablishTrustInClient().equals(TransportConfig.ESTABLISH_TRUST_IN_CLIENT_NONE)) { supports = supports | EstablishTrustInClient.value; } } return supports; }