本文整理了Java中org.openid4java.association.Association
类的一些代码示例,展示了Association
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Association
类的具体详情如下:
包路径:org.openid4java.association.Association
类名称:Association
暂无
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
public void save(String opUrl, Association association) {
cleanupExpired();
try {
JdbcTemplate jdbcTemplate = getJdbcTemplate();
int cnt = jdbcTemplate.update(_sqlInsert,
new Object[]
{
opUrl,
association.getHandle(),
association.getType(),
association.getMacKey() == null ? null :
new String(
Base64.encodeBase64(association.getMacKey().getEncoded())),
association.getExpiry()});
} catch (Exception e) {
_log.error("Error saving association to table: " + _tableName, e);
}
}
代码示例来源:origin: org.jasig.cas/cas-server-support-openid
/**
* Is association valid.
*
* @param association the association
* @return the boolean
*/
protected boolean isAssociationValid(final Association association) {
return association != null && !association.hasExpired();
}
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.provider
@Override
public Association load(String handle) {
if(IdentityUtil.isBlank(handle)){
throw new IllegalArgumentException("Handle is empty");
}
if(log.isDebugEnabled()){
log.debug("Inside load(); handle : " + handle);
}
String timeStamp = handle.substring((Integer.toString(storeId)).length(), handle.indexOf("-"));
Date expireDate = new Date(Long.parseLong(timeStamp)+ this.expireIn);
if(log.isDebugEnabled()){
log.debug("Calculated Expiry Time : " + expireDate.getTime());
}
// SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
// PBEKeySpec spec = new PBEKeySpec(serverKey.toCharArray(), handle.getBytes(), 1, 256);
// SecretKey secretKey = factory.generateSecret(spec);
return Association.createHmacSha256(handle, (serverKey + handle).getBytes(), expireDate);
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.provider
public void removeExpiredAssociations() {
Date currentTime = new Date();
for (Map.Entry<String, Association> entry : associationMap.entrySet()) {
Association association = entry.getValue();
if(currentTime.after(association.getExpiry())) {
if (log.isDebugEnabled()) {
log.debug("Current time : " + currentTime.getTime() + ", expiry time : "
+ association.getExpiry().getTime() + ". Hence removing expired association : "
+ association.getHandle());
}
removeAssociation(association.getHandle());
}
}
}
}
代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.openid/org.wso2.carbon.identity.provider
public Association generate(String type, int expiryIn) throws AssociationException {
String handle = storeId + timestamp + "-" + getCounter();
Association association = Association.generate(type, handle, expiryIn);
// replicating association using cluster messages
if(log.isDebugEnabled()) {
log.debug("Storing association " + association.getHandle() + " in the map.");
}
OpenIDAssociationReplicationManager.getPersistenceManager().addAssociation(association);
return association;
}
代码示例来源:origin: be.fedict.eid-idp/eid-idp-protocol-openid
InvalidAlgorithmParameterException, NoSuchProviderException {
ByteArrayOutputStream encodedAssociation = new ByteArrayOutputStream();
String type = association.getType();
if (type == Association.TYPE_HMAC_SHA1) {
encodedAssociation.write(1);
throw new AssociationException("unknown type: " + type);
SecretKey macKey = association.getMacKey();
byte[] macKeyBytes = macKey.getEncoded();
encodedAssociation.write(macKeyBytes);
Date expiry = association.getExpiry();
Long time = expiry.getTime();
DataOutputStream dos = new DataOutputStream(encodedAssociation);
return Association.createHmacSha1(handle, macKeyBytes, expiry);
} else if (type == Association.TYPE_HMAC_SHA256) {
return Association.createHmacSha256(handle, macKeyBytes, expiry);
代码示例来源:origin: org.wso2.carbon.identity.inbound.auth.openid/org.wso2.carbon.identity.provider
assoc = Association.createHmacSha1(assocHandle, Base64.decode(macKey), expireIn);
assoc = Association.createHmacSha256(assocHandle, Base64.decode(macKey), expireIn);
代码示例来源:origin: org.openid4java/openid4java-nodeps
+ " association handle: " + assoc.getHandle());
setType(type);
setAssocHandle(assoc.getHandle());
Long expiryIn = new Long( ( assoc.getExpiry().getTime() -
System.currentTimeMillis() ) / 1000 );
setExpire(expiryIn);
assoc.getMacKey().getEncoded(),
assocReq.getDhPublicKey() ));
Base64.encodeBase64(assoc.getMacKey().getEncoded())));
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
public synchronized void save(String opUrl, Association association) {
removeExpired();
Map handleMap = (Map) _opMap.get(opUrl);
if (handleMap == null) {
handleMap = new HashMap();
_opMap.put(opUrl, handleMap);
}
String handle = association.getHandle();
if (DEBUG) {
_log.debug("Adding association to the in-memory store: " + handle +
" with OP: " + opUrl);
}
handleMap.put(association.getHandle(), association);
}
代码示例来源:origin: com.cloudbees/openid4java-shaded
protected AuthSuccess(String opEndpoint, String claimedId, String delegate,
boolean compatibility,
String returnTo, String nonce,
String invalidateHandle, Association assoc,
boolean signNow)
throws AssociationException
{
if (! compatibility)
{
set("openid.ns", OPENID2_NS);
setOpEndpoint(opEndpoint);
setClaimed(claimedId);
setNonce(nonce);
}
set("openid.mode", MODE_IDRES);
setIdentity(delegate);
setReturnTo(returnTo);
if (invalidateHandle != null) setInvalidateHandle(invalidateHandle);
setHandle(assoc.getHandle());
buildSignedList();
setSignature(signNow ? assoc.sign(getSignedText()) : "");
}
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
assoc = Association.getFailedAssociation(expDate);
assoc = Association.createHmacSha1(handle,
Base64.decodeBase64(macKey.getBytes()),
expDate);
assoc = Association.createHmacSha256(handle,
Base64.decodeBase64(macKey.getBytes()),
expDate);
代码示例来源:origin: jbufu/openid4java
_log.info("Found association: " + assoc.getHandle() +
" verifying signature locally...");
String text = authResp.getSignedText();
String signature = authResp.getSignature();
if (assoc.verifySignature(text, signature))
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
if (privateAssoc.verifySignature(signed, signature)) {
_log.info("Consumer nonce signature verified.");
return nonce;
代码示例来源:origin: org.openid4java/openid4java
public synchronized Association generate(String type, int expiryIn)
throws AssociationException
{
removeExpired();
String handle = _timestamp + "-" + _counter++;
Association association = Association.generate(type, handle, expiryIn);
_handleMap.put(handle, association);
if (DEBUG) _log.debug("Generated association, handle: " + handle +
" type: " + type +
" expires in: " + expiryIn + " seconds.");
return association;
}
代码示例来源:origin: org.openid4java/openid4java
public boolean verifySignature(String text, String signature) throws AssociationException
{
if (DEBUG) _log.debug("Verifying signature: " + signature);
// The Java String.equals() method returns on the first difference in
// its inputs, which allows a timing attack to recover signature values.
// This verification method will take the same amount of time for any
// two inputs of equal length.
String textSig = sign(text);
if (textSig.length() == 0 || textSig.length() != signature.length()) {
return false;
}
int result = 0;
for (int i = 0; i < textSig.length(); i++) {
result |= textSig.charAt(i) ^ signature.charAt(i);
}
return result == 0;
}
}
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
public synchronized Association load(String opUrl) {
removeExpired();
Association latest = null;
if (_opMap.containsKey(opUrl)) {
Map handleMap = (Map) _opMap.get(opUrl);
Iterator handles = handleMap.keySet().iterator();
while (handles.hasNext()) {
String handle = (String) handles.next();
Association association = (Association) handleMap.get(handle);
if (latest == null ||
latest.getExpiry().before(association.getExpiry())) {
latest = association;
}
}
}
return latest;
}
代码示例来源:origin: org.wso2.carbon.identity/org.wso2.carbon.identity.provider
assoc = Association.createHmacSha1(assocHandle, Base64.decode(macKey), expireIn);
assoc = Association.createHmacSha256(assocHandle, Base64.decode(macKey), expireIn);
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
if (DEBUG) {
_log.debug("Creating association response, type: " + assocReq.getType()
+ " association handle: " + assoc.getHandle());
setType(type);
setAssocHandle(assoc.getHandle());
Long expiryIn = new Long((assoc.getExpiry().getTime() -
System.currentTimeMillis()) / 1000);
setExpire(expiryIn);
assoc.getMacKey().getEncoded(),
assocReq.getDhPublicKey()));
} else // no-encryption session, unecrypted MAC key
Base64.encodeBase64(assoc.getMacKey().getEncoded())));
代码示例来源:origin: org.openid4java/openid4java
public synchronized void save(String opUrl, Association association)
{
removeExpired();
Map handleMap = (Map) _opMap.get(opUrl);
if (handleMap == null)
{
handleMap = new HashMap();
_opMap.put(opUrl, handleMap);
}
String handle = association.getHandle();
if(DEBUG)
_log.debug("Adding association to the in-memory store: " + handle +
" with OP: " + opUrl);
handleMap.put(association.getHandle(), association);
}
代码示例来源:origin: org.wso2.org.openid4java/openid4java-nodeps
protected AuthSuccess(String opEndpoint, String claimedId, String delegate,
boolean compatibility,
String returnTo, String nonce,
String invalidateHandle, Association assoc,
boolean signNow)
throws AssociationException {
if (!compatibility) {
set("openid.ns", OPENID2_NS);
setOpEndpoint(opEndpoint);
setClaimed(claimedId);
setNonce(nonce);
}
set("openid.mode", MODE_IDRES);
setIdentity(delegate);
setReturnTo(returnTo);
if (invalidateHandle != null) {
setInvalidateHandle(invalidateHandle);
}
setHandle(assoc.getHandle());
buildSignedList();
setSignature(signNow ? assoc.sign(getSignedText()) : "");
}
内容来源于网络,如有侵权,请联系作者删除!