• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Base64Utils类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.axiom.util.base64.Base64Utils的典型用法代码示例。如果您正苦于以下问题:Java Base64Utils类的具体用法?Java Base64Utils怎么用?Java Base64Utils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Base64Utils类属于org.apache.axiom.util.base64包,在下文中一共展示了Base64Utils类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: calculateHmacSha1

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
/**
 * @param key
 * @param value
 * @return
 * @throws SignatureException
 */
public static String calculateHmacSha1(String key, String value) throws SignatureException {
    String result;
    try {
        SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), "HmacSHA1");
        Mac mac = Mac.getInstance("HmacSHA1");
        mac.init(signingKey);
        byte[] rawHmac = mac.doFinal(value.getBytes());
        result = Base64Utils.encode(rawHmac);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug("Failed to create the HMAC Signature", e);
        }
        throw new SignatureException("Failed to calculate HMAC : " + e.getMessage());
    }
    return result;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:IdentityApplicationManagementUtil.java


示例2: setBasicAccessSecurityHeaders

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
public static void setBasicAccessSecurityHeaders(String userName, String password, boolean rememberMe,
                                                 Options options) throws AxisFault {

    String userNamePassword = userName + ":" + password;
    String encodedString = Base64Utils.encode(userNamePassword.getBytes());

    String authorizationHeader = "Basic " + encodedString;

    List<Header> headers = new ArrayList<Header>();

    Header authHeader = new Header("Authorization", authorizationHeader);
    headers.add(authHeader);

    if (rememberMe) {
        Header rememberMeHeader = new Header("RememberMe", "true");
        headers.add(rememberMeHeader);
    }

    options.setProperty(HTTPConstants.HTTP_HEADERS, headers);
}
 
开发者ID:wso2,项目名称:carbon-business-process,代码行数:21,代码来源:ServiceUtils.java


示例3: init

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
@Override
/**
 *
 */
