List of usage examples for org.springframework.security.oauth2.common.util SerializationUtils serialize
public static byte[] serialize(Object state)
From source file:oauth2.entities.RefreshToken.java
public void setToken(OAuth2RefreshToken token) { this.token = SerializationUtils.serialize(token); }
From source file:oauth2.entities.AccessToken.java
public void setToken(OAuth2AccessToken token) { this.token = SerializationUtils.serialize(token); }
From source file:oauth2.entities.AccessToken.java
public void setAuthentication(OAuth2Authentication authentication) { this.authentication = SerializationUtils.serialize(authentication); }
From source file:com.epam.reportportal.auth.store.OAuth2MongoTokenStore.java
@Override public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) { OAuth2AccessTokenEntity tokenEntity = new OAuth2AccessTokenEntity(); tokenEntity.setTokenId(token.getValue()); tokenEntity.setToken(SerializationUtils.serialize(token)); tokenEntity.setAuthentication(SerializationUtils.serialize(authentication)); tokenEntity.setAuthenticationId(authenticationKeyGenerator.extractKey(authentication)); tokenEntity.setUserName(authentication.isClientOnly() ? null : authentication.getName()); tokenEntity.setRefreshToken(null == token.getRefreshToken() ? null : token.getRefreshToken().getValue()); tokenEntity.setClientId(authentication.getOAuth2Request().getClientId()); oAuth2AccessTokenRepository.save(tokenEntity); }
From source file:org.openmhealth.shim.AccessParameterClientTokenServices.java
@Override public void saveAccessToken(OAuth2ProtectedResourceDetails resource, Authentication authentication, OAuth2AccessToken accessToken) { String username = authentication.getPrincipal().toString(); String shimKey = authentication.getDetails().toString(); AccessParameters accessParameters = accessParametersRepo.findByUsernameAndShimKey(username, shimKey, new Sort(Sort.Direction.DESC, "dateCreated")); if (accessParameters == null) { accessParameters = new AccessParameters(); accessParameters.setUsername(username); accessParameters.setShimKey(shimKey); }/*from w ww . j av a 2s. c o m*/ accessParameters.setSerializedToken(SerializationUtils.serialize(accessToken)); accessParametersRepo.save(accessParameters); }
From source file:com.cedac.security.oauth2.provider.code.MongoAuthorizationCodeServices.java
@Override protected void store(String code, OAuth2Authentication authentication) { BasicDBObject dbo = new BasicDBObject(codeFieldName, code).append(authenticationFieldName, SerializationUtils.serialize(authentication)); getAuthCodeCollection().insert(dbo); }
From source file:nl.surfnet.coin.api.oauth.OpenConextOauth2JdbcTokenStore.java
@Override public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) { AuthorizationRequest authorizationRequest = authentication.getAuthorizationRequest(); String clientId = authorizationRequest.getClientId(); ClientDetails clientDetails = clientDetailsService.loadClientByClientId(clientId); if (!(clientDetails instanceof OpenConextClientDetails)) { throw new RuntimeException("The clientDetails is of the type '" + (clientDetails != null ? clientDetails.getClass() : "null") + "'. Required is a (sub)class of ExtendedBaseClientDetails"); }/*www . j a v a 2s. c o m*/ ClientMetaData clientMetaData = ((OpenConextClientDetails) clientDetails).getClientMetaData(); String refreshToken = null; if (token.getRefreshToken() != null) { refreshToken = token.getRefreshToken().getValue(); } String value = extractTokenKey(token.getValue()); jdbcTemplate.update(ACCESS_TOKEN_INSERT_STATEMENT, new Object[] { value, new SqlLobValue(SerializationUtils.serialize(token)), authenticationKeyGenerator.extractKey(authentication), authentication.isClientOnly() ? null : authentication.getName(), authentication.getAuthorizationRequest().getClientId(), clientMetaData.getAppEntityId(), new SqlLobValue(SerializationUtils.serialize(authentication)), refreshToken }, new int[] { Types.VARCHAR, Types.BLOB, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.BLOB, Types.VARCHAR }); }
From source file:com.epam.reportportal.auth.store.OAuth2MongoTokenStore.java
@Override public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) { OAuth2RefreshTokenEntity refreshEntity = new OAuth2RefreshTokenEntity(); refreshEntity.setAuthentication(SerializationUtils.serialize(authentication)); refreshEntity.setTokenId(refreshToken.getValue()); refreshEntity.setoAuth2RefreshToken(SerializationUtils.serialize(refreshToken)); oAuth2RefreshTokenRepository.save(refreshEntity); }
From source file:org.openmhealth.shim.OAuth2ShimBase.java
@Override public AuthorizationRequestParameters getAuthorizationRequestParameters(String username, Map<String, String> addlParameters) throws ShimException { OAuth2RestOperations restTemplate = restTemplate(); try {//from w w w . jav a2 s .c o m trigger(restTemplate, getTriggerDataRequest()); return AuthorizationRequestParameters.authorized(); } catch (UserRedirectRequiredException e) { /** * If an exception was thrown it means a redirect is required * for user's external authorization with toolmaker. */ AccessTokenRequest accessTokenRequest = restTemplate.getOAuth2ClientContext().getAccessTokenRequest(); String stateKey = accessTokenRequest.getStateKey(); /** * Build an authorization request from the exception * parameters. We also serialize spring's accessTokenRequest. */ AuthorizationRequestParameters authRequestParams = new AuthorizationRequestParameters(); authRequestParams.setRedirectUri(e.getRedirectUri()); authRequestParams.setStateKey(e.getStateKey()); authRequestParams.setAuthorizationUrl(getAuthorizationUrl(e)); authRequestParams.setSerializedRequest(SerializationUtils.serialize(accessTokenRequest)); authRequestParams.setStateKey(stateKey); authorizationRequestParametersRepo.save(authRequestParams); return authRequestParams; } }
From source file:com.haulmont.restapi.auth.ClientProxyTokenStore.java
@Override public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) { Date tokenExpiry = refreshToken instanceof ExpiringOAuth2RefreshToken ? ((ExpiringOAuth2RefreshToken) refreshToken).getExpiration() : null;/*from w w w .j a va 2 s . c o m*/ String userLogin = authentication.getName(); serverTokenStore.storeRefreshToken(refreshToken.getValue(), SerializationUtils.serialize(refreshToken), SerializationUtils.serialize(authentication), tokenExpiry, userLogin); }