Examples of encodeToString()


Examples of org.apache.commons.codec.binary.Base64.encodeToString()

          gssContext.requestMutualAuth(true);

          byte[] inToken = new byte[0];
          byte[] outToken = gssContext.initSecContext(inToken, 0, inToken.length);
          Base64 base64 = new Base64(0);
          return base64.encodeToString(outToken);

        } finally {
          if (gssContext != null) {
            gssContext.dispose();
          }
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64.encodeToString()

            GSSContext gssContext = null;
            try {
              gssContext = gssManager.createContext((GSSCredential) null);
              byte[] serverToken = gssContext.acceptSecContext(clientToken, 0, clientToken.length);
              if (serverToken != null && serverToken.length > 0) {
                String authenticate = base64.encodeToString(serverToken);
                response.setHeader(KerberosAuthenticator.WWW_AUTHENTICATE,
                                   KerberosAuthenticator.NEGOTIATE + " " + authenticate);
              }
              if (!gssContext.isEstablished()) {
                response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64.encodeToString()

    byte[] bytes = cert.getEncoded();
    final FileOutputStream out = new FileOutputStream( file );
    Base64 encoder = new Base64( 76, "\n".getBytes( "ASCII" ) );
    try {
      out.write( "-----BEGIN CERTIFICATE-----\n".getBytes( "ASCII" ) );
      out.write( encoder.encodeToString( bytes ).getBytes( "ASCII" ) );
      out.write( "-----END CERTIFICATE-----\n".getBytes( "ASCII" ) );
    } finally {
      out.close();
    }
  }
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64.encodeToString()

        // important : no end of line, else the cookie contains control
        // characters, and it doesn't work
        Base64 base64 = new Base64(-1);
        Cookie cookie = new Cookie(SECRET_KEY_COOKIE_NAME,
                                   base64.encodeToString(encryptedSecretKey));
        cookie.setMaxAge(-1);
        cookie.setPath(getRequest().getContextPath() + "/");
        if (SystemProperty.environment.value() == SystemProperty.Environment.Value.Production) {
            cookie.setSecure(true);
        }
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64.encodeToString()

    DataOutputBuffer buf = new DataOutputBuffer();
    obj.write(buf);
    Base64 encoder = new Base64(0, null, true);
    byte[] raw = new byte[buf.getLength()];
    System.arraycopy(buf.getData(), 0, raw, 0, buf.getLength());
    return encoder.encodeToString(raw);
  }
 
  /**
   * Modify the writable to the value from the newValue
   * @param obj the object to read into
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64.encodeToString()

        request.addHeader( "User-Agent", "Apache Archiva unit test" );
        request.setMethod( "GET" );

        Base64 encoder = new Base64( 0, new byte[0] );
        String userPass = "user1:password1";
        String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
        request.addHeader( "Authorization", "BASIC " + encodedUserPass );

        MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse();

        rssFeedServlet.doGet( request, mockHttpServletResponse );
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64.encodeToString()

        //WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/org/apache/archiva/artifact-two" );

        Base64 encoder = new Base64( 0, new byte[0] );
        String userPass = "user1:password1";
        String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
        request.addHeader( "Authorization", "BASIC " + encodedUserPass );

        MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse();

        rssFeedServlet.doGet( request, mockHttpServletResponse );
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64.encodeToString()

        //WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/unauthorized-repo" );

        Base64 encoder = new Base64( 0, new byte[0] );
        String userPass = "user1:password1";
        String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
        request.addHeader( "Authorization", "BASIC " + encodedUserPass );

        MockHttpServletResponse mockHttpServletResponse = new MockHttpServletResponse();
        rssFeedServlet.doGet( request, mockHttpServletResponse );
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64.encodeToString()

        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/test-repo" );

        Base64 encoder = new Base64(0, new byte[0]);
        String userPass = "user1:password1";
        String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
        request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );

        WebResponse response = client.getResponse( request );
        assertEquals( RssFeedServlet.MIME_TYPE, response.getHeaderField( "CONTENT-TYPE" ) );
        assertNotNull( "Should have recieved a response", response );
View Full Code Here

Examples of org.apache.commons.codec.binary.Base64.encodeToString()

        WebRequest request = new GetMethodWebRequest( "http://localhost/feeds/org/apache/archiva/artifact-two" );

        Base64 encoder = new Base64(0, new byte[0]);
        String userPass = "user1:password1";
        String encodedUserPass = encoder.encodeToString( userPass.getBytes() );
        request.setHeaderField( "Authorization", "BASIC " + encodedUserPass );

        WebResponse response = client.getResponse( request );
        assertEquals( RssFeedServlet.MIME_TYPE, response.getHeaderField( "CONTENT-TYPE" ) );
        assertNotNull( "Should have recieved a response", response );
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.