Verifies a sequence of codepoints using the specified profile

@param sStr
String
@param eProfile
profile to use
494220
public static void verify (@Nullable final String sStr, @Nonnull final ECodepointProfile eProfile)
  {
    if (sStr != null)
      verify (new CodepointIteratorCharSequence (sStr), eProfile);
  }
724931
protected boolean validateSARLSpecificElements(IJavaProject javaProject) {
		// Check if the "SARL" generation directory is a source folder.
		final IPath outputPath = SARLPreferences.getSARLOutputPathFor(javaProject.getProject());

		if (outputPath == null) {
			final String message = MessageFormat.format(
					Messages.BuildSettingWizardPage_0,
					SARLConfig.FOLDER_SOURCE_GENERATED);
			final IStatus status = SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, message);
			handleFinishException(getShell(), new InvocationTargetException(new CoreException(status)));
			return false;
		}
		if (!hasSourcePath(javaProject, outputPath)) {
			final String message = MessageFormat.format(
					Messages.SARLProjectCreationWizard_0,
					toOSString(outputPath),
					buildInvalidOutputPathMessageFragment(javaProject));
			final IStatus status = SARLEclipsePlugin.getDefault().createStatus(IStatus.ERROR, message);
			handleFinishException(getShell(), new InvocationTargetException(new CoreException(status)));
			return false;
		}
		return true;
	}
239168
private static EndpointReferenceType createEPR(String address, SLProperties props) {
        EndpointReferenceType epr = WSAEndpointReferenceUtils.getEndpointReference(address);
        if (props != null) {
            addProperties(epr, props);
        }
        return epr;
    }
1093286
public void handleSsoPostProfileRequest(final HttpServletResponse response,
                                            final HttpServletRequest request,
                                            final BaseHttpServletRequestXMLMessageDecoder decoder) throws Exception {
        val authnRequest = getSamlProfileHandlerConfigurationContext().getSamlHttpRequestExtractor()
            .extract(request, decoder, AuthnRequest.class);
        initiateAuthenticationRequest(authnRequest, response, request);
    }
696956
@JsonIgnore
    public void validate(final CommonProfile profile) {
        if (StringUtils.isBlank(getClientId())) {
            throw new InvalidResourceSetException(HttpStatus.BAD_REQUEST.value(), "Authentication request does contain a client id");
        }

        if (getScopes().isEmpty()) {
            throw new InvalidResourceSetException(HttpStatus.BAD_REQUEST.value(), "Resource set registration is missing scopes");
        }

        if (!getOwner().equals(profile.getId())) {
            throw new InvalidResourceSetException(HttpStatus.FORBIDDEN.value(), "Resource-set owner does not match the authenticated profile");
        }
    }
548254
@GetMapping(path = SamlIdPConstants.ENDPOINT_SAML2_SLO_PROFILE_REDIRECT)
    protected void handleSaml2ProfileSLOPostRequest(final HttpServletResponse response,
                                                    final HttpServletRequest request) throws Exception {
        val decoder = getSamlProfileHandlerConfigurationContext().getSamlMessageDecoders().getInstance(HttpMethod.GET);
        handleSloProfileRequest(response, request, decoder);
    }
