Examples of ICrypt


Examples of org.apache.wicket.util.crypt.ICrypt

   */
  @Test
  public void noCrypt()
  {
    // The NoCrypt implementation does not modify the string at all
    final ICrypt crypt = new NoCrypt();

    assertEquals("test", crypt.encryptUrlSafe("test"));
    assertEquals("test", crypt.decryptUrlSafe("test"));
  }
View Full Code Here

Examples of org.apache.wicket.util.crypt.ICrypt

  {

    @Override
    public ICrypt newCrypt()
    {
      return new ICrypt()
      {

        @Override
        public String decryptUrlSafe(String text)
        {
View Full Code Here

Examples of org.apache.wicket.util.crypt.ICrypt

   * @return The encoded url
   */
  public CharSequence encodeURL(CharSequence url)
  {
      // Get the crypt implementation from the application
    ICrypt urlCrypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt();
    if (urlCrypt != null)
    {
        // The url must have a query string, otherwise keep the url unchanged
        final int pos = url.toString().indexOf('?');
        if (pos > 0)
        {
            // The url's path
          CharSequence urlPrefix = url.subSequence(0, pos);

          // Extract the querystring
          String queryString = url.subSequence(pos + 1, url.length()).toString();

          // if the querystring starts with a parameter like
          // "x=", than don't change the querystring as it
          // has been encoded already
          if (!queryString.startsWith("x="))
          {
              // The length of the encrypted string depends on the
              // length of the original querystring. Let's try to
              // make the querystring shorter first without loosing
              // information.
            queryString = shortenUrl(queryString).toString();

            // encrypt the query string
          final String encryptedQueryString = urlCrypt.encryptUrlSafe(queryString);

          // build the new complete url
          return new AppendingStringBuffer(urlPrefix).append("?x=").append(encryptedQueryString);
          }
        }
View Full Code Here

Examples of org.apache.wicket.util.crypt.ICrypt

    // Encoded query string have only a single parameter named "x"
    final String secureParam = request.getParameter("x");
    if ((secureParam != null) && (secureParam.length() > 0))
    {
      // Get the crypt implementation from the application
      ICrypt urlCrypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt();

      // Decrypt the query string
      final String queryString = urlCrypt.decryptUrlSafe(secureParam);

      // The querystring might have been shortened (length reduced).
      // In that case, lengthen the query string again.
      this.queryString = rebuildUrl(queryString);
View Full Code Here

Examples of org.apache.wicket.util.crypt.ICrypt

        // should never happen
        throw new WicketRuntimeException(ex);
      }

      // Get the crypt implementation from the application
      final ICrypt urlCrypt = Application.get().getSecuritySettings().getCryptFactory()
          .newCrypt();

      // Decrypt the query string
      final String queryString = urlCrypt.decryptUrlSafe(secureParam);

      // The querystring might have been shortened (length reduced).
      // In that case, lengthen the query string again.
      return rebuildUrl(queryString);
    }
View Full Code Here

Examples of org.apache.wicket.util.crypt.ICrypt

   * @return The encoded url
   */
  protected CharSequence encodeURL(final CharSequence url)
  {
    // Get the crypt implementation from the application
    ICrypt urlCrypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt();
    if (urlCrypt != null)
    {
      // The url must have a query string, otherwise keep the url
      // unchanged
      final int pos = url.toString().indexOf('?');
      if (pos > -1)
      {
        // The url's path
        CharSequence urlPrefix = url.subSequence(0, pos);

        // Extract the querystring
        String queryString = url.subSequence(pos + 1, url.length()).toString();

        // if the querystring starts with a parameter like
        // "x=", than don't change the querystring as it
        // has been encoded already
        if (!queryString.startsWith("x="))
        {
          // The length of the encrypted string depends on the
          // length of the original querystring. Let's try to
          // make the querystring shorter first without loosing
          // information.
          queryString = shortenUrl(queryString).toString();

          // encrypt the query string
          String encryptedQueryString = urlCrypt.encryptUrlSafe(queryString);

          try
          {
            encryptedQueryString = URLEncoder.encode(encryptedQueryString, Application
                .get().getRequestCycleSettings().getResponseRequestEncoding());
View Full Code Here

Examples of org.apache.wicket.util.crypt.ICrypt

        secureParam = URLDecoder.decode(secureParam, Application.get()
            .getRequestCycleSettings().getResponseRequestEncoding());

        // Get the crypt implementation from the application
        final ICrypt urlCrypt = Application.get().getSecuritySettings().getCryptFactory()
            .newCrypt();

        // Decrypt the query string
        String queryString = urlCrypt.decryptUrlSafe(secureParam);

        // The querystring might have been shortened (length reduced).
        // In that case, lengthen the query string again.
        queryString = rebuildUrl(queryString);
        return queryString;
View Full Code Here

Examples of org.apache.wicket.util.crypt.ICrypt

   * @return The encoded url
   */
  protected CharSequence encodeURL(final CharSequence url)
  {
    // Get the crypt implementation from the application
    ICrypt urlCrypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt();
    if (urlCrypt != null)
    {
      // The url must have a query string, otherwise keep the url
      // unchanged
      final int pos = url.toString().indexOf('?');
      if (pos > -1)
      {
        // The url's path
        CharSequence urlPrefix = url.subSequence(0, pos);

        // Extract the querystring
        String queryString = url.subSequence(pos + 1, url.length()).toString();

        // if the querystring starts with a parameter like
        // "x=", than don't change the querystring as it
        // has been encoded already
        if (!queryString.startsWith("x="))
        {
          // The length of the encrypted string depends on the
          // length of the original querystring. Let's try to
          // make the querystring shorter first without loosing
          // information.
          queryString = shortenUrl(queryString).toString();

          // encrypt the query string
          String encryptedQueryString = urlCrypt.encryptUrlSafe(queryString);

          try
          {
            encryptedQueryString = URLEncoder.encode(encryptedQueryString, Application
                .get().getRequestCycleSettings().getResponseRequestEncoding());
View Full Code Here

Examples of org.apache.wicket.util.crypt.ICrypt

        secureParam = URLDecoder.decode(secureParam, Application.get()
            .getRequestCycleSettings().getResponseRequestEncoding());

        // Get the crypt implementation from the application
        final ICrypt urlCrypt = Application.get().getSecuritySettings().getCryptFactory()
            .newCrypt();

        // Decrypt the query string
        String queryString = urlCrypt.decryptUrlSafe(secureParam);

        // The querystring might have been shortened (length reduced).
        // In that case, lengthen the query string again.
        queryString = rebuildUrl(queryString);
        return queryString;
View Full Code Here

Examples of org.apache.wicket.util.crypt.ICrypt

   * @return The encoded url
   */
  protected CharSequence encodeURL(final CharSequence url)
  {
    // Get the crypt implementation from the application
    ICrypt urlCrypt = Application.get().getSecuritySettings().getCryptFactory().newCrypt();
    if (urlCrypt != null)
    {
      // The url must have a query string, otherwise keep the url
      // unchanged
      final int pos = url.toString().indexOf('?');
      if (pos > -1)
      {
        // The url's path
        CharSequence urlPrefix = url.subSequence(0, pos);

        // Extract the querystring
        String queryString = url.subSequence(pos + 1, url.length()).toString();

        // if the querystring starts with a parameter like
        // "x=", than don't change the querystring as it
        // has been encoded already
        if (!queryString.startsWith("x="))
        {
          // The length of the encrypted string depends on the
          // length of the original querystring. Let's try to
          // make the querystring shorter first without loosing
          // information.
          queryString = shortenUrl(queryString).toString();

          // encrypt the query string
          String encryptedQueryString = urlCrypt.encryptUrlSafe(queryString);

          try
          {
            encryptedQueryString = URLEncoder.encode(encryptedQueryString, Application
                .get().getRequestCycleSettings().getResponseRequestEncoding());
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.