當前位置: 首頁>>代碼示例>>Java>>正文


Java Base64.decode方法代碼示例

本文整理匯總了Java中org.springframework.security.crypto.codec.Base64.decode方法的典型用法代碼示例。如果您正苦於以下問題:Java Base64.decode方法的具體用法?Java Base64.decode怎麽用?Java Base64.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.security.crypto.codec.Base64的用法示例。


在下文中一共展示了Base64.decode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: extractAndDecodeHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
private String[] extractAndDecodeHeader(String header, HttpServletRequest request) throws IOException {
    byte[] base64Token = header.substring(6).getBytes("UTF-8");

    byte[] decoded;
    try {
        decoded = Base64.decode(base64Token);
    } catch (IllegalArgumentException var7) {
        throw new BadCredentialsException("Failed to decode basic authentication token");
    }

    String token = new String(decoded, "UTF-8");
    int delim = token.indexOf(":");
    if (delim == -1) {
        throw new BadCredentialsException("Invalid basic authentication token");
    } else {
        return new String[]{token.substring(0, delim), token.substring(delim + 1)};
    }
}
 
開發者ID:TZClub,項目名稱:OMIPlatform,代碼行數:19,代碼來源:TZAuthenticationSuccessHandler.java

示例2: extractAndDecodeHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
/**
 * Decodes the header into a username and password.
 *
 * @throws BadCredentialsException if the Basic header is not present or is not valid
 * Base64
 */
private String[] extractAndDecodeHeader(String header, HttpServletRequest request)
        throws IOException {

    byte[] base64Token = header.substring(6).getBytes("UTF-8");
    byte[] decoded;
    try {
        decoded = Base64.decode(base64Token);
    }
    catch (IllegalArgumentException e) {
        throw new BadCredentialsException(
                "Failed to decode basic authentication token");
    }

    String token = new String(decoded, getCredentialsCharset(request));

    int delim = token.indexOf(":");

    if (delim == -1) {
        throw new BadCredentialsException("Invalid basic authentication token");
    }
    return new String[] { token.substring(0, delim), token.substring(delim + 1) };
}
 
開發者ID:LIBCAS,項目名稱:ARCLib,代碼行數:29,代碼來源:BasicAuthenticationFilter.java

示例3: extractCredentials

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
@Override
public AuthenticationRequest extractCredentials(HttpServletRequest request) {

    // Only support Kerberos authentication when running securely
    if (!request.isSecure()) {
        return null;
    }

    String headerValue = request.getHeader(AUTHORIZATION);

    if (!isValidKerberosHeader(headerValue)) {
        return null;
    }

    logger.debug("Detected 'Authorization: Negotiate header in request {}", request.getRequestURL());
    byte[] base64Token = headerValue.substring(headerValue.indexOf(" ") + 1).getBytes(StandardCharsets.UTF_8);
    byte[] kerberosTicket = Base64.decode(base64Token);
    if (kerberosTicket != null) {
        logger.debug("Successfully decoded SPNEGO/Kerberos ticket passed in Authorization: Negotiate <ticket> header.", request.getRequestURL());
    }

    return new AuthenticationRequest(null, kerberosTicket, authenticationDetailsSource.buildDetails(request));

}
 
開發者ID:apache,項目名稱:nifi-registry,代碼行數:25,代碼來源:KerberosSpnegoIdentityProvider.java

示例4: extractAndDecodeHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
private String[] extractAndDecodeHeader(String header) throws IOException {

        byte[] base64Token = header.substring(6).getBytes("UTF-8");
        byte[] decoded;
        try {
            decoded = Base64.decode(base64Token);
        } catch (IllegalArgumentException e) {
            throw new BadCredentialsException("Failed to decode basic authentication token");
        }

        String token = new String(decoded, "UTF-8");

        int delim = token.indexOf(":");

        if (delim == -1) {
            throw new BadCredentialsException("Invalid basic authentication token");
        }
        return new String[] {token.substring(0, delim), token.substring(delim + 1)};
    }
 
開發者ID:gravitee-io,項目名稱:graviteeio-access-management,代碼行數:20,代碼來源:ClientAwareAuthenticationDetailsSource.java

示例5: extractAndDecodeHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
private String[] extractAndDecodeHeader(String header, HttpServletRequest request)
		throws IOException {

	byte[] base64Token = header.substring(6).getBytes("UTF-8");
	byte[] decoded;
	try {
		decoded = Base64.decode(base64Token);
	}
	catch (IllegalArgumentException e) {
		throw new BadCredentialsException(
				"Failed to decode basic authentication token");
	}

	String token = new String(decoded, getCredentialsCharset(request));

	int delim = token.indexOf(":");

	if (delim == -1) {
		throw new BadCredentialsException("Invalid basic authentication token");
	}
	return new String[] { token.substring(0, delim), token.substring(delim + 1) };
}
 
