List of usage examples for org.springframework.security.oauth.provider.token OAuthProviderTokenImpl getCallbackUrl
public String getCallbackUrl()
From source file:nl.surfnet.coin.api.oauth.OpenConextOauth1TokenServices.java
@Override protected void storeToken(String value, OAuthProviderTokenImpl token) { Assert.notNull(token, "Token cannot be null"); Assert.notNull(value, "token value cannot be null"); Authentication userAuthentication = token.getUserAuthentication(); String userId = null;// w w w. j av a 2 s . c om if (token.isAccessToken()) { String consumerKey = token.getConsumerKey(); /* * get the client detail from Janus as we are unable to store them * somewhere along the 'road' and we cache this call anyway */ ConsumerDetails consumerDetails = consumerDetailsService.loadConsumerByConsumerKey(consumerKey); if (consumerDetails instanceof OpenConextConsumerDetails) { OpenConextConsumerDetails extendedBaseConsumerDetails = (OpenConextConsumerDetails) consumerDetails; if (userAuthentication instanceof PreAuthenticatedAuthenticationToken) { PreAuthenticatedAuthenticationToken pre = (PreAuthenticatedAuthenticationToken) userAuthentication; Object principal = pre.getPrincipal(); if (principal instanceof ClientMetaDataUser) { ((ClientMetaDataUser) principal) .setClientMetaData(extendedBaseConsumerDetails.getClientMetaData()); userId = ((ClientMetaDataUser) principal).getUsername(); } else if (principal instanceof SAMLAuthenticationToken) { ((SAMLAuthenticationToken) principal) .setClientMetaData(extendedBaseConsumerDetails.getClientMetaData()); userId = ((SAMLAuthenticationToken) principal).getName(); } else { throw new RuntimeException( "The principal on the PreAuthenticatedAuthenticationToken is of the type '" + (principal != null ? principal.getClass() : "null") + "'. Required is a (sub)class of ClientMetaDataUser or a (sub)class of SAMLAuthenticationToken"); } } else if (userAuthentication instanceof SAMLAuthenticationToken) { SAMLAuthenticationToken samlToken = (SAMLAuthenticationToken) userAuthentication; samlToken.setClientMetaData(extendedBaseConsumerDetails.getClientMetaData()); userId = samlToken.getName(); } else { throw new RuntimeException("The userAuthentication is of the type '" + (userAuthentication != null ? userAuthentication.getClass() : "null") + "'. Required is a (sub)class of PreAuthenticatedAuthenticationToken or SAMLAuthenticationToken"); } } else { throw new RuntimeException("The consumerDetails is of the type '" + (consumerDetails != null ? consumerDetails.getClass() : "null") + "'. Required is a (sub)class of ExtendedBaseConsumerDetails"); } } jdbcTemplate.update(deleteTokenSql, value); jdbcTemplate.update(insertTokenSql, value, token.getCallbackUrl(), token.getVerifier(), token.getSecret(), token.getConsumerKey(), userId, token.isAccessToken(), token.getTimestamp(), SerializationUtils.serialize(userAuthentication)); }