730435
protected U convertAttributesToProfile(final List<Map<String, Object>> listStorageAttributes, final String username) {
        if (listStorageAttributes == null || listStorageAttributes.size() == 0) {
            return null;
        }
        final Map<String, Object> storageAttributes = listStorageAttributes.get(0);

        final String linkedId = (String) storageAttributes.get(LINKEDID);
        // legacy mode: only read the defined attributes
        if (isLegacyMode()) {
            final U profile = getProfileDefinition().newProfile();
            for (final String attributeName : attributeNames) {
                getProfileDefinition().convertAndAdd(profile, PROFILE_ATTRIBUTE, attributeName, storageAttributes.get(attributeName));
            }
            final Object retrievedUsername = storageAttributes.get(getUsernameAttribute());
            if (retrievedUsername != null) {
                profile.setId(ProfileHelper.sanitizeIdentifier(profile, retrievedUsername));
            } else {
                profile.setId(username);
            }
            if (isNotBlank(linkedId)) {
                profile.setLinkedId(linkedId);
            }
            return profile;
        } else {
            // new behaviour (>= v2.0): read the serialized profile
            final String serializedProfile = (String) storageAttributes.get(SERIALIZED_PROFILE);
            if (serializedProfile == null) {
                throw new TechnicalException("No serialized profile found. You should certainly define the explicit attribute names you " +
                    "want to retrieve");
            }
            final U profile = (U) javaSerializationHelper.deserializeFromBase64(serializedProfile);
            if (profile == null) {
                throw new TechnicalException("No deserialized profile available. You should certainly define the explicit attribute " +
                    "names you want to retrieve");
            }
            final Object id = storageAttributes.get(getIdAttribute());
            if (isBlank(profile.getId()) && id != null) {
                profile.setId(ProfileHelper.sanitizeIdentifier(profile, id));
            }
            if (isBlank(profile.getLinkedId()) && isNotBlank(linkedId)) {
                profile.setLinkedId(linkedId);
            }
            return profile;
        }
    }
733416
static int codePointBeforeImpl(char[] a, int index, int start) {
        char c2 = a[--index];
        if (isLowSurrogate(c2) && index > start) {
            char c1 = a[--index];
            if (isHighSurrogate(c1)) {
                return toCodePoint(c1, c2);
            }
        }
        return c2;
    }
797990
private AllProfiles loadProfiles(InputStream is) throws IOException {
        ProfilesConfigFileLoaderHelper helper = new ProfilesConfigFileLoaderHelper();
        Map<String, Map<String, String>> allProfileProperties = helper
                .parseProfileProperties(new Scanner(is, StringUtils.UTF8.name()));

        // Convert the loaded property map to credential objects
        Map<String, BasicProfile> profilesByName = new LinkedHashMap<String, BasicProfile>();

        for (Entry<String, Map<String, String>> entry : allProfileProperties.entrySet()) {
            String profileName = entry.getKey();
            Map<String, String> properties = entry.getValue();

            if (profileName.startsWith("profile ")) {
                LOG.warn(
                        "Your profile name includes a 'profile ' prefix. This is considered part of the profile name in the " +
                        "Java SDK, so you will need to include this prefix in your profile name when you reference this " +
                        "profile from your Java code.");
            }

            assertParameterNotEmpty(profileName,
                                    "Unable to load properties from profile: Profile name is empty.");
            profilesByName.put(profileName, new BasicProfile(profileName, properties));
        }

        return new AllProfiles(profilesByName);
    }
784810
@PostMapping(path = SamlIdPConstants.ENDPOINT_SAML2_SSO_PROFILE_POST)
    public void handleSaml2ProfileSsoPostRequest(final HttpServletResponse response,
                                                 final HttpServletRequest request) throws Exception {
        val decoder = getSamlProfileHandlerConfigurationContext().getSamlMessageDecoders().getInstance(HttpMethod.POST);
        handleSsoPostProfileRequest(response, request, decoder);
    }
