本文整理汇总了Java中org.openid4java.association.Association类的典型用法代码示例。如果您正苦于以下问题:Java Association类的具体用法?Java Association怎么用?Java Association使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Association类属于org.openid4java.association包,在下文中一共展示了Association类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAssociation
import org.openid4java.association.Association; //导入依赖的package包/类
/**
* Gets association.
*
* @param serverManager the server manager
* @return the association
*/
protected Association getAssociation(final ServerManager serverManager) {
try {
final AuthRequest authReq = AuthRequest.createAuthRequest(this.parameterList,
serverManager.getRealmVerifier());
final Map parameterMap = authReq.getParameterMap();
if (parameterMap != null && !parameterMap.isEmpty()) {
final String assocHandle = (String) parameterMap.get(OpenIdProtocolConstants.OPENID_ASSOCHANDLE);
if (assocHandle != null) {
return serverManager.getSharedAssociations().load(assocHandle);
}
}
} catch (final MessageException me) {
LOGGER.error("Message exception : {}", me.getMessage(), me);
}
return null;
}
示例2: verifyExpiredAssociationGetResponse
import org.openid4java.association.Association; //导入依赖的package包/类
@Test
public void verifyExpiredAssociationGetResponse() {
request.addParameter("openid.assoc_handle", "test");
openIdService = OpenIdService.createServiceFrom(request, null);
Association association = null;
try {
association = Association.generate(Association.TYPE_HMAC_SHA1, "test", 2);
} catch (final Exception e) {
fail("Could not generate association");
}
when(sharedAssociations.load("test")).thenReturn(association);
synchronized (this) {
try {
this.wait(3000);
} catch (final InterruptedException ie) {
fail("Could not wait long enough to check association expiry date");
}
}
final Response response = this.openIdService.getResponse("test");
request.removeParameter("openid.assoc_handle");
assertNotNull(response);
assertEquals(1, response.getAttributes().size());
assertEquals("cancel", response.getAttributes().get("openid.mode"));
}
示例3: getAssociation
import org.openid4java.association.Association; //导入依赖的package包/类
/**
* Gets association.
*
* @param serverManager the server manager
* @param parameterList the parameter list
* @return the association
*/
protected Association getAssociation(final ServerManager serverManager, final ParameterList parameterList) {
try {
final AuthRequest authReq = AuthRequest.createAuthRequest(parameterList, serverManager.getRealmVerifier());
final Map parameterMap = authReq.getParameterMap();
if (parameterMap != null && !parameterMap.isEmpty()) {
final String assocHandle = (String) parameterMap.get(OpenIdProtocolConstants.OPENID_ASSOCHANDLE);
if (assocHandle != null) {
return serverManager.getSharedAssociations().load(assocHandle);
}
}
} catch (final MessageException e) {
LOGGER.error("Message exception : [{}]", e.getMessage(), e);
}
return null;
}
示例4: getAssociation
import org.openid4java.association.Association; //导入依赖的package包/类
/**
* Gets association.
*
* @param serverManager the server manager
* @return the association
*/
protected Association getAssociation(final ServerManager serverManager) {
try {
final AuthRequest authReq = AuthRequest.createAuthRequest(this.parameterList,
serverManager.getRealmVerifier());
final Map parameterMap = authReq.getParameterMap();
if (parameterMap != null && !parameterMap.isEmpty()) {
final String assocHandle = (String) parameterMap.get(OpenIdProtocolConstants.OPENID_ASSOCHANDLE);
if (assocHandle != null) {
return serverManager.getSharedAssociations().load(assocHandle);
}
}
} catch (final MessageException me) {
logger.error("Message exception : {}", me.getMessage(), me);
}
return null;
}
示例5: AuthRequest
import org.openid4java.association.Association; //导入依赖的package包/类
protected AuthRequest(String claimedId, String delegate, boolean compatibility,
String returnToUrl, String handle, String realm,
RealmVerifier verifier)
{
if (! compatibility)
{
set("openid.ns", OPENID2_NS);
setClaimed(claimedId);
}
setIdentity(delegate);
if ( returnToUrl != null ) setReturnTo(returnToUrl);
if ( realm != null ) setRealm(realm);
if (! Association.FAILED_ASSOC_HANDLE.equals(handle)) setHandle(handle);
setImmediate(false);
_realmVerifier = verifier;
}
示例6: AuthSuccess
import org.openid4java.association.Association; //导入依赖的package包/类
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()) : "");
}
示例7: createAuthSuccess
import org.openid4java.association.Association; //导入依赖的package包/类
public static AuthSuccess createAuthSuccess(
String opEndpoint, String claimedId, String delegate,
boolean compatibility,
String returnTo, String nonce,
String invalidateHandle, Association assoc,
boolean signNow)
throws MessageException, AssociationException
{
AuthSuccess resp = new AuthSuccess(opEndpoint, claimedId, delegate,
compatibility, returnTo, nonce,
invalidateHandle, assoc, signNow);
resp.validate();
if (DEBUG) _log.debug("Created positive auth response:\n"
+ resp.keyValueFormEncoding());
return resp;
}
示例8: load
import org.openid4java.association.Association; //导入依赖的package包/类
public synchronized Association load(String opUrl, String handle)
{
removeExpired();
if (_opMap.containsKey(opUrl))
{
Map handleMap = (Map) _opMap.get(opUrl);
if (handleMap.containsKey(handle))
{
return (Association) handleMap.get(handle);
}
}
return null;
}
示例9: save
import org.openid4java.association.Association; //导入依赖的package包/类
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 ) ;
}
}
示例10: ConsumerManager
import org.openid4java.association.Association; //导入依赖的package包/类
@Inject
public ConsumerManager(RealmVerifierFactory realmFactory, Discovery discovery,
HttpFetcherFactory httpFetcherFactory)
{
_realmVerifier = realmFactory.getRealmVerifierForConsumer();
// don't verify own (RP) identity, disable RP discovery
_realmVerifier.setEnforceRpId(false);
_discovery = discovery;
_httpFetcher = httpFetcherFactory.createFetcher(HttpRequestOptions.getDefaultOptionsForOpCalls());
if (Association.isHmacSha256Supported())
_prefAssocSessEnc = AssociationSessionType.DH_SHA256;
else
_prefAssocSessEnc = AssociationSessionType.DH_SHA1;
}
示例11: sign
import org.openid4java.association.Association; //导入依赖的package包/类
/**
* Signs an AuthSuccess message, using the association identified by the
* handle specified within the message.
*
* @param authSuccess The Authentication Success message to be signed.
*
* @throws ServerException If the Association corresponding to the handle
* in the @authSuccess cannot be retrieved from
* the store.
* @throws AssociationException If the signature cannot be computed.
*
*/
public void sign(AuthSuccess authSuccess)
throws ServerException, AssociationException
{
String handle = authSuccess.getHandle();
// try shared associations first, then private
Association assoc = _sharedAssociations.load(handle);
if (assoc == null)
assoc = _privateAssociations.load(handle);
if (assoc == null) throw new ServerException(
"No association found for handle: " + handle);
authSuccess.setSignature(assoc.sign(authSuccess.getSignedText()));
}
示例12: generate
import org.openid4java.association.Association; //导入依赖的package包/类
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;
}
示例13: testSaveLoadRemove
import org.openid4java.association.Association; //导入依赖的package包/类
public void testSaveLoadRemove()
{
_associationStore.save("http://example.com", Association.generateHmacSha1("a", 60));
_associationStore.save("http://example.com", Association.generateHmacSha256("b", 60));
_associationStore.save("http://example.com", Association.generateHmacSha1("c", 60));
assertNotNull(_associationStore.load("http://example.com", "a"));
assertNotNull(_associationStore.load("http://example.com", "b"));
assertNotNull(_associationStore.load("http://example.com", "c"));
assertNotNull(_associationStore.load("http://example.com"));
_associationStore.remove("http://example.com", "b");
assertNull(_associationStore.load("http://example.com", "b"));
}
示例14: saveAssociationStoreToDisk
import org.openid4java.association.Association; //导入依赖的package包/类
public static void saveAssociationStoreToDisk(File saveFile, List<Association> associationList) throws XmlPersistenceError {
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(CustomInMemoryServerAssociationStore.class);
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
// jaxbMarshaller.marshal(associationStore, saveFile);
// LOG.info(String.format("Saved successfully associations to '%s'", saveFile.getAbsoluteFile()));
// } catch (JAXBException ex) {
// throw new XmlPersistenceError(String.format("Could not save associations to File '%s'", saveFile.getAbsoluteFile()), ex);
// }
try {
FileOutputStream f_out = new FileOutputStream(saveFile);
ObjectOutputStream obj_out = new ObjectOutputStream(f_out);
obj_out.writeObject(associationList);
} catch (IOException ex) {
throw new XmlPersistenceError(String.format("Could not save associations to File '%s'", saveFile.getAbsoluteFile()), ex);
}
}
示例15: loadAssociationStoreFromFile
import org.openid4java.association.Association; //导入依赖的package包/类
public static List<Association> loadAssociationStoreFromFile(final File loadFile) throws XmlPersistenceError {
// CustomInMemoryServerAssociationStore result;
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(CustomInMemoryServerAssociationStore.class);
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// result = (CustomInMemoryServerAssociationStore) jaxbUnmarshaller.unmarshal(loadFile);
// LOG.info(String.format("Loaded successfully associations from '%s'", loadFile.getAbsoluteFile()));
// } catch (JAXBException ex) {
// throw new XmlPersistenceError(String.format("Could not load associations from File '%s'", loadFile.getAbsoluteFile()), ex);
// }
// return result;
// Read from disk using FileInputStream
try {
FileInputStream f_in;
f_in = new FileInputStream(loadFile);
ObjectInputStream obj_in = new ObjectInputStream(f_in);
Object obj = obj_in.readObject();
return (List<Association>) obj;
} catch (IOException | ClassNotFoundException ex) {
throw new XmlPersistenceError(String.format("Could not load associations from File '%s'", loadFile.getAbsoluteFile()), ex);
}
}