当前位置: 首页>>代码示例>>Java>>正文


Java Base64.decode方法代码示例

本文整理汇总了Java中org.apache.axiom.om.util.Base64.decode方法的典型用法代码示例。如果您正苦于以下问题:Java Base64.decode方法的具体用法?Java Base64.decode怎么用?Java Base64.decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.axiom.om.util.Base64的用法示例。


在下文中一共展示了Base64.decode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSamplePrivateKey

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
public static PrivateKey getSamplePrivateKey() throws Exception {
    // Read in the key into a String
    StringBuilder pkcs8Lines = new StringBuilder();
    BufferedReader rdr = new BufferedReader(new StringReader(PRIVATE_KEY));
    String line;
    while ((line = rdr.readLine()) != null) {
        pkcs8Lines.append(line);
    }

    // Remove the "BEGIN" and "END" lines, as well as any whitespace

    String pkcs8Pem = pkcs8Lines.toString();
    pkcs8Pem = pkcs8Pem.replace("-----BEGIN PRIVATE KEY-----", "");
    pkcs8Pem = pkcs8Pem.replace("-----END PRIVATE KEY-----", "");
    pkcs8Pem = pkcs8Pem.replaceAll("\\s+", "");

    // Base64 decode the result

    byte[] pkcs8EncodedBytes = Base64.decode(pkcs8Pem);

    // extract the private key

    PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(pkcs8EncodedBytes);
    KeyFactory kf = KeyFactory.getInstance("RSA");
    return kf.generatePrivate(keySpec);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:27,代码来源:ReadCertStoreSampleUtil.java

示例2: generateThumbPrint

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
/**
 * Generate thumbprint of certificate
 *
 * @param encodedCert Base64 encoded certificate
 * @return Certificate thumbprint
 * @throws java.security.NoSuchAlgorithmException Unsupported hash algorithm
 */
public static String generateThumbPrint(String encodedCert) throws NoSuchAlgorithmException {

    if (encodedCert != null) {
        MessageDigest digestValue = null;
        digestValue = MessageDigest.getInstance("SHA-1");
        byte[] der = Base64.decode(encodedCert);
        digestValue.update(der);
        byte[] digestInBytes = digestValue.digest();
        String publicCertThumbprint = hexify(digestInBytes);
        return publicCertThumbprint;
    } else {
        String errorMsg = "Invalid encoded certificate: \'NULL\'";
        log.debug(errorMsg);
        throw new IllegalArgumentException(errorMsg);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:IdentityApplicationManagementUtil.java

示例3: getCertData

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
/**
 * @param encodedCert
 * @return
 * @throws CertificateException
 */
public static CertData getCertData(String encodedCert) throws CertificateException {

    if (encodedCert != null) {
        byte[] bytes = Base64.decode(encodedCert);
        CertificateFactory factory = CertificateFactory.getInstance("X.509");
        X509Certificate cert = (X509Certificate) factory
                .generateCertificate(new ByteArrayInputStream(bytes));
        Format formatter = new SimpleDateFormat("dd/MM/yyyy");
        return fillCertData(cert, formatter);
    } else {
        String errorMsg = "Invalid encoded certificate: \'NULL\'";
        log.debug(errorMsg);
        throw new IllegalArgumentException(errorMsg);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:IdentityApplicationManagementUtil.java

示例4: decodeCertificate

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
/**
 * Generate thumbprint of certificate
 *
 * @param encodedCert Base64 encoded certificate
 * @return Decoded <code>Certificate</code>
 * @throws java.security.cert.CertificateException Error when decoding certificate
 */
public static Certificate decodeCertificate(String encodedCert) throws CertificateException {

    if (encodedCert != null) {
        byte[] bytes = Base64.decode(encodedCert);
        CertificateFactory factory = CertificateFactory.getInstance("X.509");
        X509Certificate cert = (X509Certificate) factory
                .generateCertificate(new ByteArrayInputStream(bytes));
        return cert;
    } else {
        String errorMsg = "Invalid encoded certificate: \'NULL\'";
        log.debug(errorMsg);
        throw new IllegalArgumentException(errorMsg);
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:22,代码来源:IdentityApplicationManagementUtil.java

示例5: decodeBase64

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
/**
 * decode the base64 encoded string
 * @param encodedString
 * @return
 */
public static String decodeBase64(String encodedString){
    // decode it and extract username and password
    byte[] decodedAuthHeader = Base64.decode(encodedString.split(" ")[1]);
    String authHeader = new String(decodedAuthHeader);
    String userName = authHeader.split(":")[0];
    return userName;
}
 
开发者ID:Vindulamj,项目名称:scim-inbound-provisioning-scim2,代码行数:13,代码来源:SupportUtils.java

示例6: convertToBase64Binary

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
public static javax.activation.DataHandler convertToBase64Binary(String s) {
    // reusing the byteArrayDataSource from the Axiom classes
    if ((s == null) || s.equals("")){
        return null;
    }
    ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(
            Base64.decode(s)
    );
    return new DataHandler(byteArrayDataSource);
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:11,代码来源:ConverterUtil.java

示例7: isAuthenticated

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
public boolean isAuthenticated(Message message, ClassResourceInfo classResourceInfo) {
    // extract authorization header and authenticate.
    // get the map of protocol headers
    Map protocolHeaders = (TreeMap) message.get(Message.PROTOCOL_HEADERS);
    // get the value for Authorization Header
    List authzHeaders = (ArrayList) protocolHeaders
            .get(EntitlementEndpointConstants.AUTHORIZATION_HEADER);
    if (authzHeaders != null) {
        // get the authorization header value, if provided
        String authzHeader = (String) authzHeaders.get(0);

        // decode it and extract username and password
        byte[] decodedAuthHeader = Base64.decode(authzHeader.split(" ")[1]);
        String authHeader = new String(decodedAuthHeader);
        String userName = authHeader.split(":")[0];
        String password = authHeader.split(":")[1];
        if (userName != null && password != null) {
            String tenantDomain = MultitenantUtils.getTenantDomain(userName);
            String tenantLessUserName = MultitenantUtils.getTenantAwareUsername(userName);

            try {
                // get super tenant context and get realm service which is an osgi service
                RealmService realmService = (RealmService) PrivilegedCarbonContext
                        .getThreadLocalCarbonContext().getOSGiService(RealmService.class);
                if (realmService != null) {
                    int tenantId = realmService.getTenantManager().getTenantId(tenantDomain);
                    if (tenantId == -1) {
                        log.error("Invalid tenant domain " + tenantDomain);
                        return false;
                    }
                    // get tenant's user realm
                    UserRealm userRealm = realmService.getTenantUserRealm(tenantId);
                    boolean authenticated = userRealm.getUserStoreManager().authenticate(
                            tenantLessUserName, password);
                    if (authenticated) {
                        // authentication success. set the username for authorization header and
                        // proceed the REST call
                        authzHeaders.set(0, userName);
                        return true;
                    } else {
                        log.error("Authentication failed for the user: " + tenantLessUserName
                                + "@" + tenantDomain);
                        return false;
                    }
                } else {
                    log.error("Error in getting Realm Service for user: " + userName);
                    return false;
                }
            } catch (UserStoreException e) {
                log.error("Internal server error while authenticating the user.");
                return false;
            }
        } else {
            log.error("Authentication required for this resource. " +
                            "Username or password not provided.");
            return false;
        }
    } else {
        log.error("Authentication required for this resource. " +
                      "Authorization header not present in the request.");
        return false;
    }

}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:65,代码来源:BasicAuthHandler.java

示例8: addKeyStore

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
public void addKeyStore(String fileData, String filename, String password, String provider,
                        String type, String pvtkeyPass) throws SecurityConfigException {
    byte[] content = Base64.decode(fileData);
    addKeyStore(content, filename, password, provider, type, pvtkeyPass);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:6,代码来源:KeyStoreAdmin.java

示例9: addTrustStore

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
public void addTrustStore(String fileData, String filename, String password, String provider,
                          String type) throws SecurityConfigException {
    byte[] content = Base64.decode(fileData);
    addTrustStore(content, filename, password, provider, type);
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:6,代码来源:KeyStoreAdmin.java

示例10: processObject

import org.apache.axiom.om.util.Base64; //导入方法依赖的package包/类
public static Object processObject(OMElement omElement,
                                   Class classType,
                                   MultirefHelper helper,
                                   boolean isArrayType,
                                   ObjectSupplier objectSupplier,
                                   Type generictype) throws AxisFault {
    boolean hasRef = false;
    OMAttribute omatribute = MultirefHelper.processRefAtt(omElement);
    String ref = null;
    if (omatribute != null) {
        hasRef = true;
        ref = MultirefHelper.getAttvalue(omatribute);
    }
    if (OMElement.class.isAssignableFrom(classType)) {
        if (hasRef) {
            OMElement elemnt = helper.getOMElement(ref);
            if (elemnt == null) {
                return helper.processOMElementRef(ref);
            } else {
                return elemnt;
            }
        } else
            return omElement;
    } else {
        if (hasRef) {
            if (helper.getObject(ref) != null) {
                return helper.getObject(ref);
            } else {
                return helper.processRef(classType, ref, objectSupplier);
            }
        } else {
            OMAttribute attribute = omElement.getAttribute(
                    new QName("http://www.w3.org/2001/XMLSchema-instance", "nil", "xsi"));
            if (attribute != null) {
                return null;
            }
            if (SimpleTypeMapper.isSimpleType(classType)) {
                if (isArrayType && "byte".equals(classType.getName())) {
                    String value = omElement.getText();
                    return Base64.decode(value);
                } else {
                    return getSimpleTypeObjectChecked(classType, omElement);
                }
            } else if (SimpleTypeMapper.isCollection(classType)) {
                if (generictype != null && (generictype instanceof ParameterizedType)) {
                    ParameterizedType aType = (ParameterizedType) generictype;
                    Type[] parameterArgTypes = aType.getActualTypeArguments();
                    Type parameter = parameterArgTypes[0];
                    Iterator parts = omElement.getChildElements();
                    return ProcessGenericsElement((Class) parameter, omElement, helper, parts, objectSupplier, generictype);
                }
                return SimpleTypeMapper.getArrayList(omElement);
            } else if (SimpleTypeMapper.isDataHandler(classType)) {
                return SimpleTypeMapper.getDataHandler(omElement);
            } else {
                return BeanUtil.deserialize(classType, omElement, objectSupplier, null);
            }
        }
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:61,代码来源:BeanUtil.java


注:本文中的org.apache.axiom.om.util.Base64.decode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。