401790
private void checkPrimitiveBinding(List<ValidationMessage> errors, String path, String type, ElementDefinition elementContext, Element element, StructureDefinition profile) {
		if (!element.hasPrimitiveValue())
			return;

		String value = element.primitiveValue();
		// System.out.println("check "+value+" in "+path);

		// firstly, resolve the value set
		ElementDefinitionBindingComponent binding = elementContext.getBinding();
		if (binding.hasValueSet() && binding.getValueSet() instanceof Reference) {
			ValueSet vs = resolveBindingReference(profile, binding.getValueSet());
			if (warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, vs != null, "ValueSet {0} not found", describeReference(binding.getValueSet()))) {
				long t = System.nanoTime();
				ValidationResult vr = context.validateCode(null, value, null, vs);
				txTime = txTime + (System.nanoTime() - t);
				if (vr != null && !vr.isOk()) {
					if (binding.getStrength() == BindingStrength.REQUIRED)
						rule(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided ('"+value+"') is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code is required from this value set");
					else if (binding.getStrength() == BindingStrength.EXTENSIBLE)
						warning(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false, "The value provided ('"+value+"') is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code should come from this value set unless it has no suitable code");
					else if (binding.getStrength() == BindingStrength.PREFERRED)
						hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, false,  "The value provided ('"+value+"') is not in the value set " + describeReference(binding.getValueSet()) + " (" + vs.getUrl() + ", and a code is recommended to come from this value set");
				}
			}
		} else
			hint(errors, IssueType.CODEINVALID, element.line(), element.col(), path, !type.equals("code"), "Binding has no source, so can't be checked");
	}
227089
@Override
    public void spr(char order, char Uplo, double alpha, INDArray X, INDArray Ap) {
        if (Nd4j.getExecutioner().getProfilingMode() == OpExecutioner.ProfilingMode.ALL)
            OpProfiler.getInstance().processBlasCall(false, Ap, X);


        // FIXME: int cast

        if (X.data().dataType() == DataType.DOUBLE) {
            DefaultOpExecutioner.validateDataType(DataType.DOUBLE, X);
            dspr(order, Uplo, (int) X.length(), alpha, X, X.stride(-1), Ap);
        } else {
            DefaultOpExecutioner.validateDataType(DataType.FLOAT, X);
            sspr(order, Uplo, (int) X.length(), (float) alpha, X, X.stride(-1), Ap);
        }

        OpExecutionerUtil.checkForAny(Ap);
    }
258109
public void initSwfVerification(String swfFilePath) {
        log.info("Initializing swf verification for: {}", swfFilePath);
        byte[] bytes = null;
        if (swfFilePath != null) {
            File localSwfFile = new File(swfFilePath);
            if (localSwfFile.exists() && localSwfFile.canRead()) {
                log.info("Swf file path: {}", localSwfFile.getAbsolutePath());
                bytes = FileUtil.readAsByteArray(localSwfFile);
            } else {
                bytes = "Red5 is awesome for handling non-accessable swf file".getBytes();
            }
        } else {
            bytes = new byte[42];
        }
        calculateHMAC_SHA256(bytes, 0, bytes.length, GENUINE_FP_KEY, 30, swfHash, 0);
        swfSize = bytes.length;
        log.info("Verification - size: {}, hash: {}", swfSize, Hex.encodeHexString(swfHash));
    }
1338090
private void validateRevocationStatusMain(
      SFPair<Certificate, Certificate> pairIssuerSubject,
      String ocspRespB64) throws CertificateException
  {
    try
    {
      OCSPResp ocspResp = b64ToOCSPResp(ocspRespB64);
      Date currentTime = new Date();
      BasicOCSPResp basicOcspResp = (BasicOCSPResp) (ocspResp.getResponseObject());
      X509CertificateHolder[] attachedCerts = basicOcspResp.getCerts();
      X509CertificateHolder signVerifyCert;
      if (attachedCerts.length > 0)
      {
        LOGGER.debug(
            "Certificate is attached for verification. " +
            "Verifying it by the issuer certificate.");
        signVerifyCert = attachedCerts[0];
        if (currentTime.after(signVerifyCert.getNotAfter()) || currentTime.before(signVerifyCert.getNotBefore()))
        {
          throw new OCSPException(String.format("Cert attached to OCSP Response is invalid." +
                                                "Current time - %s" +
                                                "Certificate not before time - %s" +
                                                "Certificate not after time - %s",
                                                currentTime.toString(),
                                                signVerifyCert.getNotBefore().toString(),
                                                signVerifyCert.getNotAfter().toString()));
        }
        verifySignature(
            new X509CertificateHolder(pairIssuerSubject.left.getEncoded()),
            signVerifyCert.getSignature(),
            CONVERTER_X509.getCertificate(signVerifyCert).getTBSCertificate(),
            signVerifyCert.getSignatureAlgorithm());
        LOGGER.debug(
            "Verifying OCSP signature by the attached certificate public key."
        );
      }
      else
      {
        LOGGER.debug("Certificate is NOT attached for verification. " +
                     "Verifying OCSP signature by the issuer public key.");
        signVerifyCert = new X509CertificateHolder(
            pairIssuerSubject.left.getEncoded());
      }
      verifySignature(
          signVerifyCert,
          basicOcspResp.getSignature(),
          basicOcspResp.getTBSResponseData(),
          basicOcspResp.getSignatureAlgorithmID());

      validateBasicOcspResponse(currentTime, basicOcspResp);
    }
    catch (IOException | OCSPException ex)
    {
      throw new CertificateEncodingException(
          "Failed to check revocation status.", ex);
    }
  }
