本文整理匯總了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;
}