public String getValue(SecurityToken token) { return token.getAppUrl(); } public void loadFromMap(AbstractSecurityToken token, Map<String, String> map) {
protected static String getAppUrl(HttpRequest request) { if (request.getAuthType() != AuthType.NONE) { return request.getSecurityToken().getAppUrl(); } // Requests that don't use authentication can share the result. return null; }
protected static String getAppUrl(HttpRequest request) { if (request.getAuthType() != AuthType.NONE) { return request.getSecurityToken().getAppUrl(); } // Requests that don't use authentication can share the result. return null; }
protected static String getAppUrl(HttpRequest request) { if (request.getAuthType() != AuthType.NONE) { return request.getSecurityToken().getAppUrl(); } // Requests that don't use authentication can share the result. return null; }
public OAuthGadgetContext(SecurityToken securityToken, OAuthArguments arguments) { this.securityToken = securityToken; this.container = securityToken.getContainer(); this.appUrl = Uri.parse(securityToken.getAppUrl()); this.bypassSpecCache = arguments.getBypassSpecCache(); }
public OAuthGadgetContext(SecurityToken securityToken, OAuthArguments arguments) { this.securityToken = securityToken; this.container = securityToken.getContainer(); this.appUrl = Uri.parse(securityToken.getAppUrl()); this.bypassSpecCache = arguments.getBypassSpecCache(); }
public OAuthGadgetContext(SecurityToken securityToken, OAuthArguments arguments) { this.securityToken = securityToken; this.container = securityToken.getContainer(); this.appUrl = Uri.parse(securityToken.getAppUrl()); this.bypassSpecCache = arguments.getBypassSpecCache(); }
private void checkSecurityToken(HttpRequest request) { if (request.getSecurityToken() == null) { throw new RuntimeException("Security token should not be null" ); } if (!request.getSecurityToken().isAnonymous()) { throw new RuntimeException("Expected an anonymous security token" ); } if (expectedRequestSecurityToken != null) { if (!expectedRequestSecurityToken.getAppUrl().equals( request.getSecurityToken().getAppUrl() )) { throw new RuntimeException("Security token AppUrl mismatch" ); } } }
@Before public void setUp() { crypter = new BasicBlobCrypter("abcdefafadfaxxxx".getBytes()); token = EasyMock.createMock(SecurityToken.class); origRequest = new HttpRequest(Uri.parse("http://originalrequest/")); EasyMock.expect(token.getAppUrl()).andStubReturn(APP); EasyMock.replay(token); params = new OAuthResponseParams(token, origRequest, crypter); }
@Before public void setUp() { crypter = new BasicBlobCrypter("abcdefafadfaxxxx".getBytes()); token = EasyMock.createMock(SecurityToken.class); origRequest = new HttpRequest(Uri.parse("http://originalrequest/")); EasyMock.expect(token.getAppUrl()).andStubReturn(APP); EasyMock.replay(token); params = new OAuthResponseParams(token, origRequest, crypter); }
@Before public void setUp() { crypter = new BasicBlobCrypter("abcdefafadfaxxxx".getBytes()); token = EasyMock.createMock(SecurityToken.class); origRequest = new HttpRequest(Uri.parse("http://originalrequest/")); EasyMock.expect(token.getAppUrl()).andStubReturn(APP); EasyMock.replay(token); params = new OAuthResponseParams(token, origRequest, crypter); }
private BasicOAuthStoreTokenIndex makeBasicOAuthStoreTokenIndex( SecurityToken securityToken, String serviceName, String tokenName) { BasicOAuthStoreTokenIndex tokenKey = new BasicOAuthStoreTokenIndex(); tokenKey.setGadgetUri(securityToken.getAppUrl()); tokenKey.setModuleId(securityToken.getModuleId()); tokenKey.setServiceName(serviceName); tokenKey.setTokenName(tokenName); tokenKey.setUserId(securityToken.getViewerId()); return tokenKey; }
private BasicOAuthStoreTokenIndex makeBasicOAuthStoreTokenIndex( SecurityToken securityToken, String serviceName, String tokenName) { BasicOAuthStoreTokenIndex tokenKey = new BasicOAuthStoreTokenIndex(); tokenKey.setGadgetUri(securityToken.getAppUrl()); tokenKey.setModuleId(securityToken.getModuleId()); tokenKey.setServiceName(serviceName); tokenKey.setTokenName(tokenName); tokenKey.setUserId(securityToken.getViewerId()); return tokenKey; }
private BasicOAuthStoreTokenIndex makeBasicOAuthStoreTokenIndex( SecurityToken securityToken, String serviceName, String tokenName) { BasicOAuthStoreTokenIndex tokenKey = new BasicOAuthStoreTokenIndex(); tokenKey.setGadgetUri(securityToken.getAppUrl()); tokenKey.setModuleId(securityToken.getModuleId()); tokenKey.setServiceName(serviceName); tokenKey.setTokenName(tokenName); tokenKey.setUserId(securityToken.getViewerId()); return tokenKey; }
@Test public void testBasicDecoder() throws Exception { DefaultSecurityTokenCodec codec = new DefaultSecurityTokenCodec( new FakeContainerConfig("insecure")); String token = "o:v:app:domain:appurl:12345:container"; Map<String, String> parameters = Collections.singletonMap( SecurityTokenCodec.SECURITY_TOKEN_NAME, token); SecurityToken st = codec.createToken(parameters); assertEquals("o", st.getOwnerId()); assertEquals("v", st.getViewerId()); assertEquals("appurl", st.getAppUrl()); assertEquals("container", st.getContainer()); }
@Test public void specRequestMarkedWithAnonymousToken() throws Exception { CapturingPipeline capturingPipeline = new CapturingPipeline(); GadgetSpecFactory factory = new DefaultGadgetSpecFactory( new CountingExecutor(), capturingPipeline, cacheProvider, 10000); factory.getGadgetSpec(createContext(SPEC_URL, false)); SecurityToken st = capturingPipeline.request.getSecurityToken(); assertNotNull(st); assertTrue( st.isAnonymous() ); assertEquals( SPEC_URL.toString(), st.getAppUrl() ); }
@Test public void specRequestMarkedWithAnonymousToken() throws Exception { CapturingPipeline capturingPipeline = new CapturingPipeline(); GadgetSpecFactory factory = new DefaultGadgetSpecFactory( new CountingExecutor(), capturingPipeline, cacheProvider, 10000); factory.getGadgetSpec(createContext(SPEC_URL, false)); SecurityToken st = capturingPipeline.request.getSecurityToken(); assertNotNull(st); assertTrue( st.isAnonymous() ); assertEquals( SPEC_URL.toString(), st.getAppUrl() ); }