1229760
public PmiModuleConfig loadDescriptor(String fileName, boolean validate, boolean loadFromClassPathOnly)
                    throws Exception {
        loadFromClassPathOnly = false;
        if (tc.isEntryEnabled())
            Tr.entry(tc, "loadDescriptor: parsing stats xml " + fileName + "; dtd validation: " + validate);

        // reset variables:
        oneModule = null;
        currentData = null;
        submoduleName = null;
        submoduleData = null;
        _fileName = fileName;
        _validate = validate;
        InputStream istream = null;
        boolean usingCC = false;

        if (fileName.indexOf('=') != (-1)) {
            // We check for an equals symbol, so that we can determine if
            // this resource should be loaded from the extenstion point repository.
            // Extension point lookups are encoded using a 'EXTENSION=xxxx'
            // encoding scheme.
            String[] tokens = fileName.split("=");
            if (tokens.length > 1) {
                if (tokens[0].equalsIgnoreCase(EXTENSION_TAG)) {
                    bExtension = true;
                    _fileName = tokens[1];
                    try {
                        parseFromExtension(_fileName);
                    } catch (Exception ex) {
                        if (tc.isDebugEnabled())
                            com.ibm.ws.ffdc.FFDCFilter.processException(ex, "com.ibm.ws.pmi.server.ModuleConfigParser.loadDescriptor", "97", this);
                        throw ex;
                    }
                    if (tc.isEntryEnabled())
                        Tr.exit(tc, "loadDescriptor");

                    return oneModule;
                }
            }
        }
        // No extension
        bExtension = false;
        if (istream == null) {
            istream = getResourcefromBundle(fileName);
            //System.out.println("ISTREME is ++++++++++++++++ " + istream);
            if (istream == null) {
                istream = getClass().getResourceAsStream(fileName);
            }
            usingCC = false;
            if (istream == null) {
                istream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
                usingCC = true;
            }
            if (istream == null) {
                istream = Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName.substring(1));
                usingCC = true;
            }
            if (istream == null) {
                Tr.error(tc, "PMI0010W", fileName);
                return null;
            }

        }

        try {
            //**JDK1.4.1 fix
            //**XMLReader parser = ParserFactory.createXMLReader("org.apache.xerces.parsers.SAXParser");
            XMLReader parser = ParserFactory.createXMLReader();
            parser.setFeature("http://xml.org/sax/features/namespaces", true);

            // commenting this -D flag
            // boolean validateDescriptors = Boolean.getBoolean(VALIDATE_DESCRIPTOR_PROPERTY);
            // skip DTD validation for pre-defined modules (perf.dtd)
            // do DTD validataion for custom PMI modules (stats.dtd)
            parser.setFeature("http://xml.org/sax/features/validation", validate);
            //** FIX: need to remove this feature?
            parser.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", validate);
            parser.setEntityResolver(this);
            parser.setContentHandler(this);
            parser.setErrorHandler(this);
            parser.parse(new InputSource(istream));
        } catch (Exception ex) {
            if (tc.isDebugEnabled())
                ex.printStackTrace();
            com.ibm.ws.ffdc.FFDCFilter.processException(ex, "com.ibm.ws.pmi.server.ModuleConfigParser.loadDescriptor", "97", this);
            throw ex;
        } finally {
            istream.close();
        }

        String uid = PerfModules.getModuleUID(fileName);

        //int index = uid.lastIndexOf(".");
        //String newUID = uid.substring(index+1);
        // instantiate oneModule
        //oneModule = new PmiModuleConfig (newUID);
        com.ibm.ws.pmi.stat.StatsConfigHelper.translateAndCache(oneModule, null);
        //        System.out.println("OneModule = " + oneModule);
        if (tc.isEntryEnabled())
            Tr.exit(tc, "loadDescriptor");

        return oneModule;
    }
