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


Java MessageExtension类代码示例

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


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

示例1: addSReg

import org.openid4java.message.MessageExtension; //导入依赖的package包/类
/**
 * Add Simple Register extension message to the response message.
 * 
 * @param response
 *            the response message to add to
 * @param persona
 *            the persona
 * @throws MessageException
 *             if add extension failed
 */
private void addSReg(final Message response, final Persona persona)
		throws MessageException {
	if (authRequest.hasExtension(SRegMessage.OPENID_NS_SREG)) {
		MessageExtension ext = authRequest
				.getExtension(SRegMessage.OPENID_NS_SREG);
		if (ext instanceof SRegRequest) {
			SRegRequest sregReq = (SRegRequest) ext;
			// data released by the user
			if (persona != null) {
				Map<String, String> userDataSReg = persona.toAliasValueMap();

				SRegResponse sregResp = SRegResponse.createSRegResponse(
						sregReq, userDataSReg);
				// (alternatively) manually add attribute values
				// sregResp.addAttribute("email", email);
				response.addExtension(sregResp);
			}
		} else {
			throw new UnsupportedOperationException(ext.getClass()
					+ " is unsupported.");
		}
	}
}
 
开发者ID:sutra,项目名称:openid-server,代码行数:34,代码来源:ApprovingRequestProcessor.java

示例2: getExtension

import org.openid4java.message.MessageExtension; //导入依赖的package包/类
/**
 * Instantiates the apropriate Simple Registration object
 * (request / response) for the supplied parameter list.
 *
 * Similar to SRegMessage.getExtension(), but sets the SREG 1.1 type URI.
 *
 * @param parameterList         The Simple Registration specific parameters
 *                              (without the openid.<ext_alias> prefix)
 *                              extracted from the openid message.
 * @param isRequest             Indicates whether the parameters were
 *                              extracted from an OpenID request (true),
 *                              or from an OpenID response.
 * @return                      MessageExtension implementation for
 *                              the supplied extension parameters.
 * @throws MessageException     If a Simple Registration object could not be
 *                              instantiated from the supplied parameter list.
 */
