Examples of ICrypt


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

        }

        secureParam = WicketURLDecoder.QUERY_INSTANCE.decode(secureParam);

        // 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

   *
   *
   */
  public void testCrypt()
  {
    final ICrypt crypt = new SunJceCrypt();

    try
    {
      if (crypt.encryptUrlSafe("test") != null)
      {
        final String text = "abcdefghijkABC: A test which creates a '/' and/or a '+'";
        final String expectedUrlSafeEncrypted = "g*N-AGk2b3qe70kJ0we4Rsa8getbnPLm6NyE0BCd*go0P*0kuIe6UvAYP7dlzx*9mfmPaMQ5lCk";

        assertEquals(expectedUrlSafeEncrypted, crypt.encryptUrlSafe(text));
        assertEquals(text, crypt.decryptUrlSafe(expectedUrlSafeEncrypted));
      }
    }
    catch (Exception ex)
    {
      // fails on JVMs without security provider (e.g. seems to be on
View Full Code Here

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

   *
   */
  public void testNoCrypt()
  {
    // 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

   * @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);

          encryptedQueryString = WicketURLEncoder.QUERY_INSTANCE.encode(encryptedQueryString);

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

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

        }

        secureParam = WicketURLDecoder.QUERY_INSTANCE.decode(secureParam);

        // 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

    };

    this.panel.setPersistent(true);
    this.form = (Form)panel.get("signInForm");

    final ICrypt crypt = tester.getApplication().getSecuritySettings().getCryptFactory()
        .newCrypt();
    final String encryptedPassword = crypt.encryptUrlSafe("test");
    assertNotNull(encryptedPassword);
    this.cookieUsername = new Cookie("panel:signInForm:username", "juergen");
    this.cookiePassword = new Cookie("panel:signInForm:password", encryptedPassword);
    this.cookies = new Cookie[] { cookieUsername, cookiePassword };
View Full Code Here

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

   *
   *
   */
  public void testCrypt()
  {
    final ICrypt crypt = new SunJceCrypt();

    try
    {
      if (crypt.encryptUrlSafe("test") != null)
      {
        final String text = "abcdefghijkABC: A test which creates a '/' and/or a '+'";
        final String expectedUrlSafeEncrypted = "g-N_AGk2b3qe70kJ0we4Rsa8getbnPLm6NyE0BCd-go0P-0kuIe6UvAYP7dlzx-9mfmPaMQ5lCk";

        final String encrypted = crypt.encryptUrlSafe(text);
        assertEquals(expectedUrlSafeEncrypted, encrypted);
        assertEquals(text, crypt.decryptUrlSafe(expectedUrlSafeEncrypted));
      }
    }
    catch (Exception ex)
    {
      // fails on JVMs without security provider (e.g. seems to be on
View Full Code Here

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

   *
   */
  public void testNoCrypt()
  {
    // 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
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.