List of usage examples for org.springframework.security.oauth2.provider AuthorizationRequest isApproved
public boolean isApproved()
From source file:com.acc.oauth2.HybrisApprovalHandler.java
/** * Allows automatic approval for a white list of clients in the implicit grant case. * /*w w w . ja v a 2 s . co m*/ * @param authorizationRequest * The authorization request. * @param userAuthentication * the current user authentication * * @return Whether the specified request has been approved by the current user. */ @Override public boolean isApproved(final AuthorizationRequest authorizationRequest, final Authentication userAuthentication) { if (useTokenServices && super.isApproved(authorizationRequest, userAuthentication)) { return true; } if (!userAuthentication.isAuthenticated()) { return false; } return authorizationRequest.isApproved() || (authorizationRequest.getResponseTypes().contains("token") && autoApproveClients.contains(authorizationRequest.getClientId())); }
From source file:org.energyos.espi.datacustodian.oauth.EspiUserApprovalHandler.java
/** * Allows automatic approval for a white list of clients in the implicit grant case. * // w w w .j av a 2 s . co m * @param authorizationRequest The authorization request. * @param userAuthentication the current user authentication * * @return An updated request if it has already been approved by the current user. */ @Override public AuthorizationRequest checkForPreApproval(AuthorizationRequest authorizationRequest, Authentication userAuthentication) { boolean approved = false; // If we are allowed to check existing approvals this will short circuit the decision if (useApprovalStore) { authorizationRequest = super.checkForPreApproval(authorizationRequest, userAuthentication); approved = authorizationRequest.isApproved(); } else { if (clientDetailsService != null) { Collection<String> requestedScopes = authorizationRequest.getScope(); try { ClientDetails client = clientDetailsService .loadClientByClientId(authorizationRequest.getClientId()); for (String scope : requestedScopes) { if (client.isAutoApprove(scope) || client.isAutoApprove("all")) { approved = true; break; } } } catch (ClientRegistrationException e) { } } } authorizationRequest.setApproved(approved); return authorizationRequest; }
From source file:cn.ifast.oauth2server.oauth.SparklrUserApprovalHandler.java
/** * Allows automatic approval for a white list of clients in the implicit grant case. * /* w w w .j a va2 s. c o m*/ * @param authorizationRequest The authorization request. * @param userAuthentication the current user authentication * * @return An updated request if it has already been approved by the current user. */ @Override public AuthorizationRequest checkForPreApproval(AuthorizationRequest authorizationRequest, Authentication userAuthentication) { boolean approved = false; // If we are allowed to check existing approvals this will short circuit the decision if (useApprovalStore) { authorizationRequest = super.checkForPreApproval(authorizationRequest, userAuthentication); approved = authorizationRequest.isApproved(); } else { if (clientDetailsService != null) { Collection<String> requestedScopes = authorizationRequest.getScope(); try { ClientDetails client = clientDetailsService .loadClientByClientId(authorizationRequest.getClientId()); for (String scope : requestedScopes) { if (client.isAutoApprove(scope) || client.isAutoApprove("all")) { approved = true; break; } } } catch (ClientRegistrationException e) { } } } authorizationRequest.setApproved(approved); return authorizationRequest; }
From source file:com.cmz.web1.oauth.MyWebUserApprovalHandler.java
/** * Allows automatic approval for a white list of clients in the implicit grant case. * //from w w w. j a v a 2 s .c o m * @param authorizationRequest The authorization request. * @param userAuthentication the current user authentication * * @return An updated request if it has already been approved by the current user. */ @Override public AuthorizationRequest checkForPreApproval(AuthorizationRequest authorizationRequest, Authentication userAuthentication) { boolean approved = false; // If we are allowed to check existing approvals this will short circuit the decision if (useApprovalStore) { authorizationRequest = super.checkForPreApproval(authorizationRequest, userAuthentication); approved = authorizationRequest.isApproved(); } else { if (clientDetailsService != null) { Collection<String> requestedScopes = authorizationRequest.getScope(); try { ClientDetails client = clientDetailsService .loadClientByClientId(authorizationRequest.getClientId()); for (String scope : requestedScopes) { if (client.isAutoApprove(scope)) { approved = true; break; } } } catch (ClientRegistrationException e) { } } } authorizationRequest.setApproved(approved); return authorizationRequest; }
From source file:org.springsecurity.oauth2.oauth.OAuth2UserApprovalHandler.java
/** * Allows automatic approval for a white list of clients in the implicit * grant case./* w ww . j a v a 2 s . c om*/ * * @param authorizationRequest * The authorization request. * @param userAuthentication * the current user authentication * * @return An updated request if it has already been approved by the current * user. */ @Override public AuthorizationRequest checkForPreApproval(AuthorizationRequest authorizationRequest, Authentication userAuthentication) { boolean approved = false; // If we are allowed to check existing approvals this will short circuit // the decision if (useApprovalStore) { authorizationRequest = super.checkForPreApproval(authorizationRequest, userAuthentication); approved = authorizationRequest.isApproved(); } else { if (clientDetailsService != null) { Collection<String> requestedScopes = authorizationRequest.getScope(); try { ClientDetails client = clientDetailsService .loadClientByClientId(authorizationRequest.getClientId()); for (String scope : requestedScopes) { if (client.isAutoApprove(scope) || client.isAutoApprove("all")) { approved = true; break; } } } catch (ClientRegistrationException e) { } } } authorizationRequest.setApproved(approved); return authorizationRequest; }
From source file:org.mitre.openid.connect.token.TofuUserApprovalHandler.java
/** * Check if the user has already stored a positive approval decision for this site; or if the * site is whitelisted, approve it automatically. * /* w w w . j a v a 2 s . c om*/ * Otherwise, return false so that the user will see the approval page and can make their own decision. * * @param authorizationRequest the incoming authorization request * @param userAuthentication the Principal representing the currently-logged-in user * * @return true if the site is approved, false otherwise */ @Override public boolean isApproved(AuthorizationRequest authorizationRequest, Authentication userAuthentication) { // if this request is already approved, pass that info through // (this flag may be set by updateBeforeApproval, which can also do funny things with scopes, etc) if (authorizationRequest.isApproved()) { return true; } else { // if not, check to see if the user has approved it // TODO: make parameter name configurable? return Boolean.parseBoolean(authorizationRequest.getApprovalParameters().get("user_oauth_approval")); } }
From source file:com.kopetto.sample.oauth.WebAppUserApprovalHandler.java
/** * Allows automatic approval for a white list of clients in the implicit grant case. * //w ww . j av a 2 s .c o m * @param authorizationRequest The authorization request. * @param userAuthentication the current user authentication * * @return An updated request if it has already been approved by the current user. */ @Override public AuthorizationRequest checkForPreApproval(AuthorizationRequest authorizationRequest, Authentication userAuthentication) { boolean approved = false; // If we are allowed to check existing approvals this will short circuit the decision if (useApprovalStore) { authorizationRequest = super.checkForPreApproval(authorizationRequest, userAuthentication); // this is set up in OAuth2ServerConfiguration::configure (autoApprove) approved = authorizationRequest.isApproved(); } else { if (clientDetailsService != null) { Collection<String> requestedScopes = authorizationRequest.getScope(); try { ClientDetails client = clientDetailsService .loadClientByClientId(authorizationRequest.getClientId()); for (String scope : requestedScopes) { if (client.isAutoApprove(scope) || client.isAutoApprove("all")) { approved = true; break; } } } catch (ClientRegistrationException e) { } } } authorizationRequest.setApproved(approved); return authorizationRequest; }
From source file:org.mitre.openid.connect.ConnectOAuth2RequestFactory.java
@Override public OAuth2Request createOAuth2Request(AuthorizationRequest request) { return new OAuth2Request(request.getRequestParameters(), request.getClientId(), request.getAuthorities(), request.isApproved(), request.getScope(), request.getResourceIds(), request.getRedirectUri(), request.getExtensions());//w w w .j a va 2 s . c om }
From source file:org.smartplatforms.openid.connect.token.SmartTofuUserApprovalHandler.java
/** * Check if the user has already stored a positive approval decision for this site; or if the * site is whitelisted, approve it automatically. * //ww w . java2s. c o m * Otherwise, return false so that the user will see the approval page and can make their own decision. * * @param authorizationRequest the incoming authorization request * @param userAuthentication the Principal representing the currently-logged-in user * * @return true if the site is approved, false otherwise */ @Override public boolean isApproved(AuthorizationRequest authorizationRequest, Authentication userAuthentication) { // if this request is already approved, pass that info through // (this flag may be set by updateBeforeApproval, which can also do funny things with scopes, etc) if (authorizationRequest.isApproved()) { return true; } else { // if not, check to see if the user has approved it if (Boolean.parseBoolean(authorizationRequest.getApprovalParameters().get("user_oauth_approval"))) { // TODO: make parameter name configurable? // check the value of the CSRF parameter if (authorizationRequest.getExtensions().get(CSRF) != null) { if (authorizationRequest.getExtensions().get(CSRF) .equals(authorizationRequest.getApprovalParameters().get(CSRF))) { // make sure the user is actually authenticated return userAuthentication.isAuthenticated(); } } } // if the above doesn't pass, it's not yet approved return false; } }