public MessageExtension getExtension(
        ParameterList parameterList, boolean isRequest)
        throws MessageException
{
    SRegMessage sreg;

    if ( parameterList.hasParameter("required") ||
         parameterList.hasParameter("optional"))

        sreg = SRegRequest.createSRegRequest(parameterList);

    else
        sreg = SRegResponse.createSRegResponse(parameterList);

    sreg.setTypeUri(SRegMessage.OPENID_NS_SREG11);

    return sreg;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:36,代码来源:SReg11ExtensionFactory.java

示例3: receiveSimpleRegistration

import org.openid4java.message.MessageExtension; //导入依赖的package包/类
/**
 * @param httpReq
 * @param authSuccess
 * @throws MessageException 
 */
private void receiveSimpleRegistration(HttpServletRequest httpReq,
		AuthSuccess authSuccess) throws MessageException {
	if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
		MessageExtension ext = authSuccess
				.getExtension(SRegMessage.OPENID_NS_SREG);
		if (ext instanceof SRegResponse) {
			SRegResponse sregResp = (SRegResponse) ext;
			for (Iterator iter = sregResp.getAttributeNames()
					.iterator(); iter.hasNext();) {
				String name = (String) iter.next();
				String value = sregResp.getParameterValue(name);
				httpReq.setAttribute(name, value);
			}
		}
	}
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:22,代码来源:ConsumerServlet.java

示例4: processSRegExtension

import org.openid4java.message.MessageExtension; //导入依赖的package包/类
private Message processSRegExtension(Message token, final AuthRequest authRequest) throws MessageException {
    String sregNamespace = detectSRegVersion(authRequest);
    if (sregNamespace != null) {
        MessageExtension ext = authRequest.getExtension(sregNamespace);
        if (ext instanceof SRegRequest) {
            SRegRequest sregReq = (SRegRequest) ext;
            SRegResponse sregResp = SRegResponse.createSRegResponse(sregReq, getValidUser().getUserDataMap());
            token.addExtension(sregResp, "sreg");
        } else if (ext instanceof SRegResponse) {
            // what to do here?
        } else {
            final String message = String.format("TODO - Support of '%s'", ext.getClass().getCanonicalName());
            throw new UnsupportedOperationException(message);
        }
    }
    return token;
}
 
开发者ID:RUB-NDS,项目名称:OpenID-Attacker,代码行数:18,代码来源:CustomOpenIdProcessor.java

示例5: processAxExtension

import org.openid4java.message.MessageExtension; //导入依赖的package包/类
private Message processAxExtension(Message token, final AuthRequest authRequest) throws MessageException {
    if (authRequest.hasExtension(AxMessage.OPENID_NS_AX)) {
        MessageExtension extension = authRequest.getExtension(AxMessage.OPENID_NS_AX);
        if (extension instanceof FetchRequest) {
            final FetchRequest fetchRequest = (FetchRequest) extension;
            final Map userDataMap = getValidUser().getUserDataMap();
            final FetchResponse fetchResponse = FetchResponse.createFetchResponse(fetchRequest, userDataMap);
            token.addExtension(fetchResponse, "ax");
        } else {
            throw new UnsupportedOperationException("TODO: if (ext instanceof StoreRequest)");
        }
    }
    return token;
}
 
开发者ID:RUB-NDS,项目名称:OpenID-Attacker,代码行数:15,代码来源:CustomOpenIdProcessor.java

示例6: getMessageExtension

import org.openid4java.message.MessageExtension; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public MessageExtension getMessageExtension(String userId, String profileName, OpenIDAuthRequestDTO requestDTO)
        throws IdentityException {

    MessageExtension message = null;
    PapeResponse papeResponse = null;
    AuthRequest authRequest = null;

    try {
        authRequest = request.getAuthRequest();

        if (authRequest != null) {
            message = authRequest.getExtension(PapeMessage.OPENID_NS_PAPE);

            if (message instanceof PapeRequest) {
                papeResponse = PapeResponse.createPapeResponse();
                if (request.isPhishingResistanceLogin()) {
                    papeResponse.addAuthPolicy(PapeMessage.PAPE_POLICY_PHISHING_RESISTANT);
                    //papeResponse.setNistAuthLevel(1);  TODO
                }
                if (request.isMultifactorLogin()) {
                    papeResponse.addAuthPolicy(PapeMessage.PAPE_POLICY_MULTI_FACTOR);
                    //papeResponse.setNistAuthLevel(2);  TODO
                }
            }
        }
    } catch (MessageException e) {
        log.error("Failed to create message extension for PAPE", e);
        throw IdentityException.error("Failed to create message extension for PAPE", e);
    }

    return papeResponse;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:37,代码来源:OpenIDPape.java

示例7: addAttributes

import org.openid4java.message.MessageExtension; //导入依赖的package包/类
/**
 * Add attributes to the response message.
 * 
 * @param response
 *            the response message to add to
 * @throws MessageException
 *             if add failed
 */
private void addAttributes(final Message response, Persona persona)
		throws MessageException {
	if (authRequest.hasExtension(AxMessage.OPENID_NS_AX)) {
		MessageExtension ext = authRequest
				.getExtension(AxMessage.OPENID_NS_AX);
		if (ext instanceof FetchRequest) {
			FetchRequest fetchReq = (FetchRequest) ext;

			FetchResponse fetchResp = FetchResponse.createFetchResponse();

			@SuppressWarnings("unchecked")
			Map<String, String> attributes = (Map<String, String>) fetchReq
					.getAttributes();

			Map<String, String> typeValueMap = persona.toTypeValueMap();
			Map<String, String> aliasValueMap = persona.toAliasValueMap();

			for (Map.Entry<String, String> entry : attributes.entrySet()) {
				String alias = entry.getKey();
				String type = entry.getValue();

				String value = typeValueMap.get(type);
				if (value == null) {
					value = aliasValueMap.get(alias);
				}
				if (value != null) {
					fetchResp.addAttribute(alias, type, value);
				}

				Attribute attribute = persona.getAttributeByType(type);
				if (attribute != null) {
					for (String v : attribute.getValues()) {
						fetchResp.addAttribute(alias, type, v);
					}
				}
			}

			response.addExtension(fetchResp);
		} else { // if (ext instanceof StoreRequest)
			throw new UnsupportedOperationException(ext.getClass()
					+ " is unsupported.");
		}
	}
}
 
开发者ID:sutra,项目名称:openid-server,代码行数:53,代码来源:ApprovingRequestProcessor.java

示例8: getMessageExtension

import org.openid4java.message.MessageExtension; //导入依赖的package包/类
/**
 * Creates an instance of MessageExtension for the OpenID authentication
 * response
 *
 * @param requestDTO
 * @param requestDTO OpenID authentication request
 * @return An instance of MessageExtension
 * @throws IdentityException
 */
public abstract MessageExtension getMessageExtension(String userId, String profileName,
                                                     OpenIDAuthRequestDTO requestDTO)
        throws IdentityException;
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:13,代码来源:OpenIDExtension.java


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