Spring Social - Messaging Friends & Influencing People

Gordon Dickens
Gordon DickensCIGNA IT Principal en CIGNA Group Insurance
Spring Social

Messaging Friends & Influencing
           People

           ETE 2011
         Apr 27-28, 2011
Who Am I?

• Instructor/Mentor

• Active Tweeter for Open Source Tech
  Topics
  twitter.com/gdickens



• Certified Instructor for

• DZone Most Valuable Blogger
  dzone.com/page/mvbs – dzone.com/user/284679
  Technophile Blog   - technophile.gordondickens.com
                                                       2
Agenda

•   Spring & REST
•   Spring Social
•   Security with OAuth
•   Spring Mobile
•   Spring Android
•   Spring iPhone
•   Spring Greenhouse
                          3
Social & Mobile Projects

•   Spring   Social
•   Spring   Mobile
•   Spring   Android
•   Spring   Greenhouse




                           4
What is Spring Social?

• Allow ourapps to interact with




                                   5
Simple Twitter
TwitterTemplatetwitterTemplate =
  new TwitterTemplate();

List<String> friends =
twitterTemplate.getFriends("chariotsolution");


for (String friend : friends) {
  logger.debug("Friend: {}”, friend);
}



                                                 6
What is TwitterTemplate?

• One of the Provider Specific
  Templates
• A convenience class
• Implements TwitterApi
• Wraps RESTful calls to Twitter
  –Using Spring 3 RestTemplate
• OAuth support – provider specific
                                      7
Twitter API




              8
REST& Social Media

• Search Twitter with RestTemplate
RestTemplaterestTemplate=
  new RestTemplate();

String search= "#phillyete";

String results = restTemplate.getForObject(
  "http://search.twitter.com/search.json?q={sea
  rch}",String.class, search);

                 Note: All the cool kids are using REST


                                                      9
Who is using REST?




                     10
Spring REST

• Added in Spring 3.0
• RestTemplate
  – Client side
• Spring MVC
  – Server side
  – <mvc:annotation-driven/>
  – Annotations
  – Content Negotiation
  – Web page support for PUT & DELETE
     • HiddenHttpMethodFilter


                                        11
<mvc:annotation-driven/>

• Validation
  – JSR-303
• Formatting
  – Annotated Field Formatters
• Conversion
  – JSON
  – XML
  – ATOM/RSS
  – JodaTime
  – Custom Conversion (MyBean1 to/from MyBean2)

                                                  12
Spring REST Annotations
• @RequestMapping                • @RequestHeader
  – Method for URL Path            – Value in Req Header
• @PathVariable                  • @ResponseStatus
  – Var in URL path “/{myVar}”     – Http Codes on success
• @RequestParam                  • @ExceptionHandler
  – Parameter                      – Methods by exception
    “/myurl/?myVar=abc”          • @ModelAttribute
• @RequestBody                     – Returning result into model
  – Unmarshal into bean
• @ResponseBody
  – Marshal into bean

                                                               13
Spring REST Annotations
@Controller
public class TwitterTimelineController {
    ...

@RequestMapping(value="/twitter/timeline/{timelineType}", method=RequestMethod.GET)
public String showTimeline(@PathVariable("timelineType") String timelineType, Model
    model) {

    TwitterApi twitterApi = getTwitterApi();
    if (timelineType.equals("Home")) {
      model.addAttribute("timeline", twitterApi.timelineOperations().getHomeTimeline());
    } else if(timelineType.equals("Public")) {
      model.addAttribute("timeline",
      twitterApi.timelineOperations().getPublicTimeline());
      ...
    }
    model.addAttribute("timelineName", timelineType);
    return "twitter/timeline";
}




                                                                                       14
Content Negotiating

• ContentNegotiatingViewResolver
 –Client requests format of data
 –“Accept” header
 –“format” parameter
 –URL extension
 –Java Activation Framework

                                   15
Templates to the Rescue

• Template for each Social Media Provider
  – TwitterTemplate, LinkedInTemplate,   etc.

• Provider Specific
  – Authentication Support
  – API methods

• For other providers:
  – Roll your own
  – RestTemplate    is our friend
                                                16
Template API Calls

• Most calls require authentication
  –Some trivial calls do not need auth


• Authentication
  –Provider side
  –Secured with OAuth

                                         17
Authenticating



“An open protocol to allow secure API
     authorization in a simple and
   standard method from desktop to
          web applications.”
           http://oauth.net

     code.google.com/p/oauth/
                                    18
OAuth Participants

• Client
                          Client
  – Our app
  – Wants to access serverto Access
                      Wants

• Server
                                          Server
  – With whom we want to connect
  – May not be the provider
• Service Provider
  – Provides authentication                S.P.

                                      I verify credentials

                                                        19
OAuth Flavors

• 1.0a
  –More complex



• 2.0


                  20
OAuth Safety Dance
                     1. App asks for a request token
                     •   OAuth 1.0a - w callback URL

                     2. Provider issues a request token

                     3. App redirects user to provider's auth page
                     •   passes request token
                     •   OAuth 1.0a – w callback URL

                     4. Provider prompts to authorize

                     5. Provider redirects user back to app
                     •   OAuth 1.0a – w verifier code

                     6. App exchanges request token for access to
                     •   OAuth 1.0a - also w verifier code

                     7. Provider issues access token

                     8. App uses the access token
                     •   App now obtains a ref to the Service API
                     •   interacts with provider on behalf of the user
                                                              21
Twitter Auth Steps
1. ApiKey-   Redirect user to provider auth
     page
2.   User authenticates themselves
3.   User authorizes our app to act on
     their behalf
4.   User redirected to our site
     w/RequestToken &VerificationCode
5.   RequestToken &VerificationCode, get
     AccessToken
6. Interact w/ provider using ApiKey
   &AccessToken                            22
Template & OAuth Summary

• Provider specific template
• OAuth support within template

• How do we manage provider login
  and credential storage?
           We need CPR!
                                  23
Spring CPR

• Connect Controller            TwitterController
  – Connection to Service
   Provider
• Service Provider            TwitterServiceProvider

  – Twitter, LinkedIn, etc.
• Connection Repository       ConnectionRepository

  – Storage for Connection
    Details

                                                       24
Twitter CPR Signin




                     25
Connection API




                 26
CPR - Controller
<bean class=”o.sf.social.web.connect.ConnectController">
<constructor-arg value="${application.url}”/>
</bean>




• application.url
   – Base secure URL for this application
   – used to construct the callback URL
   – passed to the service providers


                                                           27
CPR - Provider
<bean class=”o.sf.social.twitter.connect.TwitterServiceProvider">
<constructor-arg value="${twitter.appId}" />
<constructor-arg value="${twitter.appSecret}" />
<constructor-arg ref="connectionRepository" />
</bean>




• twitter.appId
   – ApiKey assigned to app by provider
• twitter.appSecret
   – VerifierCode returned by provider


                                                                28
CPR - Repository
<bean id="connectionRepository"
   class=”o.sf.social.connect.jdbc.JdbcConnectionRepository">
<constructor-arg ref="dataSource" />          create table Connection (
<constructor-arg ref="textEncryptor" />       id identity,
</bean>                                       accountId varchar not null,
                                              providerId varchar not null,
                                              accessToken varchar not
                                              null,
                                              secret varchar,
                                              refreshToken varchar,
• textEncryptor                               providerAccountId varchar,
                                               primary key (id));
    – interface for symmetric encryption of text strings




                                                                         29
Greenhouse: RI app suite
• Spring Greenhouse (RI)
• Web App
  – Group Event Management
  – Environment-specific Beans and Profiles
  – Password Encoding &Data Encryption
• Social Media
  – Integration
  – Authentication
• Mobile Apps
  – Android
  – iPhone

                                              30
Greenhouse: Social & Mobile
• Spring Social
  – App Framework
  – Service Provider Framework
     • Twitter, Facebook, LinkedIn & TripIt
  – Sign Up, Sign In & Password Reset
  – Member Invite
  – Badge System
• Spring Mobile
  – iPhone Client
  – Android Client
  – Mobile web version for other smartphone platforms

                                                    31
Spring Mobile

• Server Side
• Spring MVC Extension
• Key Facets:
 1. Mobile Device Detection
 2. Site Preference Management
 3. Site Switching

                                 32
Mobile Detection in MVC
•   DeviceResolver
    – Inspects inbound HttpRequest
    – “User-Agent” header
    – Default Analysis: ”Mobile device client?”

• More sophisticated resolvers identify
    –   screen size
    –   manufacturer
    –   model            •   DeviceResolverHandlerInterceptor
    –   preferred markup     – LiteDeviceResolver (default)
                                 • Based on Wordpress Lite Algorithm
                                 • Part of Wordpress Mobile Pack(wpmp)


                             – Plug in another for specific features
                                 • WurflDeviceResolver (Java API)


                                                                         33
MVC Configuration

• Handler Interceptor
  <mvc:interceptors>
  <!– Resolve device on pre-handle -->
  <bean class=”o.sf.mobile.device.DeviceResolverHandlerInterceptor”/>
  </mvc:interceptors>


• Enable Device for Controller Methods
  <mvc:annotation-driven>
  <mvc:argument-resolvers>
  <bean class=”o.sf.mobile.device.DeviceWebArgumentResolver”/>
  </mvc:argument-resolvers>
  </mvc:annotation-driven>


• Inject Device
  @Controller
  public class MyController {
      …
    @RequestMapping("/”)
    public void sayHi(Device device) {
      if (device.isMobile()) logger.info("Hello mobile user!");



                                                                        34
Greenhouse CPR
• AnnotatedControllerConfig
   – DeviceResolverHandlerInterceptor
   – DeviceHandlerMethodArgumentResolver
   – FacebookHandlerMethodArgumentResolver




                                             35
DeviceResolver API




                     36
Preference Management

• App supporting multiple sites
  –“mobile”
  –“normal”
• Allow user to switch
• SitePreferenceHandler   interface
• SitePreferenceWebArgumentResolver
• CookieSitePreferenceRepository
                                      37
MVC Pref Config

• Enable SitePreference support
  <mvc:annotation-driven>
  <mvc:argument-resolvers>
  <bean class=”o.sf.mobile.device.DeviceWebArgumentResolver" />
  <bean class=”o.sf.mobile.device.site.SitePreferenceWebArgumentResolver" />
  </mvc:argument-resolvers>
  </mvc:annotation-driven>



• Inject into Controller Methods
  @Controller
  public class MyController {
    @RequestMapping("/”)
    public String home(SitePreference sitePreference, Model model) {
      if (sitePreference == SitePreference.MOBILE) { …




                                                                               38
Site Switching

• Hosting mobile site different
  location

• SiteSwitcherHandlerInterceptor

• mDot
  m.${serverName}

• dotMobi
  ${serverName}.mobi
                                   39
Spring Android

• Client tools
• Http Components
• RestTemplate
•   Object to JSON Marshaling
•   Object to XML Marshaling
•   RSS and Atom Support
•   Greenhouse app in Android market
    – https://market.android.com/details?id=com.springsource.greenho
      use

                                                                  40
Spring iPhone
• Greenhouse for iPhone client

• Download & Install the iOS SDK

• Project source code from the git
   – git clone git://git.springsource.org/greenhouse/iphone.git

• Open the Greenhouse.xcodeproj in Xcode

• Expects Greenhouse web app running locally

• Greenhouse App in iTunes
   – http://itunes.apple.com/us/app/greenhouse/id395862873?mt=8


                                                                  41
Spring Social Showcase

• Twitter, Facebook, TripIt
• MVC Application
• CPR configuration




                              42
Summary

• Spring Social
     • App collaboration with SM Sites
     • Security through OAuth
• Spring REST
     • Significant for Social & Mobile
     • RestTemplate Rules!
• Spring Mobile
  – MVC Support for Mobile Devices
• Spring Android
  – Client Tools, based on RestTemplate

                                          43
Q& F

• Questions?

• Followup
  – Learn REST…
  – Spring Social Showcase
  – Spring Greenhouse
• Contact me
  – technophile.gordondickens.com
  – gordon@gordondickens.com
                                    44
1 de 44

Recomendados

RESTful Web Services por
RESTful Web ServicesRESTful Web Services
RESTful Web ServicesGordon Dickens
7.4K vistas22 diapositivas
The RESTful Soa Datagrid with Oracle por
The RESTful Soa Datagrid with OracleThe RESTful Soa Datagrid with Oracle
The RESTful Soa Datagrid with OracleEmiliano Pecis
14.7K vistas39 diapositivas
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS por
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRISThe glory of REST in Java: Spring HATEOAS, RAML, Temenos IRIS
The glory of REST in Java: Spring HATEOAS, RAML, Temenos IRISGeert Pante
10.4K vistas17 diapositivas
A great api is hard to find por
A great api is hard to findA great api is hard to find
A great api is hard to findDan Diephouse
1.6K vistas67 diapositivas
Building REST and Hypermedia APIs with PHP por
Building REST and Hypermedia APIs with PHPBuilding REST and Hypermedia APIs with PHP
Building REST and Hypermedia APIs with PHPAzRy LLC, Caucasus School of Technology
14.9K vistas39 diapositivas
Take a REST! por
Take a REST!Take a REST!
Take a REST!Vladimir Tsukur
4.2K vistas241 diapositivas

Más contenido relacionado

La actualidad más candente

REST Architecture with use case and example por
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and exampleShailesh singh
1.4K vistas24 diapositivas
REST API Design por
REST API DesignREST API Design
REST API DesignDevi Kiran G
4.3K vistas23 diapositivas
Web Center Services and Framework por
Web Center Services and  FrameworkWeb Center Services and  Framework
Web Center Services and FrameworkJaime Cid
1.7K vistas48 diapositivas
Restful webservices por
Restful webservicesRestful webservices
Restful webservicesLuqman Shareef
2.1K vistas24 diapositivas
Server-Side Programming Primer por
Server-Side Programming PrimerServer-Side Programming Primer
Server-Side Programming PrimerIvano Malavolta
1.9K vistas49 diapositivas
Representational State Transfer por
Representational State TransferRepresentational State Transfer
Representational State TransferAlexei Skachykhin
1.7K vistas61 diapositivas

La actualidad más candente(20)

REST Architecture with use case and example por Shailesh singh
REST Architecture with use case and exampleREST Architecture with use case and example
REST Architecture with use case and example
Shailesh singh1.4K vistas
Web Center Services and Framework por Jaime Cid
Web Center Services and  FrameworkWeb Center Services and  Framework
Web Center Services and Framework
Jaime Cid1.7K vistas
Server-Side Programming Primer por Ivano Malavolta
Server-Side Programming PrimerServer-Side Programming Primer
Server-Side Programming Primer
Ivano Malavolta1.9K vistas
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7 por CA API Management
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
RESTful Web APIs – Mike Amundsen, Principal API Architect, Layer 7
CA API Management7.5K vistas
Best Practices in Web Service Design por Lorna Mitchell
Best Practices in Web Service DesignBest Practices in Web Service Design
Best Practices in Web Service Design
Lorna Mitchell40.5K vistas
SharePoint Data Anywhere and Everywhere by Chris Beckett - SPTechCon por SPTechCon
SharePoint Data Anywhere and Everywhere by Chris Beckett - SPTechConSharePoint Data Anywhere and Everywhere by Chris Beckett - SPTechCon
SharePoint Data Anywhere and Everywhere by Chris Beckett - SPTechCon
SPTechCon1.3K vistas
RESTful services por gouthamrv
RESTful servicesRESTful services
RESTful services
gouthamrv4.5K vistas
Web development with ASP.NET Web API por Damir Dobric
Web development with ASP.NET Web APIWeb development with ASP.NET Web API
Web development with ASP.NET Web API
Damir Dobric3.9K vistas
HTML5 Server Sent Events/JSF JAX 2011 Conference por Roger Kitain
HTML5 Server Sent Events/JSF  JAX 2011 ConferenceHTML5 Server Sent Events/JSF  JAX 2011 Conference
HTML5 Server Sent Events/JSF JAX 2011 Conference
Roger Kitain2.2K vistas
Servletarchitecture,lifecycle,get,post por vamsi krishna
Servletarchitecture,lifecycle,get,postServletarchitecture,lifecycle,get,post
Servletarchitecture,lifecycle,get,post
vamsi krishna2.6K vistas
Survey of restful web services frameworks por Vijay Prasad Gupta
Survey of restful web services frameworksSurvey of restful web services frameworks
Survey of restful web services frameworks
Vijay Prasad Gupta16.2K vistas
Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc... por Joonas Lehtinen
Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...
Vaadin - Rich Web Applications in Server-side Java without Plug-ins or JavaSc...
Joonas Lehtinen3.4K vistas
Websphere interview Questions por gummadi1
Websphere interview QuestionsWebsphere interview Questions
Websphere interview Questions
gummadi1118.7K vistas

Destacado

Introduction to spring social - illustrated in the Europe PMC project por
Introduction to spring social - illustrated in the Europe PMC projectIntroduction to spring social - illustrated in the Europe PMC project
Introduction to spring social - illustrated in the Europe PMC projectyucigou
285 vistas32 diapositivas
Going Social: What You Need to Know to Launch a Social Media Strategy por
Going Social: What You Need to Know to Launch a Social Media StrategyGoing Social: What You Need to Know to Launch a Social Media Strategy
Going Social: What You Need to Know to Launch a Social Media StrategyJim Rattray
662 vistas56 diapositivas
ALL PATIENTS NEEDING OVERSEAS OR EFMP CLEARANCE FOR PCS MUST COMPLETE THE ATT... por
ALL PATIENTS NEEDING OVERSEAS OR EFMP CLEARANCE FOR PCS MUST COMPLETE THE ATT...ALL PATIENTS NEEDING OVERSEAS OR EFMP CLEARANCE FOR PCS MUST COMPLETE THE ATT...
ALL PATIENTS NEEDING OVERSEAS OR EFMP CLEARANCE FOR PCS MUST COMPLETE THE ATT...20 MDG Facebook
747 vistas23 diapositivas
Social Spring por
Social SpringSocial Spring
Social SpringMatt Oliphant
347 vistas4 diapositivas
Spring social por
Spring socialSpring social
Spring socialFatima Zahra Fagroud
554 vistas27 diapositivas
Socializing your application ( Facebook ) por
Socializing your application ( Facebook )Socializing your application ( Facebook )
Socializing your application ( Facebook )Sandip Jadhav
613 vistas12 diapositivas

Destacado(6)

Introduction to spring social - illustrated in the Europe PMC project por yucigou
Introduction to spring social - illustrated in the Europe PMC projectIntroduction to spring social - illustrated in the Europe PMC project
Introduction to spring social - illustrated in the Europe PMC project
yucigou285 vistas
Going Social: What You Need to Know to Launch a Social Media Strategy por Jim Rattray
Going Social: What You Need to Know to Launch a Social Media StrategyGoing Social: What You Need to Know to Launch a Social Media Strategy
Going Social: What You Need to Know to Launch a Social Media Strategy
Jim Rattray662 vistas
ALL PATIENTS NEEDING OVERSEAS OR EFMP CLEARANCE FOR PCS MUST COMPLETE THE ATT... por 20 MDG Facebook
ALL PATIENTS NEEDING OVERSEAS OR EFMP CLEARANCE FOR PCS MUST COMPLETE THE ATT...ALL PATIENTS NEEDING OVERSEAS OR EFMP CLEARANCE FOR PCS MUST COMPLETE THE ATT...
ALL PATIENTS NEEDING OVERSEAS OR EFMP CLEARANCE FOR PCS MUST COMPLETE THE ATT...
20 MDG Facebook747 vistas
Socializing your application ( Facebook ) por Sandip Jadhav
Socializing your application ( Facebook )Socializing your application ( Facebook )
Socializing your application ( Facebook )
Sandip Jadhav613 vistas

Similar a Spring Social - Messaging Friends & Influencing People

oauth-for-credentials-security-in-rest-api-access por
oauth-for-credentials-security-in-rest-api-accessoauth-for-credentials-security-in-rest-api-access
oauth-for-credentials-security-in-rest-api-accessidsecconf
491 vistas40 diapositivas
Secure your app with keycloak por
Secure your app with keycloakSecure your app with keycloak
Secure your app with keycloakGuy Marom
870 vistas48 diapositivas
Linkedin & OAuth por
Linkedin & OAuthLinkedin & OAuth
Linkedin & OAuthUmang Goyal
5.1K vistas12 diapositivas
OpenID vs OAuth - Identity on the Web por
OpenID vs OAuth - Identity on the WebOpenID vs OAuth - Identity on the Web
OpenID vs OAuth - Identity on the WebRichard Metzler
13.7K vistas45 diapositivas
Api security por
Api security Api security
Api security teodorcotruta
750 vistas38 diapositivas
Stateless Auth using OAuth2 & JWT por
Stateless Auth using OAuth2 & JWTStateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWTGaurav Roy
11.5K vistas73 diapositivas

Similar a Spring Social - Messaging Friends & Influencing People(20)

oauth-for-credentials-security-in-rest-api-access por idsecconf
oauth-for-credentials-security-in-rest-api-accessoauth-for-credentials-security-in-rest-api-access
oauth-for-credentials-security-in-rest-api-access
idsecconf491 vistas
Secure your app with keycloak por Guy Marom
Secure your app with keycloakSecure your app with keycloak
Secure your app with keycloak
Guy Marom870 vistas
Linkedin & OAuth por Umang Goyal
Linkedin & OAuthLinkedin & OAuth
Linkedin & OAuth
Umang Goyal5.1K vistas
OpenID vs OAuth - Identity on the Web por Richard Metzler
OpenID vs OAuth - Identity on the WebOpenID vs OAuth - Identity on the Web
OpenID vs OAuth - Identity on the Web
Richard Metzler13.7K vistas
Stateless Auth using OAuth2 & JWT por Gaurav Roy
Stateless Auth using OAuth2 & JWTStateless Auth using OAuth2 & JWT
Stateless Auth using OAuth2 & JWT
Gaurav Roy11.5K vistas
Spring4 security oauth2 por axykim00
Spring4 security oauth2Spring4 security oauth2
Spring4 security oauth2
axykim0075 vistas
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec... por CA API Management
Understanding Identity in the World of Web APIs – Ronnie Mitra,  API Architec...Understanding Identity in the World of Web APIs – Ronnie Mitra,  API Architec...
Understanding Identity in the World of Web APIs – Ronnie Mitra, API Architec...
CA API Management998 vistas
Mobile Authentication - Onboarding, best practices & anti-patterns por Pieter Ennes
Mobile Authentication - Onboarding, best practices & anti-patternsMobile Authentication - Onboarding, best practices & anti-patterns
Mobile Authentication - Onboarding, best practices & anti-patterns
Pieter Ennes1.2K vistas
Getting Started with Globus for Developers por Globus
Getting Started with Globus for DevelopersGetting Started with Globus for Developers
Getting Started with Globus for Developers
Globus 111 vistas
Web API 2 Token Based Authentication por jeremysbrown
Web API 2 Token Based AuthenticationWeb API 2 Token Based Authentication
Web API 2 Token Based Authentication
jeremysbrown2.6K vistas
Stateless Auth using OAUTH2 & JWT por Mobiliya
Stateless Auth using OAUTH2 & JWTStateless Auth using OAUTH2 & JWT
Stateless Auth using OAUTH2 & JWT
Mobiliya1K vistas
Oauth2 and OWSM OAuth2 support por Gaurav Sharma
Oauth2 and OWSM OAuth2 supportOauth2 and OWSM OAuth2 support
Oauth2 and OWSM OAuth2 support
Gaurav Sharma4K vistas
Securing SharePoint Apps with OAuth por Kashif Imran
Securing SharePoint Apps with OAuthSecuring SharePoint Apps with OAuth
Securing SharePoint Apps with OAuth
Kashif Imran6.7K vistas
Spring4 security oauth2 por Sang Shin
Spring4 security oauth2Spring4 security oauth2
Spring4 security oauth2
Sang Shin281 vistas
Developing Apps with Azure AD por SharePointRadi
Developing Apps with Azure ADDeveloping Apps with Azure AD
Developing Apps with Azure AD
SharePointRadi790 vistas
Adding Identity Management and Access Control to your Application - Exersices por Álvaro Alonso González
Adding Identity Management and Access Control to your Application - ExersicesAdding Identity Management and Access Control to your Application - Exersices
Adding Identity Management and Access Control to your Application - Exersices
.NET Core, ASP.NET Core Course, Session 19 por aminmesbahi
 .NET Core, ASP.NET Core Course, Session 19 .NET Core, ASP.NET Core Course, Session 19
.NET Core, ASP.NET Core Course, Session 19
aminmesbahi475 vistas

Último

Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... por
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...ShapeBlue
54 vistas15 diapositivas
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue por
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlueShapeBlue
50 vistas23 diapositivas
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue por
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueShapeBlue
85 vistas54 diapositivas
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive por
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveNetwork Automation Forum
46 vistas35 diapositivas
MVP and prioritization.pdf por
MVP and prioritization.pdfMVP and prioritization.pdf
MVP and prioritization.pdfrahuldharwal141
38 vistas8 diapositivas
Why and How CloudStack at weSystems - Stephan Bienek - weSystems por
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsShapeBlue
111 vistas13 diapositivas

Último(20)

Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... por ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue54 vistas
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue por ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
2FA and OAuth2 in CloudStack - Andrija Panić - ShapeBlue
ShapeBlue50 vistas
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue por ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlueVNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
VNF Integration and Support in CloudStack - Wei Zhou - ShapeBlue
ShapeBlue85 vistas
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive por Network Automation Forum
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLiveAutomating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Automating a World-Class Technology Conference; Behind the Scenes of CiscoLive
Why and How CloudStack at weSystems - Stephan Bienek - weSystems por ShapeBlue
Why and How CloudStack at weSystems - Stephan Bienek - weSystemsWhy and How CloudStack at weSystems - Stephan Bienek - weSystems
Why and How CloudStack at weSystems - Stephan Bienek - weSystems
ShapeBlue111 vistas
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue por ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlueElevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
Elevating Privacy and Security in CloudStack - Boris Stoyanov - ShapeBlue
ShapeBlue96 vistas
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... por TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc77 vistas
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ... por ShapeBlue
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
Live Demo Showcase: Unveiling Dell PowerFlex’s IaaS Capabilities with Apache ...
ShapeBlue35 vistas
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ... por ShapeBlue
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
How to Re-use Old Hardware with CloudStack. Saving Money and the Environment ...
ShapeBlue65 vistas
Digital Personal Data Protection (DPDP) Practical Approach For CISOs por Priyanka Aash
Digital Personal Data Protection (DPDP) Practical Approach For CISOsDigital Personal Data Protection (DPDP) Practical Approach For CISOs
Digital Personal Data Protection (DPDP) Practical Approach For CISOs
Priyanka Aash81 vistas
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading... por The Digital Insurer
Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...Webinar : Desperately Seeking Transformation - Part 2:  Insights from leading...
Webinar : Desperately Seeking Transformation - Part 2: Insights from leading...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... por ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue42 vistas
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue por ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlueCloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
CloudStack Object Storage - An Introduction - Vladimir Petrov - ShapeBlue
ShapeBlue46 vistas
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... por ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue46 vistas
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... por ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue48 vistas
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T por ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue56 vistas
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates por ShapeBlue
Keynote Talk: Open Source is Not Dead - Charles Schulz - VatesKeynote Talk: Open Source is Not Dead - Charles Schulz - Vates
Keynote Talk: Open Source is Not Dead - Charles Schulz - Vates
ShapeBlue119 vistas

Spring Social - Messaging Friends & Influencing People

  • 1. Spring Social Messaging Friends & Influencing People ETE 2011 Apr 27-28, 2011
  • 2. Who Am I? • Instructor/Mentor • Active Tweeter for Open Source Tech Topics twitter.com/gdickens • Certified Instructor for • DZone Most Valuable Blogger dzone.com/page/mvbs – dzone.com/user/284679 Technophile Blog - technophile.gordondickens.com 2
  • 3. Agenda • Spring & REST • Spring Social • Security with OAuth • Spring Mobile • Spring Android • Spring iPhone • Spring Greenhouse 3
  • 4. Social & Mobile Projects • Spring Social • Spring Mobile • Spring Android • Spring Greenhouse 4
  • 5. What is Spring Social? • Allow ourapps to interact with 5
  • 6. Simple Twitter TwitterTemplatetwitterTemplate = new TwitterTemplate(); List<String> friends = twitterTemplate.getFriends("chariotsolution"); for (String friend : friends) { logger.debug("Friend: {}”, friend); } 6
  • 7. What is TwitterTemplate? • One of the Provider Specific Templates • A convenience class • Implements TwitterApi • Wraps RESTful calls to Twitter –Using Spring 3 RestTemplate • OAuth support – provider specific 7
  • 9. REST& Social Media • Search Twitter with RestTemplate RestTemplaterestTemplate= new RestTemplate(); String search= "#phillyete"; String results = restTemplate.getForObject( "http://search.twitter.com/search.json?q={sea rch}",String.class, search); Note: All the cool kids are using REST 9
  • 10. Who is using REST? 10
  • 11. Spring REST • Added in Spring 3.0 • RestTemplate – Client side • Spring MVC – Server side – <mvc:annotation-driven/> – Annotations – Content Negotiation – Web page support for PUT & DELETE • HiddenHttpMethodFilter 11
  • 12. <mvc:annotation-driven/> • Validation – JSR-303 • Formatting – Annotated Field Formatters • Conversion – JSON – XML – ATOM/RSS – JodaTime – Custom Conversion (MyBean1 to/from MyBean2) 12
  • 13. Spring REST Annotations • @RequestMapping • @RequestHeader – Method for URL Path – Value in Req Header • @PathVariable • @ResponseStatus – Var in URL path “/{myVar}” – Http Codes on success • @RequestParam • @ExceptionHandler – Parameter – Methods by exception “/myurl/?myVar=abc” • @ModelAttribute • @RequestBody – Returning result into model – Unmarshal into bean • @ResponseBody – Marshal into bean 13
  • 14. Spring REST Annotations @Controller public class TwitterTimelineController { ... @RequestMapping(value="/twitter/timeline/{timelineType}", method=RequestMethod.GET) public String showTimeline(@PathVariable("timelineType") String timelineType, Model model) { TwitterApi twitterApi = getTwitterApi(); if (timelineType.equals("Home")) { model.addAttribute("timeline", twitterApi.timelineOperations().getHomeTimeline()); } else if(timelineType.equals("Public")) { model.addAttribute("timeline", twitterApi.timelineOperations().getPublicTimeline()); ... } model.addAttribute("timelineName", timelineType); return "twitter/timeline"; } 14
  • 15. Content Negotiating • ContentNegotiatingViewResolver –Client requests format of data –“Accept” header –“format” parameter –URL extension –Java Activation Framework 15
  • 16. Templates to the Rescue • Template for each Social Media Provider – TwitterTemplate, LinkedInTemplate, etc. • Provider Specific – Authentication Support – API methods • For other providers: – Roll your own – RestTemplate is our friend 16
  • 17. Template API Calls • Most calls require authentication –Some trivial calls do not need auth • Authentication –Provider side –Secured with OAuth 17
  • 18. Authenticating “An open protocol to allow secure API authorization in a simple and standard method from desktop to web applications.” http://oauth.net code.google.com/p/oauth/ 18
  • 19. OAuth Participants • Client Client – Our app – Wants to access serverto Access Wants • Server Server – With whom we want to connect – May not be the provider • Service Provider – Provides authentication S.P. I verify credentials 19
  • 20. OAuth Flavors • 1.0a –More complex • 2.0 20
  • 21. OAuth Safety Dance 1. App asks for a request token • OAuth 1.0a - w callback URL 2. Provider issues a request token 3. App redirects user to provider's auth page • passes request token • OAuth 1.0a – w callback URL 4. Provider prompts to authorize 5. Provider redirects user back to app • OAuth 1.0a – w verifier code 6. App exchanges request token for access to • OAuth 1.0a - also w verifier code 7. Provider issues access token 8. App uses the access token • App now obtains a ref to the Service API • interacts with provider on behalf of the user 21
  • 22. Twitter Auth Steps 1. ApiKey- Redirect user to provider auth page 2. User authenticates themselves 3. User authorizes our app to act on their behalf 4. User redirected to our site w/RequestToken &VerificationCode 5. RequestToken &VerificationCode, get AccessToken 6. Interact w/ provider using ApiKey &AccessToken 22
  • 23. Template & OAuth Summary • Provider specific template • OAuth support within template • How do we manage provider login and credential storage? We need CPR! 23
  • 24. Spring CPR • Connect Controller TwitterController – Connection to Service Provider • Service Provider TwitterServiceProvider – Twitter, LinkedIn, etc. • Connection Repository ConnectionRepository – Storage for Connection Details 24
  • 27. CPR - Controller <bean class=”o.sf.social.web.connect.ConnectController"> <constructor-arg value="${application.url}”/> </bean> • application.url – Base secure URL for this application – used to construct the callback URL – passed to the service providers 27
  • 28. CPR - Provider <bean class=”o.sf.social.twitter.connect.TwitterServiceProvider"> <constructor-arg value="${twitter.appId}" /> <constructor-arg value="${twitter.appSecret}" /> <constructor-arg ref="connectionRepository" /> </bean> • twitter.appId – ApiKey assigned to app by provider • twitter.appSecret – VerifierCode returned by provider 28
  • 29. CPR - Repository <bean id="connectionRepository" class=”o.sf.social.connect.jdbc.JdbcConnectionRepository"> <constructor-arg ref="dataSource" /> create table Connection ( <constructor-arg ref="textEncryptor" /> id identity, </bean> accountId varchar not null, providerId varchar not null, accessToken varchar not null, secret varchar, refreshToken varchar, • textEncryptor providerAccountId varchar, primary key (id)); – interface for symmetric encryption of text strings 29
  • 30. Greenhouse: RI app suite • Spring Greenhouse (RI) • Web App – Group Event Management – Environment-specific Beans and Profiles – Password Encoding &Data Encryption • Social Media – Integration – Authentication • Mobile Apps – Android – iPhone 30
  • 31. Greenhouse: Social & Mobile • Spring Social – App Framework – Service Provider Framework • Twitter, Facebook, LinkedIn & TripIt – Sign Up, Sign In & Password Reset – Member Invite – Badge System • Spring Mobile – iPhone Client – Android Client – Mobile web version for other smartphone platforms 31
  • 32. Spring Mobile • Server Side • Spring MVC Extension • Key Facets: 1. Mobile Device Detection 2. Site Preference Management 3. Site Switching 32
  • 33. Mobile Detection in MVC • DeviceResolver – Inspects inbound HttpRequest – “User-Agent” header – Default Analysis: ”Mobile device client?” • More sophisticated resolvers identify – screen size – manufacturer – model • DeviceResolverHandlerInterceptor – preferred markup – LiteDeviceResolver (default) • Based on Wordpress Lite Algorithm • Part of Wordpress Mobile Pack(wpmp) – Plug in another for specific features • WurflDeviceResolver (Java API) 33
  • 34. MVC Configuration • Handler Interceptor <mvc:interceptors> <!– Resolve device on pre-handle --> <bean class=”o.sf.mobile.device.DeviceResolverHandlerInterceptor”/> </mvc:interceptors> • Enable Device for Controller Methods <mvc:annotation-driven> <mvc:argument-resolvers> <bean class=”o.sf.mobile.device.DeviceWebArgumentResolver”/> </mvc:argument-resolvers> </mvc:annotation-driven> • Inject Device @Controller public class MyController { … @RequestMapping("/”) public void sayHi(Device device) { if (device.isMobile()) logger.info("Hello mobile user!"); 34
  • 35. Greenhouse CPR • AnnotatedControllerConfig – DeviceResolverHandlerInterceptor – DeviceHandlerMethodArgumentResolver – FacebookHandlerMethodArgumentResolver 35
  • 37. Preference Management • App supporting multiple sites –“mobile” –“normal” • Allow user to switch • SitePreferenceHandler interface • SitePreferenceWebArgumentResolver • CookieSitePreferenceRepository 37
  • 38. MVC Pref Config • Enable SitePreference support <mvc:annotation-driven> <mvc:argument-resolvers> <bean class=”o.sf.mobile.device.DeviceWebArgumentResolver" /> <bean class=”o.sf.mobile.device.site.SitePreferenceWebArgumentResolver" /> </mvc:argument-resolvers> </mvc:annotation-driven> • Inject into Controller Methods @Controller public class MyController { @RequestMapping("/”) public String home(SitePreference sitePreference, Model model) { if (sitePreference == SitePreference.MOBILE) { … 38
  • 39. Site Switching • Hosting mobile site different location • SiteSwitcherHandlerInterceptor • mDot m.${serverName} • dotMobi ${serverName}.mobi 39
  • 40. Spring Android • Client tools • Http Components • RestTemplate • Object to JSON Marshaling • Object to XML Marshaling • RSS and Atom Support • Greenhouse app in Android market – https://market.android.com/details?id=com.springsource.greenho use 40
  • 41. Spring iPhone • Greenhouse for iPhone client • Download & Install the iOS SDK • Project source code from the git – git clone git://git.springsource.org/greenhouse/iphone.git • Open the Greenhouse.xcodeproj in Xcode • Expects Greenhouse web app running locally • Greenhouse App in iTunes – http://itunes.apple.com/us/app/greenhouse/id395862873?mt=8 41
  • 42. Spring Social Showcase • Twitter, Facebook, TripIt • MVC Application • CPR configuration 42
  • 43. Summary • Spring Social • App collaboration with SM Sites • Security through OAuth • Spring REST • Significant for Social & Mobile • RestTemplate Rules! • Spring Mobile – MVC Support for Mobile Devices • Spring Android – Client Tools, based on RestTemplate 43
  • 44. Q& F • Questions? • Followup – Learn REST… – Spring Social Showcase – Spring Greenhouse • Contact me – technophile.gordondickens.com – gordon@gordondickens.com 44

Notas del editor

  1. Demo Here – Simple JUnit Test
  2. OAuth Core 1.0 Revision A was created to address a session fixation attack identified in the OAuth Core 1.0 specification as detailed in http://oauth.net/advisories/2009-1.
  3. Request TokenVerifier Code - The OAuth Verifier is a verification code tied to the Request Token. The OAuth Verifier and Request Token both must be provided in exchange for an Access Token. They also both expire together.