Package org.apache.commons.codec.binary

Examples of org.apache.commons.codec.binary.Base64


                        SynapseConstants.SYNPASE_HTTP_PROXY_USER);
                String password = synapseProperties.getProperty(
                        SynapseConstants.SYNPASE_HTTP_PROXY_PASSWORD);
                if (userName != null && password != null) {
                    String header = userName + ":" + password;
                    byte[] encodedHeaderBytes = new Base64().encode(header.getBytes());
                    String encodedHeader = new String(encodedHeaderBytes);

                    connection.setRequestProperty("Proxy-Authorization", "Basic " + encodedHeader);
                }
            } else {
View Full Code Here


        byte[] data;
        byte[] rawHmac;
        try {
            data = stringToSign.getBytes(UTF8_CHARSET);
            rawHmac = mac.doFinal(data);
            Base64 encoder = new Base64();
            signature = new String(encoder.encode(rawHmac));
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(UTF8_CHARSET + " is unsupported!", e);
        }
        return signature;
    }
View Full Code Here

        if (key.indexOf(".account") != -1) {
          acPassEntry.setAccountName(URLEncoder.encode(authProps.getProperty(key), "UTF-8"));
          mLog.debug("Found account name: " + acPassEntry.getAccountName() + " for auth entry: " + url);
        } else if (key.indexOf(".password") != -1) {
          Base64 decoder = new Base64();
          acPassEntry.setPassword(new String(decoder.decode(authProps.getProperty(key))));
          mLog.debug("Found password for auth entry: " + url);
        }
        // write the updated entry back to hashtable
        mLog.debug("write entry for url >" + url + "<" + " with username/password into authentication store.");
        accountPasswordStore.put(url, acPassEntry);
View Full Code Here

   private static void accessEndUserResource(String relativeURI) throws Exception
   {
       HttpClient client = new HttpClient();
       GetMethod method = new GetMethod(EndUserResourceURL + relativeURI);
      
       Base64 base64 = new Base64();
       String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
       method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
      
       int status = client.executeMethod(method);
       if ("/invisible".equals(relativeURI)) {
           if (status != 401) {
View Full Code Here

   {
      HttpClient client = new HttpClient();
      GetMethod method = new GetMethod(url);
      // request that XML formatted authorization request is presented
      method.addRequestHeader(new Header("Accept", "application/xml"));
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
     
      int status = client.executeMethod(method);
      if (200 != status) {
          throw new RuntimeException("No authorization request data is available");
View Full Code Here

  
   public String confirmAuthorization(String url) throws Exception
   {
      HttpClient client = new HttpClient();
      PostMethod method = new PostMethod(url);
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
     
      int status = client.executeMethod(method);
      if (302 != status) {
          throw new RuntimeException("Initiation failed");
View Full Code Here

            FilterChain filterChain) throws IOException, ServletException {
        String header = request.getHeader("Authorization");
        if (header != null && header.startsWith("Basic"))
        {
            String base64Value = header.substring(6);
            Base64 base64 = new Base64();
            String decoded = new String(base64.decode(base64Value.getBytes()));
            String[] pair = decoded.split(":");
            String username = pair[0];
            String password = pair[1];
            request = createSecurityContext(request, username, password);
            filterChain.doFilter(request, response);
View Full Code Here

   public void registerTrustedOpenIdRealms()
       throws Exception
    {
       HttpClient client = new HttpClient();
       PostMethod method = new PostMethod(OpenIdTrustedRealmsURL);
       Base64 base64 = new Base64();
       String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
       method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
       method.addParameter("xopenid.realm", OpenIdTrustedRealm);
       int status = client.executeMethod(method);
       if (HttpResponseCodes.SC_OK != status) {
           throw new RuntimeException("OpenId realms can not be registered");
View Full Code Here

   private static void accessEndUserResource(String relativeURI) throws Exception
   {
       HttpClient client = new HttpClient();
       GetMethod method = new GetMethod(EndUserResourceURL + relativeURI);
      
       Base64 base64 = new Base64();
       String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
       method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
      
       int status = client.executeMethod(method);
       if ("/invisible".equals(relativeURI)) {
           if (status != 401) {
View Full Code Here

   {
      HttpClient client = new HttpClient();
      GetMethod method = new GetMethod(url);
      // request that XML formatted authorization request is presented
      method.addRequestHeader(new Header("Accept", "application/xml"));
      Base64 base64 = new Base64();
      String base64Credentials = new String(base64.encode("admin:admin".getBytes()));
      method.addRequestHeader(new Header("Authorization", "Basic " + base64Credentials));
     
      int status = client.executeMethod(method);
      if (200 != status) {
          throw new RuntimeException("No authorization request data is available");
View Full Code Here

TOP

Related Classes of org.apache.commons.codec.binary.Base64

Copyright © 2018 www.massapicom. 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.