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


Java Association.hasExpired方法代码示例

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


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

示例1: load

import org.openid4java.association.Association; //导入方法依赖的package包/类
public Association load(String handle) {
    // get association using map
    Association association = OpenIDAssociationReplicationManager.getPersistenceManager().getAssociation(handle);

    // no association found for the given handle
    if (association == null) {
        log.warn("Association " + handle + " not found in the map.");
        return null;
    }

    // if the association is expired
    if (association.hasExpired()) {
        log.warn("Association is expired for handle " + handle);
        remove(handle); // remove from map
        return null;

    }

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

示例2: load

import org.openid4java.association.Association; //导入方法依赖的package包/类
/**
 * First try to load from the memory, in case of failure look in the db.
 *
 * @param handle
 * @return <code>Association<code>
 */
@Override
public Association load(String handle) {

    boolean chacheMiss = false;

    // looking in the cache
    Association association = cache.getFromCache(handle);

    // if failed, look in the database
    if (association == null) {
        if(log.isDebugEnabled()) {
            log.debug("Association " + handle + " not found in cache. Loading from the database.");
        }
        association = dao.loadAssociation(handle);
        chacheMiss = true;
    }

    // no association found for the given handle
    if (association == null) {
        if(log.isDebugEnabled()) {
            log.debug("Association " + handle + " not found in the database.");
        }
        return null;
    }

    // if the association is expired
    if (association.hasExpired()) {
        log.warn("Association is expired for handle " + handle);
        remove(handle); // remove only from db
        return null;

    } else if (chacheMiss) {
        // add the missing entry to the cache
        cache.addToCache(association);
    }

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

示例3: getResponse

import org.openid4java.association.Association; //导入方法依赖的package包/类
/**
 * Generates an Openid response.
 * If no ticketId is found, response is negative.
 * If we have a ticket id, then we check if we have an association.
 * If so, we ask OpenId server manager to generate the answer according with the existing association.
 * If not, we send back an answer with the ticket id as association handle.
 * This will force the consumer to ask a verification, which will validate the service ticket.
 * @param ticketId the service ticket to provide to the service.
 * @return the generated authentication answer
 */
@Override
public Response getResponse(final String ticketId) {
    final Map<String, String> parameters = new HashMap<>();
    if (ticketId != null) {

        final ServerManager manager = (ServerManager) ApplicationContextProvider.getApplicationContext().getBean("serverManager");
        final CentralAuthenticationService cas = ApplicationContextProvider.getApplicationContext()
                                            .getBean("centralAuthenticationService", CentralAuthenticationService.class);
        boolean associated = false;
        boolean associationValid = true;
        try {
            final AuthRequest authReq = AuthRequest.createAuthRequest(requestParameters, manager.getRealmVerifier());
            final Map parameterMap = authReq.getParameterMap();
            if (parameterMap != null && parameterMap.size() > 0) {
                final String assocHandle = (String) parameterMap.get(OpenIdConstants.OPENID_ASSOCHANDLE);
                if (assocHandle != null) {
                    final Association association = manager.getSharedAssociations().load(assocHandle);
                    if (association != null) {
                        associated = true;
                        if (association.hasExpired()) {
                            associationValid = false;
                        }
                    }

                }
            }
        } catch (final MessageException me) {
            LOGGER.error("Message exception : {}", me.getMessage(), me);
        }

        boolean successFullAuthentication = true;
        Assertion assertion = null;
        try {
            if (associated) {
                if (associationValid) {
                    assertion = cas.validateServiceTicket(ticketId, this);
                    LOGGER.info("Validated openid ticket");
                } else {
                    successFullAuthentication = false;
                }
            }
        } catch (final TicketException te) {
            LOGGER.error("Could not validate ticket : {}", te.getMessage(), te);
            successFullAuthentication = false;
        }

        final String id;
        if (assertion != null && OpenIdConstants.OPENID_IDENTIFIERSELECT.equals(this.identity)) {
            id = this.openIdPrefixUrl + '/' + assertion.getPrimaryAuthentication().getPrincipal().getId();
        } else {
            id = this.identity;
        }
        // We sign directly (final 'true') because we don't add extensions
        // response message can be either a DirectError or an AuthSuccess here.
        // Anyway, handling is the same : send the response message
        final Message response = manager.authResponse(requestParameters,
                id,
                id,
                successFullAuthentication,
                true);
        parameters.putAll(response.getParameterMap());
        if (!associated) {
            parameters.put(OpenIdConstants.OPENID_ASSOCHANDLE, ticketId);
        }
    } else {
        parameters.put(OpenIdConstants.OPENID_MODE, OpenIdConstants.CANCEL);
    }
    return DefaultResponse.getRedirectResponse(getOriginalUrl(), parameters);
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:80,代码来源:OpenIdService.java

示例4: getResponse

import org.openid4java.association.Association; //导入方法依赖的package包/类
/**
 * Generates an Openid response.
 * If no ticketId is found, response is negative.
 * If we have a ticket id, then we check if we have an association.
 * If so, we ask OpenId server manager to generate the answer according with the existing association.
 * If not, we send back an answer with the ticket id as association handle.
 * This will force the consumer to ask a verification, which will validate the service ticket.
 * @param ticketId the service ticket to provide to the service.
 * @return the generated authentication answer
 */
@Override
public Response getResponse(final String ticketId) {
    final Map<String, String> parameters = new HashMap<String, String>();
    if (ticketId != null) {

        ServerManager manager = (ServerManager) ApplicationContextProvider.getApplicationContext().getBean("serverManager");
        CentralAuthenticationService cas = (CentralAuthenticationService) ApplicationContextProvider.getApplicationContext()
                                            .getBean("centralAuthenticationService");
        boolean associated = false;
        boolean associationValid = true;
        try {
            AuthRequest authReq = AuthRequest.createAuthRequest(requestParameters, manager.getRealmVerifier());
            Map parameterMap = authReq.getParameterMap();
            if (parameterMap != null && parameterMap.size() > 0) {
                String assocHandle = (String) parameterMap.get("openid.assoc_handle");
                if (assocHandle != null) {
                    Association association = manager.getSharedAssociations().load(assocHandle);
                    if (association != null) {
                        associated = true;
                        if (association.hasExpired()) {
                            associationValid = false;
                        }
                    }

                }
            }
        } catch (final MessageException me) {
            LOGGER.error("Message exception : {}", me.getMessage(), me);
        }

        boolean successFullAuthentication = true;
        try {
            if (associated) {
                if (associationValid) {
                    cas.validateServiceTicket(ticketId, this);
                    LOGGER.info("Validated openid ticket");
                } else {
                    successFullAuthentication = false;
                }
            }
        } catch (final TicketException te) {
            LOGGER.error("Could not validate ticket : {}", te.getMessage(), te);
            successFullAuthentication = false;
        }

        // We sign directly (final 'true') because we don't add extensions
        // response message can be either a DirectError or an AuthSuccess here.
        // Anyway, handling is the same : send the response message
        Message response = manager.authResponse(requestParameters,
                this.identity,
                this.identity,
                successFullAuthentication,
                true);
        parameters.putAll(response.getParameterMap());
        if (!associated) {
            parameters.put("openid.assoc_handle", ticketId);
        }
    } else {
        parameters.put("openid.mode", "cancel");
    }
    return Response.getRedirectResponse(getOriginalUrl(), parameters);
}
 
开发者ID:luotuo,项目名称:cas4.0.x-server-wechat,代码行数:73,代码来源:OpenIdService.java

示例5: isAssociationValid

import org.openid4java.association.Association; //导入方法依赖的package包/类
/**
 * Is association valid.
 *
 * @param association the association
 * @return the boolean
 */
protected boolean isAssociationValid(final Association association) {
    return association != null && !association.hasExpired();
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:10,代码来源:OpenIdServiceResponseBuilder.java

示例6: isAssociationValid

import org.openid4java.association.Association; //导入方法依赖的package包/类
/**
 * Is association valid.
 *
 * @param association the association
 * @return true/false
 */
protected boolean isAssociationValid(final Association association) {
    return association != null && !association.hasExpired();
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:10,代码来源:OpenIdServiceResponseBuilder.java


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