Package com.force.sdk.oauth.context

Examples of com.force.sdk.oauth.context.SecurityContext


        //If a user has been authenticated then the information about that user must be stored
        if (auth != null && auth.getPrincipal() instanceof ForceUserPrincipal) {
            ForceUserPrincipal user = (ForceUserPrincipal) auth.getPrincipal();
            ForceConnectorConfig cc = new ForceConnectorConfig();
            cc.setSessionId(user.getSessionId());
            SecurityContext sc = (SecurityContext) auth.getDetails();
            cc.setServiceEndpoint(sc.getEndPoint());
            cc.setSessionRenewer(this);
            //The security context holder handles the storage of the security context
            ForceSecurityContextHolder.set(sc);

            //The ForceServiceConnector handles the storage of the connector config and will use this config going forward
View Full Code Here


           
            if ((instanceUrl = map.get(INSTANCE_URL_JSON_KEY)) == null) {
                throw new IOException("Missing instance url on response");
            }
           
            SecurityContext sc =
                userDataRetrievalService.retrieveUserData(
                        session, ForceConnectorUtils.buildForceApiEndpoint(instanceUrl), refresh);
           
            return sc;
        } catch (ConnectionException ce) {
View Full Code Here

    }

    @Override
    public Authentication autoLogin(HttpServletRequest request, HttpServletResponse response) {
       
        SecurityContext sc = securityContextService.getSecurityContextFromSession(request);
       
        if (sc != null) {
            return OAuthAuthenticationProvider.createAuthentication(sc);
        }
       
View Full Code Here

    public void logout(HttpServletRequest request, HttpServletResponse response, Authentication authentication) {
        if (authentication == null || authentication.getDetails() == null
                || !(authentication.getDetails() instanceof SecurityContext)) return;
        ForceConnectorConfig config = new ForceConnectorConfig();
        try {
            SecurityContext sc = ((SecurityContext) authentication.getDetails());
            // Use the value from session and not the login endpoint
            request.setAttribute(LogoutSuccessHandler.FORCE_ENDPOINT_ATTRIBUTE, sc.getEndPoint());
            config.setServiceEndpoint(sc.getEndPoint());
            config.setSessionId(sc.getSessionId());
            config.setSessionRenewer(this);
            ForceServiceConnector connector = new ForceServiceConnector();
            connector.setConnectorConfig(config);
            //logout from the partner API
            connector.getConnection().logout();
View Full Code Here

    @Override
    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        OAuthAuthenticationToken authToken = (OAuthAuthenticationToken) authentication;
        try {
            Object details = authToken.getDetails();
            SecurityContext sc;
            if (details instanceof SecurityContext) {
                sc = (SecurityContext) details;
            } else {
                sc = oauthConnector.getAccessToken((String) authToken.getCredentials(), (String) authToken.getDetails());
            }
View Full Code Here

     * @throws AuthenticationException
     */
    @Override
    public Authentication authenticate(Authentication authentication)
            throws AuthenticationException {
        SecurityContext sc = new ForceSecurityContext();
        sc.setEndPoint(SpringSecurityTestData.SFDC_ENDPOINT);
        sc.setSessionId(SpringSecurityTestData.SFDC_SESSION_ID);
        sc.setRefreshToken(SpringSecurityTestData.OAUTH_REFRESH_TOKEN);
        sc.setUserName(SpringSecurityTestData.SFDC_USERNAME);
        return createAuthentication(sc);
    }
View Full Code Here

     */
    public void doFilter(ServletRequest request, ServletResponse response)
            throws IOException, ServletException {
        Assert.assertNotNull(ForceSecurityContextHolder.get());
        Assert.assertNotNull(ForceServiceConnector.getThreadLocalConnectorConfig());
        SecurityContext sc = ForceSecurityContextHolder.get();
        Assert.assertEquals(sc.getUserName(), SpringSecurityTestData.SFDC_USERNAME);
        Assert.assertEquals(sc.getEndPoint(), SpringSecurityTestData.SFDC_ENDPOINT);
        Assert.assertEquals(sc.getSessionId(), SpringSecurityTestData.SFDC_SESSION_ID);
        ConnectorConfig cc = ForceServiceConnector.getThreadLocalConnectorConfig();
        Assert.assertEquals(cc.getServiceEndpoint(), SpringSecurityTestData.SFDC_ENDPOINT);
        Assert.assertNotNull(cc.getSessionRenewer());
    }
View Full Code Here

        return SpringSecurityTestData.OAUTH_ACCESS_CODE;
    }

    @Override
    public SecurityContext refreshAccessToken(String refreshToken) throws IOException {
        SecurityContext securityContext = new ForceSecurityContext();
        securityContext.setEndPoint(SpringSecurityTestData.SFDC_ENDPOINT);
        securityContext.setSessionId(SpringSecurityTestData.SFDC_SESSION_ID_2);
        securityContext.setRefreshToken(SpringSecurityTestData.OAUTH_REFRESH_TOKEN);
        securityContext.setUserName(SpringSecurityTestData.SFDC_USERNAME);
        securityContext.setRole(SpringSecurityTestData.DEFAULT_ROLE);
        return securityContext;
    }
View Full Code Here

                "Cookie containing the security context should have been set");
       
        request = new MockHttpServletRequest();
        request.setCookies(response.getCookies());
       
        SecurityContext sc = storageService.retreiveSecurityContext(request);
       
        Assert.assertNotNull(sc, "Security context should not be null after retrieval from the cookie store");
        assertSecurityContextsAreEqual(
                originalSc, sc, "Security context should be equal after serialization and deserialization to a cookie");
    }
View Full Code Here

    @Test
    public void userWithoutProfileAccessShouldHaveDefaultRole() throws ConnectionException {
        try {
            Mockit.setUpMocks(MockInsufficientProfileAccessPartnerConnection.class);
            SecurityContext sc = new ForceSecurityContext();
            sc.setEndPoint(originalSc.getEndPoint());
            sc.setSessionId(VALID_SFDC_SID);
            SecurityContextUtil.initializeSecurityContextFromApi(sc);
            assertEquals(sc.getRole(), SecurityContextUtil.DEFAULT_ROLE);
        } finally {
            Mockit.tearDownMocks(MockInsufficientProfileAccessPartnerConnection.class);
        }
    }
View Full Code Here

TOP

Related Classes of com.force.sdk.oauth.context.SecurityContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.