開發者ID:KonkerLabs,項目名稱:konker-platform,代碼行數:23,代碼來源:KonkerBasicAuthenticationFilter.java

示例6: Desencriptar

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
public static String Desencriptar(String textoEncriptado) throws Exception {

     
       String base64EncryptedString = "";

       try {
           byte[] message = Base64.decode(textoEncriptado.getBytes("utf-8"));
           MessageDigest md = MessageDigest.getInstance("MD5");
           byte[] digestOfPassword = md.digest(secretKey.getBytes("utf-8"));
           byte[] keyBytes = Arrays.copyOf(digestOfPassword, 24);
           SecretKey key = new SecretKeySpec(keyBytes, "DESede");

           Cipher decipher = Cipher.getInstance("DESede");
           decipher.init(Cipher.DECRYPT_MODE, key);

           byte[] plainText = decipher.doFinal(message);

           base64EncryptedString = new String(plainText, "UTF-8");

       } catch (Exception ex) {
       }
       return base64EncryptedString;
   }
 
開發者ID:dovier,項目名稱:coj-web,代碼行數:24,代碼來源:TokenUtils.java

示例7: extractAndDecodeHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
/**
 * Decodes the header into a username and password.
 *
 * @throws org.springframework.security.authentication.BadCredentialsException if the Basic header is not present or is not valid Base64
 */
private String[] extractAndDecodeHeader(String header, HttpServletRequest request) throws IOException {

    byte[] base64Token = header.substring(6).getBytes("UTF-8");
    byte[] decoded;
    try {
        decoded = Base64.decode(base64Token);
    } catch (IllegalArgumentException e) {
        throw new BadCredentialsException("Failed to decode basic authentication token");
    }

    String token = new String(decoded, getCredentialsCharset(request));

    int delim = token.indexOf(":");

    if (delim == -1) {
        throw new BadCredentialsException("Invalid basic authentication token");
    }
    return new String[] {token.substring(0, delim), token.substring(delim + 1)};
}
 
開發者ID:oreumio,項目名稱:rest,代碼行數:25,代碼來源:MyBasicAuthenticationFilter.java

示例8: extractAndDecodeHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
/**
 * Decodes the header into a username and password.
 * 
 * @throws BadCredentialsException
 *             if the Basic header is not present or is not valid Base64
 */
private String[] extractAndDecodeHeader(String header, HttpServletRequest request) {
	try {
		byte[] base64Token = header.substring(AUTHORIZATION_PREFIX.length()).getBytes("UTF-8");
		byte[] decoded;
		try {
			decoded = Base64.decode(base64Token);
		} catch (IllegalArgumentException e) {
			throw new BadCredentialsException("Failed to decode basic authentication token");
		}

		String token = new String(decoded, getCredentialsCharset(request));

		int delim = token.indexOf(":");

		if (delim == -1) {
			throw new BadCredentialsException("Invalid basic authentication token");
		}
		return new String[] { token.substring(0, delim), token.substring(delim + 1) };
	} catch (IOException ioe) {
		throw new RuntimeException("Failed to decode auth tokens");
	}
}
 
開發者ID:skarpushin,項目名稱:summerb,代碼行數:29,代碼來源:RestLoginFilter.java

示例9: extractAndDecodeHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
/**
 * Decodes the header into a username and password.
 *
 * @throws BadCredentialsException if the Basic header is not present or is not valid Base64
 */
private String[] extractAndDecodeHeader(String header) throws IOException {

    byte[] base64Token = header.substring(6).getBytes(CREDENTIALS_CHARSET);
    byte[] decoded;
    try {
        decoded = Base64.decode(base64Token);
    } catch (IllegalArgumentException e) {
        throw new BadCredentialsException("Failed to decode basic authentication token");
    }

    String token = new String(decoded, CREDENTIALS_CHARSET);

    int delim = token.indexOf(":");

    if (delim == -1) {
        throw new BadCredentialsException("Invalid basic authentication token");
    }
    return new String[] {token.substring(0, delim), token.substring(delim + 1)};
}
 
開發者ID:petrbouda,項目名稱:joyrest,代碼行數:25,代碼來源:BasicAuthenticator.java