public void init(Property[] provisioningProperties) throws IdentityProvisioningException {
    Properties configs = new Properties();

    if (provisioningProperties != null && provisioningProperties.length > 0) {
        for (Property property : provisioningProperties) {

            if (GoogleConnectorConstants.PRIVATE_KEY.equals(property.getName())) {
                FileOutputStream fos = null;
                try {
                    byte[] decodedBytes = Base64Utils.decode(property.getValue());
                    googlePrvKey = new File("googlePrvKey");
                    fos = new FileOutputStream(googlePrvKey);
                    fos.write(decodedBytes);
                } catch (IOException e) {
                    log.error("Error while generating private key file object", e);
                }finally {
                    IdentityIOStreamUtils.flushOutputStream(fos);
                    IdentityIOStreamUtils.closeOutputStream(fos);
                }
            }
            configs.put(property.getName(), property.getValue());

            if (IdentityProvisioningConstants.JIT_PROVISIONING_ENABLED.equals(property
                                                                                      .getName()) && "1".equals(property.getValue())) {
                jitProvisioningEnabled = true;


            }
        }
    }

    configHolder = new GoogleProvisioningConnectorConfig(configs);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:38,代码来源:GoogleProvisioningConnector.java


示例4: decodeAuthorizationHeader

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
private String decodeAuthorizationHeader(String authorizationHeader) {
    String[] splitValues = authorizationHeader.trim().split(" ");
    byte[] decodedBytes = Base64Utils.decode(splitValues[1].trim());
    if (decodedBytes != null) {
        return new String(decodedBytes);
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Error decoding authorization header.");
        }
        return null;
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:13,代码来源:SignedJWTAuthenticator.java


示例5: extractCredentialsFromAuthzHeader

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
/**
 * Extracts the username and password info from the HTTP Authorization Header
 *
 * @param authorizationHeader "Basic " + base64encode(username + ":" + password)
 * @return String array with client id and client secret.
 * @throws org.wso2.carbon.identity.base.IdentityException If the decoded data is null.
 */
public static String[] extractCredentialsFromAuthzHeader(String authorizationHeader)
        throws OAuthClientException {
    String[] splitValues = authorizationHeader.trim().split(" ");
    if(splitValues.length == 2) {
        byte[] decodedBytes = Base64Utils.decode(splitValues[1].trim());
        if (decodedBytes != null) {
            String userNamePassword = new String(decodedBytes, Charsets.UTF_8);
            return userNamePassword.split(":");
        }
    }
    String errMsg = "Error decoding authorization header. Space delimited \"<authMethod> <base64Hash>\" format violated.";
    throw new OAuthClientException(errMsg);
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:21,代码来源:EndpointUtil.java


示例6: decodeAuthorizationHeader

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
private String decodeAuthorizationHeader(String authorizationHeader) {
    String[] splitValues = authorizationHeader.trim().split(" ");
    byte[] decodedBytes = Base64Utils.decode(splitValues[1].trim());
    if (decodedBytes != null) {
        return new String(decodedBytes);
    } else {
        log.debug(
                "Error decoding authorization header. Could not retrieve user name and password.");
        return null;
    }
}
 
开发者ID:apache,项目名称:stratos,代码行数:12,代码来源:SignedJWTAuthenticator.java


示例7: getSignedJWT

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
/**
 * @param jsonObj
 * @return Base64 encoded JWT
 */
public static String getSignedJWT(String jsonObj, ServiceProvider serviceProvider) {

    String oauthConsumerSecret = null;

    if (serviceProvider.getInboundAuthenticationConfig() != null
            && serviceProvider.getInboundAuthenticationConfig()
            .getInboundAuthenticationRequestConfigs() != null
            && serviceProvider.getInboundAuthenticationConfig()
            .getInboundAuthenticationRequestConfigs().length > 0) {

        InboundAuthenticationRequestConfig[] authReqConfigs = serviceProvider
                .getInboundAuthenticationConfig().getInboundAuthenticationRequestConfigs();

        for (InboundAuthenticationRequestConfig authReqConfig : authReqConfigs) {
            if ((IdentityApplicationConstants.OAuth2.NAME).equals(authReqConfig.getInboundAuthType())) {
                if (authReqConfig.getProperties() != null) {
                    for (Property property : authReqConfig.getProperties()) {
                        if ((IdentityApplicationConstants.OAuth2.OAUTH_CONSUMER_SECRET)
                                .equalsIgnoreCase(property.getName())) {
                            oauthConsumerSecret = property.getValue();
                            break;
                        }
                    }
                }
            }
        }

    }

    String jwtBody = "{\"iss\":\"wso2\",\"exp\":" + new Date().getTime() + 3000 + ",\"iat\":"
            + new Date().getTime() + "," + jsonObj + "}";
    String jwtHeader = "{\"typ\":\"JWT\", \"alg\":\"HS256\"}";

    if (oauthConsumerSecret == null) {
        jwtHeader = "{\"typ\":\"JWT\", \"alg\":\"none\"}";
    }

    String base64EncodedHeader = Base64Utils.encode(jwtHeader.getBytes());
    String base64EncodedBody = Base64Utils.encode(jwtBody.getBytes());

    if (log.isDebugEnabled()) {
        log.debug("JWT Header :" + jwtHeader);
        log.debug("JWT Body :" + jwtBody);
    }

    String assertion = base64EncodedHeader + "." + base64EncodedBody;

    if (oauthConsumerSecret == null) {
        return assertion + ".";
    } else {
        String signedAssertion;
        try {
            signedAssertion = calculateHmacSha1(oauthConsumerSecret, assertion);
            return assertion + "." + signedAssertion;
        } catch (SignatureException e) {
            log.error("Error while siging the assertion", e);
            return assertion + ".";
        }
    }
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:65,代码来源:IdentityApplicationManagementUtil.java


示例8: base64Encode

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
public static String base64Encode(byte[] bytes) {
	return Base64Utils.encode(bytes);
}
 
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:4,代码来源:OpenIDUtils.java


示例9: doAuthentication

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
private void doAuthentication(HttpServletRequest req, HttpServletResponse resp) throws EntitlementCacheUpdateServletException {
    String username = req.getParameter(USERNAME_STRING);
    String password = req.getParameter(PSWD_STRING);
    String remoteIp = req.getServerName();

    if (authenticate(username, password, remoteIp)) {

        RequestDispatcher requestDispatcher = req.getRequestDispatcher(UPDATE_CACHE);
        String subjectScope = EntitlementCacheUpdateServletDataHolder.getInstance().getServletConfig().getServletContext()
                .getInitParameter(SUBJECT_SCOPE);
        String subjectAttributeName = EntitlementCacheUpdateServletDataHolder.getInstance().getServletConfig().getServletContext()
                .getInitParameter("subjectAttributeName");

        if (subjectScope.equals(EntitlementConstants.REQUEST_PARAM)) {

            requestDispatcher = req.getRequestDispatcher(UPDATE_CACHE + "?" + subjectAttributeName + "=" + username);

        } else if (subjectScope.equals(EntitlementConstants.REQUEST_ATTIBUTE)) {

            req.setAttribute(subjectAttributeName, username);

        } else if (subjectScope.equals(EntitlementConstants.SESSION)) {

            req.getSession().setAttribute(subjectAttributeName, username);

        } else {

            resp.setHeader("Authorization", Base64Utils.encode((username + ":" + password).getBytes(Charset.forName("UTF-8"))));
        }

        try {
            requestDispatcher.forward(req, resp);
        } catch (Exception e) {
            log.error("Error occurred while dispatching request to /updateCacheAuth.do", e);
            throw new EntitlementCacheUpdateServletException("Error occurred while dispatching request to /updateCacheAuth.do", e);
        }

    } else {
        showAuthPage(req, resp);
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:42,代码来源:EntitlementCacheUpdateServlet.java


示例10: readObject

import org.apache.axiom.util.base64.Base64Utils; //导入依赖的package包/类
private Object readObject(ParameterType paramType, OMElement node, boolean client) throws Exception {
    switch (paramType.getType()) {
        case BOOLEAN:
        case DOUBLE:
        case FLOAT:
        case INT:
        case LONG:
        case STRING:
        case ENUM:
        case DATE:
        case BYTE:
            return node == null ? null : readSimpleObject(paramType, node.getLocalName(), node.getText(), client);
        case OBJECT:
            //descend - note possibly two levels if inside a collection recursion
            OMElement _copy = this.currentNode;
            currentNode = node;

            Transcribable t = (Transcribable)paramType.getImplementationClass().newInstance();
            t.transcribe(this, TranscribableParams.getAll(), client);

            //ascend
            this.currentNode = _copy;
            return t;
        case MAP:
            Map map = new HashMap();
            for (Iterator i = node.getChildElements(); i.hasNext();) {
                OMElement element = (OMElement)i.next();
                Object key = readSimpleObject(paramType.getComponentTypes()[0],  node.getLocalName(), element.getAttributeValue(keyAttName), client);
                map.put(key, readObject(paramType.getComponentTypes()[1], (OMElement)element.getChildElements().next(), client));
            }
            return map;
        case LIST:
            if (paramType.getComponentTypes()[0].getType() == ParameterType.Type.BYTE) {
                try {
                    return Base64Utils.decode(node.getText());
                } catch (Exception e) {
                    String message = "Unable to parse " + node.getText() + " as type " + paramType;
                    LOGGER.debug(message, e);
                    throw CougarMarshallingException.unmarshallingException("soap",message,e,client);
                }
            } else {
                List list = new ArrayList();
                for (Iterator i = node.getChildElements(); i.hasNext();) {
                    list.add(readObject(paramType.getComponentTypes()[0], (OMElement)i.next(),client));
                }
                return list;
            }
        case SET:
            Set set = new HashSet();
            for (Iterator i = node.getChildElements(); i.hasNext();) {
                set.add(readObject(paramType.getComponentTypes()[0], (OMElement)i.next(),client));
            }
            return set;
    }
    return null;
}
 
开发者ID:betfair,项目名称:cougar,代码行数:57,代码来源:XMLTranscriptionInput.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DataSourceType类代码示例发布时间:2022-05-22
下一篇:
Java CommandBlockBaseLogic类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap