Examples of ICrypt


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

    };

    panel.setPersistent(true);
    form = (Form<?>)panel.get("signInForm");

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

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

    };

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

    final ICrypt crypt = tester.getApplication()
      .getSecuritySettings()
      .getCryptFactory()
      .newCrypt();
    final String encryptedPassword = crypt.encryptUrlSafe("test");
    assertNotNull(encryptedPassword);
    cookieUsername = new Cookie("panel.signInForm.username", "juergen");
    cookiePassword = new Cookie("panel.signInForm.password", encryptedPassword);
    cookies = new Cookie[] { cookieUsername, cookiePassword };
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

  private static class TestCryptFactory implements ICryptFactory
  {

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

        public String decryptUrlSafe(String text)
        {
          return new String(new Base64(true).decode(text));
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);

          encryptedQueryString = WicketURLEncoder.QUERY_INSTANCE.encode(encryptedQueryString);

          // build the new complete url
          return new AppendingStringBuffer(urlPrefix).append("?x=").append(
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.