示例10: obtainUserAndPasswordFromBasicAuthenticationHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
private String[] obtainUserAndPasswordFromBasicAuthenticationHeader(HttpServletRequest httpServletRequest) throws Exception{
    // Authorization header
    String authHeader = httpServletRequest.getHeader("Authorization");

    if (authHeader == null) {
        throw new BadCredentialsException("Authorization header not found");
    }

    // Decode the authorization string
    String token;
    try{
        //Excluded "Basic " initial string
        byte[] decoded = Base64.decode(authHeader.substring(6).getBytes());
        token = new String(decoded);
    } catch (IllegalArgumentException e) {
        throw new BadCredentialsException("Failed to decode basic authentication token");
    }

    int separator = token.indexOf(":");

    if (separator == -1) {
        throw new BadCredentialsException("Invalid basic authentication token");
    }
    return new String[] {token.substring(0, separator), token.substring(separator + 1)};
}
 
開發者ID:Appverse,項目名稱:appverse-server,代碼行數:26,代碼來源:BasicAuthenticationServiceImpl.java

示例11: checkBasicAuthorization

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
private void checkBasicAuthorization(String authorization, HttpServletResponse httpResponse) throws IOException {
	StringTokenizer tokenizer = new StringTokenizer(authorization);
	if (tokenizer.countTokens() < 2) {
		return;
	}
	if (!tokenizer.nextToken().equalsIgnoreCase("Basic")) {
		return;
	}

	String base64 = tokenizer.nextToken();
	String loginPassword = new String(Base64.decode(base64.getBytes(StandardCharsets.UTF_8)));

	System.out.println("loginPassword = " + loginPassword);
	tokenizer = new StringTokenizer(loginPassword, ":");
	System.out.println("tokenizer = " + tokenizer);
	checkUsernameAndPassword(tokenizer.nextToken(), tokenizer.nextToken(), httpResponse);
}
 
開發者ID:virgo47,項目名稱:restful-spring-security,代碼行數:18,代碼來源:TokenAuthenticationFilter.java

示例12: extractAndDecodeHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
private String[] extractAndDecodeHeader(String header) throws IOException
{
   if (header == null || header.isEmpty ())
   {
      return null;
   }
   byte[] base64Token = header.substring(6).getBytes("UTF-8");
   byte[] decoded;
   try
   {
      decoded = Base64.decode(base64Token);
   }
   catch (IllegalArgumentException e)
   {
      throw new BadCredentialsException(
         "Failed to decode basic authentication token.");
   }

   String token = new String(decoded, "UTF-8");

   int delim = token.indexOf(":");

   if (delim == -1)
   {
      throw new BadCredentialsException(
         "Invalid basic authentication token.");
   }
   return new String[]{token.substring(0,delim),token.substring(delim+1)};
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:30,代碼來源:AccessValve.java

示例13: extractAndDecodeHeader

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
private String[] extractAndDecodeHeader(String header) throws IOException
{
   if (header == null || header.isEmpty())
   {
      return null;
   }
   byte[] base64Token = header.substring(6).getBytes("UTF-8");
   byte[] decoded;
   try
   {
      decoded = Base64.decode(base64Token);
   }
   catch (IllegalArgumentException e)
   {
      throw new BadCredentialsException("Failed to decode basic authentication token.");
   }

   String token = new String(decoded, "UTF-8");

   int delim = token.indexOf(":");

   if (delim == -1)
   {
      throw new BadCredentialsException("Invalid basic authentication token.");
   }
   return new String[]
   {
      token.substring(0, delim), token.substring(delim + 1)
   };
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:31,代碼來源:ProcessingValve.java

示例14: fromString

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
private Object fromString(String s) throws IOException, ClassNotFoundException {
	byte[] data = Base64.decode(s.getBytes());
	ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(data));
	Object o = ois.readObject();
	ois.close();
	return o;
}
 
開發者ID:GovernIB,項目名稱:helium,代碼行數:8,代碼來源:ZonaperEventNotificacioHandler.java

示例15: checkBasicAuthorization

import org.springframework.security.crypto.codec.Base64; //導入方法依賴的package包/類
private void checkBasicAuthorization(String authorization, HttpServletResponse httpResponse) throws IOException {
    StringTokenizer tokenizer = new StringTokenizer(authorization);
    if (tokenizer.countTokens() < 2) {
        return;
    }
    if (!tokenizer.nextToken().equalsIgnoreCase("Basic")) {
        return;
    }

    String base64 = tokenizer.nextToken();
    String loginPassword = new String(Base64.decode(base64.getBytes(StandardCharsets.UTF_8)));

    tokenizer = new StringTokenizer(loginPassword, ":");
    checkUsernameAndPassword(tokenizer.nextToken(), tokenizer.nextToken(), httpResponse);
}
 
開發者ID:helicalinsight,項目名稱:helicalinsight,代碼行數:16,代碼來源:RestTokenAuthenticationFilter.java


注:本文中的org.springframework.security.crypto.codec.Base64.decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。