本文整理汇总了Java中com.sun.org.apache.xml.internal.security.utils.Base64类的典型用法代码示例。如果您正苦于以下问题:Java Base64类的具体用法?Java Base64怎么用?Java Base64使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Base64类属于com.sun.org.apache.xml.internal.security.utils包,在下文中一共展示了Base64类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAllFilesHash
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
private Set<MFEntry> getAllFilesHash(JarFile jar) throws Exception {
Set<MFEntry> fileSet = new HashSet<MFEntry>();
Enumeration<java.util.jar.JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
java.util.jar.JarEntry entry = entries.nextElement();
String entryName = entry.getName();
MFEntry mf = new MFEntry();
if (!entry.isDirectory() && !entryName.endsWith(".MF") && !entryName.endsWith(".SF")
&& !entryName.endsWith(".RSA") && !entryName.endsWith(".DSA") && !entryName.endsWith(".EC")) {
InputStream ios = jar.getInputStream(entry);
byte[] b = new byte[ios.available()];
Streams.readFully(ios, b);
mf.setFileName(entry.getName());
mf.setDigestValue(
java.util.Base64.getEncoder().encodeToString(EncryptUtils.sha(b, getShaTypeByMFFile())));
collectJarFileName.add(entry.getName());
fileSet.add(mf);
ios.close();
}
}
return fileSet;
}
示例2: DOMSignatureValue
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
DOMSignatureValue(Element sigValueElem, XMLCryptoContext context)
throws MarshalException
{
try {
// base64 decode signatureValue
value = Base64.decode(sigValueElem);
} catch (Base64DecodingException bde) {
throw new MarshalException(bde);
}
Attr attr = sigValueElem.getAttributeNodeNS(null, "Id");
if (attr != null) {
id = attr.getValue();
sigValueElem.setIdAttributeNode(attr, true);
} else {
id = null;
}
this.sigValueElem = sigValueElem;
}
示例3: validate
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
public boolean validate(XMLValidateContext validateContext)
throws XMLSignatureException
{
if (validateContext == null) {
throw new NullPointerException("validateContext cannot be null");
}
if (validated) {
return validationStatus;
}
Data data = dereference(validateContext);
calcDigestValue = transform(data, validateContext);
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Expected digest: " + Base64.encode(digestValue));
log.log(java.util.logging.Level.FINE, "Actual digest: " + Base64.encode(calcDigestValue));
}
validationStatus = Arrays.equals(digestValue, calcDigestValue);
validated = true;
return validationStatus;
}
示例4: verify
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
/**
* Tests reference validation is success or false
*
* @return true if reference validation is success, otherwise false
* @throws ReferenceNotInitializedException
* @throws XMLSecurityException
*/
public boolean verify()
throws ReferenceNotInitializedException, XMLSecurityException {
byte[] elemDig = this.getDigestValue();
byte[] calcDig = this.calculateDigest(true);
boolean equal = MessageDigestAlgorithm.isEqual(elemDig, calcDig);
if (!equal) {
log.log(java.util.logging.Level.WARNING, "Verification failed for URI \"" + this.getURI() + "\"");
log.log(java.util.logging.Level.WARNING, "Expected Digest: " + Base64.encode(elemDig));
log.log(java.util.logging.Level.WARNING, "Actual Digest: " + Base64.encode(calcDig));
} else {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Verification successful for URI \"" + this.getURI() + "\"");
}
}
return equal;
}
示例5: setSignatureValueElement
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
/**
* Base64 encodes and sets the bytes as the content of the SignatureValue
* Node.
*
* @param bytes bytes to be used by SignatureValue before Base64 encoding
*/
private void setSignatureValueElement(byte[] bytes) {
while (signatureValueElement.hasChildNodes()) {
signatureValueElement.removeChild(signatureValueElement.getFirstChild());
}
String base64codedValue = Base64.encode(bytes);
if (base64codedValue.length() > 76 && !XMLUtils.ignoreLineBreaks()) {
base64codedValue = "\n" + base64codedValue + "\n";
}
Text t = this.doc.createTextNode(base64codedValue);
signatureValueElement.appendChild(t);
}
示例6: main
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
/**
* Method main
*
* @param unused
* @throws Exception
*/
public static void main(String unused[]) throws Exception {
CertsInFilesystemDirectoryResolver krs =
new CertsInFilesystemDirectoryResolver(
"data/ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/certs");
for (Iterator<Certificate> i = krs.getIterator(); i.hasNext(); ) {
X509Certificate cert = (X509Certificate) i.next();
byte[] ski =
com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI.getSKIBytesFromCert(cert);
System.out.println();
System.out.println("Base64(SKI())= \""
+ Base64.encode(ski) + "\"");
System.out.println("cert.getSerialNumber()= \""
+ cert.getSerialNumber().toString() + "\"");
System.out.println("cert.getSubjectX500Principal().getName()= \""
+ cert.getSubjectX500Principal().getName() + "\"");
System.out.println("cert.getIssuerX500Principal().getName()= \""
+ cert.getIssuerX500Principal().getName() + "\"");
}
}
示例7: getAsObject
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
public Object getAsObject(FacesContext context, UIComponent component, String value) {
Object obj;
try {
int underScoreIndice = value.indexOf("_");
String className = value.substring(0, underScoreIndice);
String serializedObj = value.substring(underScoreIndice + 1, value.length());
byte[] byteObj = Base64.decode(serializedObj.getBytes());
ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(byteObj));
obj = ois.readObject();
ois.close();
}
catch (Exception e) {
throw new ConverterException("Transient object cannot be read from stream.");
}
return obj;
}
示例8: getAsString
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
public String getAsString(FacesContext context, UIComponent component, Object value) {
String retValue = null;
if ((value != null) && (value instanceof Identifiable)) {
Identifiable identifiable = (Identifiable) value;
String className = identifiable.getClass().getName();
if (identifiable.getId() == null) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput output = new ObjectOutputStream(bos);
output.writeObject(identifiable);
byte[] byteArr = bos.toByteArray();
String stream = Base64.encode(byteArr);
retValue = identifiable.getClass().getName() + "_" + stream;
}
catch (IOException e) {
throw new ConverterException("Transient object cannot be output to the stream: " + identifiable.getClass() + ".");
}
}
return retValue;
}
throw new ConverterException("Object is null or not implemented Identifiable interface.");
}
示例9: supports
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
@Override
public boolean supports(AuthenticationToken token) {
try {
UsernamePasswordToken upt = (UsernamePasswordToken) token;
String username = upt.getUsername();
char[] password = upt.getPassword();
List<SecurityUserEntity> lists = template.query(
"select * from security_user where username=?",
new Object[] { username }, new SecurityUserEntity());
if (lists != null && lists.size() > 0) {
SecurityUserEntity entity = lists.get(0);
byte[] keyBytes = entity.getKey();
if (new String(password).equals(new String(Base64
.decode(aesCipherService.decrypt(
Base64.decode(entity.getPassword()), keyBytes)
.toBase64())))) {
return true;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
示例10: writeEncodedBinary
import com.sun.org.apache.xml.internal.security.utils.Base64; //导入依赖的package包/类
protected int writeEncodedBinary(int lastlinelen, byte[] buf, String newline, OutputStream os) throws Exception {
String encoded = Base64.encode(buf).replaceAll("\r", "").replaceAll("\n", "");
int strlen = encoded.length();
if (lastlinelen + strlen < 76) {
os.write(encoded.getBytes());
lastlinelen += strlen;
} else {
String tmpS = encoded.substring(0, 76 - lastlinelen);
os.write(tmpS.getBytes());
os.write(newline.getBytes());
encoded = encoded.substring(tmpS.length());
lastlinelen = 0;
while (encoded.length() >= 76) {
tmpS = encoded.substring(0, 76 - lastlinelen);
os.write(tmpS.getBytes());
os.write(newline.getBytes());
encoded = encoded.substring(tmpS.length());
}
if (encoded.length() > 0) {
os.write(encoded.getBytes());
lastlinelen = encoded.length();
}
}
return lastlinelen;
}