当前位置: 首页>>代码示例>>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;未经允许,请勿转载。