本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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();
}
示例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();
}