468441
@Override
  public Map<String, Collection<String>> profileToRecordTypes() {
    Map<String, Collection<String>>
        profileToRecordTypes =
        new LinkedHashMap<String, Collection<String>>();
    profileToRecordTypes
        .put("geo", Arrays.asList("A", "AAAAA", "CNAME", "CERT", "MX", "TXT", "SPF", "PTR", "LOC",
                                  "SRV", "RP", "KEY", "DNSKEY", "SSHFP", "DHCID", "NSAP", "PX"));
    profileToRecordTypes
        .put("roundRobin", Arrays.asList("A", "AAAA", "CERT", "DHCID", "DNAME", "DNSKEY", "DS",
                                         "IPSECKEY", "KEY", "KX", "LOC", "MX", "NAPTR", "NS",
                                         "NSAP", "PTR", "PX", "RP", "SPF", "SRV", "SSHFP", "TXT"));
    return profileToRecordTypes;
  }
446845
public void verify(HttpServletRequest servletRequest, byte[] serializedRequestEnvelope, RequestEnvelope deserializedRequestEnvelope) {
        String baseEncoded64Signature = servletRequest.getHeader(ServletConstants.SIGNATURE_REQUEST_HEADER);
        String signingCertificateChainUrl = servletRequest.getHeader(ServletConstants.SIGNATURE_CERTIFICATE_CHAIN_URL_REQUEST_HEADER);
        if ((baseEncoded64Signature == null) || (signingCertificateChainUrl == null)) {
            throw new SecurityException(
                    "Missing signature/certificate for the provided skill request");
        }

        try {
            X509Certificate signingCertificate;
            if (CERTIFICATE_CACHE.containsKey(signingCertificateChainUrl)) {
                signingCertificate = CERTIFICATE_CACHE.get(signingCertificateChainUrl);
                /*
                 * check the before/after dates on the certificate are still valid for the present
                 * time
                 */
                signingCertificate.checkValidity();
            } else {
                signingCertificate = retrieveAndVerifyCertificateChain(signingCertificateChainUrl);

                // if certificate is valid, then add it to the cache
                CERTIFICATE_CACHE.put(signingCertificateChainUrl, signingCertificate);
            }

            // verify that the request was signed by the provided certificate
            Signature signature = Signature.getInstance(ServletConstants.SIGNATURE_ALGORITHM);
            signature.initVerify(signingCertificate.getPublicKey());
            signature.update(serializedRequestEnvelope);
            if (!signature.verify(Base64.decodeBase64(baseEncoded64Signature
                    .getBytes(ServletConstants.CHARACTER_ENCODING)))) {
                throw new SecurityException(
                        "Failed to verify the signature/certificate for the provided skill request");
            }
        } catch (GeneralSecurityException | IOException ex) {
            throw new SecurityException(
                    "Failed to verify the signature/certificate for the provided skill request",
                    ex);
        }
    }