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


Java WSConstants.UT属性代码示例

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


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

示例1: getUsernameTokenPrincipal

/**
 * Returns the UsernameTokenPrincipal from the security results.
 *
 * @param mc The message context of the message
 * @return the UsernameTokenPrincipal from the security results as an
 * <code>org.apache.ws.security.WSUsernameTokenPrincipal</code>.
 * If a wsse:UsernameToken was not present in the wsse:Security header then
 * <code>null</code> will be returned.
 * @throws Exception If there are no security results.
 * @see org.apache.ws.security.WSUsernameTokenPrincipal
 */
public static WSUsernameTokenPrincipal getUsernameTokenPrincipal(
        MessageContext mc) throws Exception {

    Vector results;
    if ((results = (Vector) mc.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) {
        throw new Exception("No security results available in the message context");
    } else {
        for (int i = 0; i < results.size(); i++) {
            WSHandlerResult rResult = (WSHandlerResult) results.get(i);
            Vector wsSecEngineResults = rResult.getResults();
            for (int j = 0; j < wsSecEngineResults.size(); j++) {
                WSSecurityEngineResult wser =
                        (WSSecurityEngineResult) wsSecEngineResults.get(j);

                Integer actInt = (Integer) wser
                        .get(WSSecurityEngineResult.TAG_ACTION);
                if (actInt.intValue() == WSConstants.UT) {
                    return (WSUsernameTokenPrincipal) wser
                            .get(WSSecurityEngineResult.TAG_PRINCIPAL);
                }
            }
        }
    }
    return null;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:36,代码来源:WSS4JUtil.java

示例2: constructPasswordCallback

private WSPasswordCallback constructPasswordCallback(
        String username,
        int doAction
) throws WSSecurityException {

    int reason = WSPasswordCallback.UNKNOWN;

    switch (doAction) {
    case WSConstants.UT:
    case WSConstants.UT_SIGN:
        reason = WSPasswordCallback.USERNAME_TOKEN;
        break;
    case WSConstants.SIGN:
        reason = WSPasswordCallback.SIGNATURE;
        break;
    case WSConstants.ENCR:
        reason = WSPasswordCallback.KEY_NAME;
        break;
    }
    return new WSPasswordCallback(username, reason);
}
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:21,代码来源:WSHandler.java

示例3: readAuthenticationMechanism

/**
 * @param data
 * @throws IdentityProviderException
 */
@Override
protected void readAuthenticationMechanism(RahasData data) throws IdentityProviderException {
    MessageContext inContext = null;
    Vector results = null;

    if (log.isDebugEnabled()) {
        log.debug("Reading authentication mechanism");
    }

    inContext = data.getInMessageContext();

    if ((results = (Vector) inContext.getProperty(WSHandlerConstants.RECV_RESULTS)) == null) {
        log.error("Missing authentication mechanism");
        throw new IdentityProviderException("Missing authentication mechanism");
    } else {
        for (int i = 0; i < results.size(); i++) {
            WSHandlerResult rResult = (WSHandlerResult) results.get(i);
            Vector wsSecEngineResults = rResult.getResults();

            for (int j = 0; j < wsSecEngineResults.size(); j++) {
                WSSecurityEngineResult wser = (WSSecurityEngineResult) wsSecEngineResults.get(j);
                int action = ((Integer) wser.get(WSSecurityEngineResult.TAG_ACTION)).intValue();
                if (action == WSConstants.ST_UNSIGNED) {

                    this.authMechanism = IdentityConstants.AUTH_TYPE_SELF_ISSUED;
                    this.assertion = (SAMLAssertion) wser.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
                } else if (action == WSConstants.UT && wser.get(WSSecurityEngineResult.TAG_PRINCIPAL) != null) {
                    this.authMechanism = IdentityConstants.AUTH_TYPE_USERNAME_TOKEN;
                }
            }
        }
    }
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:37,代码来源:IdentityProviderData.java

示例4: decodeAction

public static int decodeAction(String action, Vector actions) throws WSSecurityException {

        int doAction = 0;
        if (action == null) {
            return doAction;
        }
        String single[] = StringUtil.split(action, ' ');
        for (int i = 0; i < single.length; i++) {
            if (single[i].equals(WSHandlerConstants.NO_SECURITY)) {
                doAction = WSConstants.NO_SECURITY;
                return doAction;
            } else if (single[i].equals(WSHandlerConstants.USERNAME_TOKEN)) {
                doAction |= WSConstants.UT;
                actions.add(new Integer(WSConstants.UT));
            } else if (single[i].equals(WSHandlerConstants.SIGNATURE)) {
                doAction |= WSConstants.SIGN;
                actions.add(new Integer(WSConstants.SIGN));
            } else if (single[i].equals(WSHandlerConstants.ENCRYPT)) {
                doAction |= WSConstants.ENCR;
                actions.add(new Integer(WSConstants.ENCR));
            } else if (single[i].equals(WSHandlerConstants.SAML_TOKEN_UNSIGNED)) {
                doAction |= WSConstants.ST_UNSIGNED;
                actions.add(new Integer(WSConstants.ST_UNSIGNED));
            } else if (single[i].equals(WSHandlerConstants.SAML_TOKEN_SIGNED)) {
                doAction |= WSConstants.ST_SIGNED;
                actions.add(new Integer(WSConstants.ST_SIGNED));
            } else if (single[i].equals(WSHandlerConstants.TIMESTAMP)) {
                doAction |= WSConstants.TS;
                actions.add(new Integer(WSConstants.TS));
            } else if (single[i].equals(WSHandlerConstants.NO_SERIALIZATION)) {
                doAction |= WSConstants.NO_SERIALIZE;
                actions.add(new Integer(WSConstants.NO_SERIALIZE));
            } else if (single[i].equals(WSHandlerConstants.SIGN_WITH_UT_KEY)) {
                doAction |= WSConstants.UT_SIGN;
                actions.add(new Integer(WSConstants.UT_SIGN));
            } else if (single[i].equals(WSHandlerConstants.ENABLE_SIGNATURE_CONFIRMATION)) {
                doAction |= WSConstants.SC;
                actions.add(new Integer(WSConstants.SC));
            } else {
                throw new WSSecurityException(
                    "Unknown action defined: " + single[i]
                );
            }
        }
        return doAction;
    }
 
开发者ID:wso2,项目名称:wso2-wss4j,代码行数:46,代码来源:WSSecurityUtil.java


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