public static boolean isDhSupported(AssociationSessionType type) { String hAlg = type.getHAlgorithm(); if (hAlg == null) // no encryption sessions return true; else return isDhShaSupported(hAlg); }
/** * Returns true if the specified argument's encryption level is considered * better than the one of the current instance. */ public boolean isBetter(AssociationSessionType other) { return this.compareTo(other) > 0; }
/** * Creates a OpenID 2 AssociationSessionType with the specified session type * and HMAC-SHA1 association type. * * @param sessType The session type. */ public static AssociationSessionType create(String sessType) throws AssociationException { return create(sessType, Association.TYPE_HMAC_SHA1); }
/** * Sets the association / session type for the association response. */ public void setType(AssociationSessionType type) { set("session_type", type.getSessionType()); set("assoc_type", type.getAssociationType()); }
/** * Sets the preferred association / session type. * * @see AssociationSessionType */ public void setPrefAssocSessEnc(AssociationSessionType type) throws ServerException { if (! Association.isHmacSupported(type.getAssociationType()) || ! DiffieHellmanSession.isDhSupported(type) ) throw new ServerException("Unsupported association / session type: " + type.getSessionType() + " : " + type.getAssociationType()); if (_minAssocSessEnc.isBetter(type) ) throw new ServerException( "Minimum encryption settings cannot be better than the preferred"); this._prefAssocSessEnc = type; }
AssociationSessionType type, URL opUrl) { try { if (_minAssocSessEnc.isBetter(type)) { return null; if (type.getHAlgorithm() != null) // DH session && Association.isHmacSupported(type.getAssociationType())) { assocReq = AssociationRequest.createAssociationRequest(type, dhSess); Association.isHmacSupported(type.getAssociationType())) { assocReq = AssociationRequest.createAssociationRequest(type);
if (type.isVersion2() ^ isVersion2()) if (type.getHAlgorithm() != null) // DH session if ( macSize != type.getKeySize())
if (_prefAssocSessEnc.isVersion2() == discovered.isVersion2()) { requests.remove(_prefAssocSessEnc); requests.put(_prefAssocSessEnc, null); respType.getHAlgorithm() == null && createAssociationRequest(respType,opUrl) != null)) AssociationSessionType.create( assocErr.getSessionType(), assocErr.getAssocType());
"DH session: " + dhSess); if (type.isVersion2()) set("openid.ns", OPENID2_NS); set("openid.session_type", type.getSessionType()); set("openid.assoc_type", type.getAssociationType());
if (type.isVersion2() != isVersion2()) { throw new MessageException("Protocol verison mismatch " + "between association session type: " + type + if (type.getHAlgorithm() != null && getDhPublicKey() == null) { throw new MessageException("DH consumer public key not specified.", OpenIDException.ASSOC_ERROR); if (type.getHAlgorithm() == null && (getDhGen() != null || getDhModulus() != null || getDhPublicKey() != null)) { throw new MessageException(
if ( type.getHAlgorithm() != null ) if (Association.TYPE_HMAC_SHA1.equals(type.getAssociationType())) assoc = Association.createHmacSha1(handle, macKey, expiresIn); else if (Association.TYPE_HMAC_SHA256.equals(type.getAssociationType())) assoc = Association.createHmacSha256(handle, macKey, expiresIn);
/** * Sets the preferred association / session type. * * @see AssociationSessionType */ public void setPrefAssocSessEnc(AssociationSessionType type) throws ServerException { if (! Association.isHmacSupported(type.getAssociationType()) || ! DiffieHellmanSession.isDhSupported(type) ) throw new ServerException("Unsupported association / session type: " + type.getSessionType() + " : " + type.getAssociationType()); if (_minAssocSessEnc.isBetter(type) ) throw new ServerException( "Minimum encryption settings cannot be better than the preferred"); this._prefAssocSessEnc = type; }
public void setAssociationSessionType(AssociationSessionType type) { set("session_type", type.getSessionType()); set("assoc_type", type.getAssociationType()); }
if (_minAssocSessEnc.isBetter(type)) return null; if (type.getHAlgorithm() != null) // DH session && Association.isHmacSupported(type.getAssociationType())) assocReq = AssociationRequest.createAssociationRequest(type, dhSess); Association.isHmacSupported(type.getAssociationType())) assocReq = AssociationRequest.createAssociationRequest(type);
if (type.isVersion2() ^ isVersion2()) { throw new MessageException( "Protocol verison mismatch between association " + if (type.getHAlgorithm() != null) // DH session if (macSize != type.getKeySize()) { throw new MessageException("MAC key size: " + macSize + " doesn't match the association/session type: " + type,
if (_prefAssocSessEnc.isVersion2() == discovered.isVersion2()) { requests.put(_prefAssocSessEnc, null); respType.getHAlgorithm() == null && createAssociationRequest(respType, opUrl) != null)) { AssociationSessionType.create( assocErr.getSessionType(), assocErr.getAssocType());
if (type.isVersion2()) { set("openid.ns", OPENID2_NS); set("openid.session_type", type.getSessionType()); set("openid.assoc_type", type.getAssociationType());
if (type.isVersion2() != isVersion2()) if ( type.getHAlgorithm() != null && getDhPublicKey() == null) if (type.getHAlgorithm() == null && (getDhGen() != null || getDhModulus() != null || getDhPublicKey() != null) )
if ( type.getHAlgorithm() != null ) if (Association.TYPE_HMAC_SHA1.equals(type.getAssociationType())) assoc = Association.createHmacSha1(handle, macKey, expiresIn); else if (Association.TYPE_HMAC_SHA256.equals(type.getAssociationType())) assoc = Association.createHmacSha256(handle, macKey, expiresIn);
/** * Sets the preferred association / session type. * * @see AssociationSessionType */ public void setPrefAssocSessEnc(AssociationSessionType type) throws ServerException { if (! Association.isHmacSupported(type.getAssociationType()) || ! DiffieHellmanSession.isDhSupported(type) ) throw new ServerException("Unsupported association / session type: " + type.getSessionType() + " : " + type.getAssociationType()); if (_minAssocSessEnc.isBetter(type) ) throw new ServerException( "Minimum encryption settings cannot be better than the preferred"); this._prefAssocSessEnc = type; }