984 skills found · Page 7 of 33
lnmangione / TuringMachineSimulatorA basic Turing Machine simulator in Java that can be used to compute strings
qixuanHou / Mapping My BreakPlease Read Me First. This is a set of java file of my final version of electronic artifacts. This is a game to map my experience in Disney World, in Orlando during this spring break. However, because of my limited skills in computer science, I really have no idea how to simplify the process to run the game. Sorry for the inconvenience. In order to run the game, you may need to install JAVA. I hope the following links will help you. http://www.oracle.com/technetwork/java/javase/downloads/index-jsp-138363.html#javasejdk http://www.cc.gatech.edu/~simpkins/teaching/gatech/cs1331/guides/install-java.html My main file is called Disney. You can call Disney in console to start the game. However, I failed to putting all the things inside Disney file. Therefore, you may also need to call AdventureLand, MainStreet, and FrontierLand to start other three games. I hope this will help you. Sorry again for the inconvenience. 1. the structure of my project My project only focused on my trip in Magic Kingdom, one part of Disney world in Orlando. It is a game which guides players to choose from six sub-games, which match six sections of the park, Main Street U.S.A, Tomorrowland, Adventureland, Frontierland, Fantasyland and Liberty Square. I chose one of the rides I took in each section which, from my perspective, shows what I found interesting in Disney world. I changed what I experienced in the park into a small computer game. I want to share my experience with others while they play my games. In the following part of self reflection, I explain the background, rules and other things about each game. For convenience of matching them, I use different color to mark different parts. I hope it will help readers a little bit when they are lost in my disordered reflections. 1. the hall of presidents - Liberty Square 2. Festivall parade - Fantasyland (I explain this one in the part of technology skill limitations) 3. Big Thunder Mountain Railroad - Frontierland 4.talking with Woody- Adventureland 5. Stitch Store - Tomorrowland 6. lunch time - Main Street USA 3. my reflection of the trip in Disney World from dream to reality When I exited Disney resort, I found a sign along the street welcomed people back to real world. Actually, when I was in Orlando, I couldn't believe as an adult, people can mess up fantasy world in the theme parks and the real world. Nevertheless, I felt I was still in fantasy world, when I dreamed twice that I fought for the key to open the door of future. As is known to all, while sleeping, people always dream about what people thinks in the daytime. Therefore, my dream shows that my mind still stayed in the world with Mickey and Donald. I believe that it is experiencing fantasy world which is the source of the greatest happiness people get from theme park. On the one hand, everybody has pressure in real life especially for adults. They can get out of pressure for a day trip in theme park. They can experience different lives here with cartoon characters. On the other hand, sometimes, it is a really hard task to fulfill some dreams, such as being a princess. However, in Disney world, you can dress up the same as Snow White, waiting for your prince; you can go to space by rocket; you can also travel all over the world in one day and enjoy the food of each country. These are all the magic of theme parks. Therefore, in my game, I learnt the way which Disney design their rides to focus on the background story of the game instead of the game itself. For example, there is a ride called Big Thunder Mountain Railroad, which streaks through a haunted gold-mining town aboard a rollicking runaway mine train. The views around the ride were like a gold mining town. There were tools for gold-mining around the railroad and the railroad looked like very old. In order to show riders that it was a haunted gold-mining town, the train always took a sudden turn or speed up quickly to scare people. I decided to name one of my game, which was inspired by this ride, the same name, Big Thunder Mountain Railroad. Instead of sitting inside the mine train to travel around the haunted town, mine was for users to use keyboard to control the train to travel around the gridding railroad. I place traps inside several parts of gridding to "scare" players, who cannot know where traps are until they get into them. If I know how to use animation, I will show scary pictures when players drive their train to the traps. Unlike the ride in Disney, my players can no longer travel once they encounter a trap because their train may have some problems to keep moving. Also, the main goal in the game is to find the gold. However, as we know, finding gold is really hard. Therefore, players must go to find Aladdin's Wonderful lamp where also places inside the gridding while players cannot see its exact place until they happen to drive inside the part where lamp is. Aladdin's Wonderful lamp will show players the map of the gold and when people get to the gold mine, they win. However, there is another limitation of the game. Haunted town is so dangerous during the night. Therefore, players only have 12 hours to finish the task. Train can drive one square in 20 min. Therefore, train can only move 36 times or they will also be caught by traps. In this game, I want to show audiences I have a background story like rides in Disney World. Players need to find the gold in a haunted gold-mining town. Also, in order to show the relationship with Disney, I use Aladdin's Wonderful Lamp as the guide for the players, which is a well known characters in Disney cartoon. I created another game, called talking with Woody to show the magic power of Disney characters. There are a lot of chances to meet Disney characters in Disney world. On the one hand, travelers, especially small kids, are really excited to meet the characters they watched on TV. I think some kids may believe they take pictures with real Mickey Mouse. On the hand, staffs in Disney who wear the costumes are really tired. It was hot in Orlando last week, but all costumes were very heavy. I was moved by the staffs inside Mickey. They also need to mimic the actions of characters and also need to show kindness and warmness to children. It seems like a really hard job. Therefore, I decide to show this part of Disney in my project as well. I decided to use Woody, a toy all the toys look up to. He is smart, kind and brave like a cowboy should be. He is more than a top, he is friend to everyone enjoying the movie Toy. In order to create an interactive game, I planned to ask players to guide Woody. Players need to call Woody before their instructions. For instance, if players say (actually players are typing) "Woody, please sit down", Woody will sit down (actually, there will be another line on the screen showing the same as players import). However, if players are rude and just say "sit down" without calling Woody, Woody won't act (actually there is just nothing showing up on the screen). great facilities to provide convenience to everyone The facilities to satisfy needs for special groups of people, like small kids or disabled people, are well developed. In the past in China, it seemed impossible for parents to take infants and small kids to travel. The road is not flat or wide enough for strollers or wheelchairs. However, in Disney world, everything seemed like well prepared for everyone to use. There are strollers rentals, and electric conveyance vehicles rentals, which are available to rent throughout Disney world. There are baby care center for mothers to feed, change and nurse little ones. There are locker rentals for storing personal items. There are also hearing disability services which have sign language interpretation to help disabled people to enjoy fantasy world. There are still a lot other convenient services in Disney world. I think the purpose of these services show the pursue of equality among everyone in the world. On the one hand, I am really touched by the availability of these services here. It seems Disney try its best to service everyone who have desire to experience fantasy land. On the other hand, in this way, Disney can attract more travelers in order to make more money in some ways. Also, in Disney, it seems like a tradition that there are stores at the exit of the famous rides. Somebody may think it is just a strategy to make people shopping a lot. However, I think it also provides some convenience that travelers can buy souvenirs where is memorable. For example, when I finished my trip in Escape Stitch, I entered a store with a lot of kinds of Stitch, like Stitch pillow, Stitch key chain and so on. I really want to buy something in order to remind me the wonderful feelings. Therefore, I showed my opinion inside my game as well. I wrote one part is for shopping. The items are different kinds of Stitch. My codes can act as a robot to help customers to shop in the store. There are a lot of restaurants in Disney. Maps of Disney are full of restaurants' name. The greatest things about the food are in Epcot, I experienced different counties in one day. I felt like I was in fast travel in different parts of the world and tasted their special food and snacks while I was on the way. I remembered I was still eating Japanese food when I was in "Mexico". It was a great experience. However, there were always a long waiting lines for the all restaurants. People needed to reserve a table a day before their trip and even they had the reservation, they still needed to wait for a long time. I think Disney may need some good ways to fix the problems of waiting for a long time. I have no idea of changing the situation of restaurants, but I think if there are robots to customers to order in fast food restaurant, it may help a lot. Thus, I have another code to customers to order in Plaza Restaurant. If this kind of robots can work in the real life, people can order by themselves and there will be more staffs available to prepare food. theme park uses interesting ways to teach knowledge of boring topics Theme part is also a great source of learning knowledge, especially for kids. They use Disney characters, interesting shows, or even games to teach useful things. The ways change the boring knowledge to interesting things, which always attract children's attention. The most amazing one was an interactive game in Epcot's Innoventions, called "where's the fire?", which teaches adults and children basic fire safety in a fun and entertaining way. About every five minutes, the players waiting in line are divided into two groups and move into the home's entry. Here, a host will explain the object of the game and lay out the rules. The scenario is this: you are on a mission to discover a number of fire hazards commonly found around the house. To do this, you move from room to room, looking for potential risks. To help in the task, each player is given a special "safely light" to help uncover lurking dangers. The rooms are large projection screens. When a hazard is discovered, all persons in the room must shine their safety light on the same spot. when they do, the hazard is rendered harmless and points are assigned. After playing in the game to find the hazardous things in the house, I learned a lot of safety tips. It is much easier to remember the tips I learned during the game than those I learned on textbook or internet. I believe kids will enjoy the games and learn from them as well. I also tried to show this reflection in my project. Thus, I planned to make a game, called the hall of presidents, which test people's knowledge of presidents in USA. However, I failed to achieve the goal of making it an entertaining game instead of a quiz. My game was still like a quiz. However, because it is the only code which can work well inside my big game. I decide to still hold the game for my projects in order to what my original ideas are. 4. technology skill limitations I feel terribly sorry for my limited skills in CS. It is my first time to learn JAVA this semester. I just begin to learn the core concepts of JAVA this month. When I choose to use java code for this project, I know I will face plentiful limitations and problems. Here I want to express my gratitude to Dr. Johnson, who encouraged me not to give up my ideas. To be honest, I have no idea of how to change a java code into a real game with animations. I know the background story of the game is more important for English course and pictures are the best way to show the background, but I have no idea to show all these things by JAVA coding. Therefore, I choose to use videos for my presentation. In this way, I can show my animation inside the videos while the code clue of my game is still composed by JAVA coding. Also, video gives me a lot of freedom when choose my contents for presentation. I can explain a lot details of my project clearly through videos. For example, I found the festival parade in the magic kingdom was great and I wanted to share the experience in my project by showing the pictures or videos. However, because of the technology limitations, I can only show the videos in my presentations. Also, I mistakenly deleted my videos which I shot on my trip Orlando, I can only share others' parade show...... Also, I want to apologize for the incompleteness of my game. I only dedicated to writing codes for Magic Kingdom, a part of my trip during spring break. Writing codes is a really time consuming task for me. In general, I need to spend more than eight hours to finish one project for my CS assignment this semester. While for this project, the final artifacts are composed of several parts of codes and in the end I need to write the father code in order to take care of my code family for spring break. Due to my limitation in writing codes, I can only finish one part of Disney world. However, I think my code shows all my reflections and perspectives during my trip, even though it looks like it only shows one part of my trip. The terrible mistake I made is that I found out the most of my codes I wrote had significant errors on Tuesday. I went to CS TA office for help, while the errors were still impossible to fix in order to achieve the goal I planned to get. Consequently, my game have to be separated into several parts. Instead of a big game having others as sub-games inside the big one, my final artifacts are composed by several small games. I need to start them one by one. It may cause some inconvenience for players to map their trip in Disney world.
marco76 / Java Angular BasicThis is a small showcase of spring boot and angular integration
kongruksiamza / JavaBasicโค้ดประกอบการสอนเนื้อหาเขียนโปรแกรมด้วยภาษา Java เบื้องต้น
MindtreeLtd / Balance Transfer JavaHyperledger Fabric Sample project where Hyperledger Java SDK is used to create a basic hyperledger v1.0 application to demonstrate fabric-client & fabric-ca-client Java SDK APIs
SoftUni / Programming Basics Book Java ENTextbook for the "Programming Basics" course @ SoftUni (Java, English)
zhugejunwei / Algorithms In Java Swift CPPImplementation of Some basic algorithms in Java, C++ and Swift
makerlee / Java Interview 2018java2018面试总结
codetojoy / Easter Eggs For Java 9Basic examples for Java 9 modules. Usage of 'egg' here is SSCCE: http://sscce.org
thatcher / Rhino For WebappsSome basic java to help integrate the Rhino engine into the Servlet environment
Harikishore-Official / Basic Spring Boot Using JavaNo description available
gazalpatel / AI Chat BotThis repository includes Artificial Intelligence implementation in java language to create chatbot. Chat bot is created in Core Java and Swing Project using Eclipse IDE. Projects can be run on other IDE as command line application. This project includes AI specific reply based on user input, basic type-error detection, text processing and text prediction. I intend to improve this project using more use of Natural Language Processing and better Machine Learning Algorithm in future.
sxlong0205 / JavaBasicKnowledgeNo description available
javafx-maven-plugin / Javafx Basic ArchetypeA Maven archetype for generating a basic JavaFX starter project.
chaostheory / JibenakkaA basic set of akka helper java classes and examples such as map reduce
Azure-Samples / Hdinsight Kafka Java Get StartedBasic example of using Java to create a producer and consumer that work with Kafka on HDInsight. Also a demonstration of the streaming api.
PELock / StringEncrypt WebAPIString Encryption and File Encryption for C/C++, C#, Visual Basic .NET, Delphi/Pascal/Object Pascal, Java, JavaScript, Python, Ruby, AutoIt, PowerShell, Haskell, MASM, FASM programming languages.
AnthonyZabs / ITPLibraryBasic system for managing a library on Java.
iainrose / Page ObjectsA basic framework for running automated tests using WebDriver w Java, TestNG & Gradle
mercerheather476 / Turbo Garbanzo [](https://search.maven.org/search?q=g:net.openid%20appauth) [](http://javadoc.io/doc/net.openid/appauth) [](https://github.com/openid/AppAuth-Android/actions/workflows/build.yml) [](https://codecov.io/github/openid/AppAuth-Android?branch=master) AppAuth for Android is a client SDK for communicating with [OAuth 2.0](https://tools.ietf.org/html/rfc6749) and [OpenID Connect](http://openid.net/specs/openid-connect-core-1_0.html) providers. It strives to directly map the requests and responses of those specifications, while following the idiomatic style of the implementation language. In addition to mapping the raw protocol flows, convenience methods are available to assist with common tasks like performing an action with fresh tokens. The library follows the best practices set out in [RFC 8252 - OAuth 2.0 for Native Apps](https://tools.ietf.org/html/rfc8252), including using [Custom Tabs](https://developer.chrome.com/multidevice/android/customtabs) for authorization requests. For this reason, `WebView` is explicitly *not* supported due to usability and security reasons. The library also supports the [PKCE](https://tools.ietf.org/html/rfc7636) extension to OAuth which was created to secure authorization codes in public clients when custom URI scheme redirects are used. The library is friendly to other extensions (standard or otherwise) with the ability to handle additional parameters in all protocol requests and responses. A talk providing an overview of using the library for enterprise single sign-on (produced by Google) can be found here: [Enterprise SSO with Chrome Custom Tabs](https://www.youtube.com/watch?v=DdQTXrk6YTk). ## Download AppAuth for Android is available on [MavenCentral](https://search.maven.org/search?q=g:net.openid%20appauth) ```groovy implementation 'net.openid:appauth:<version>' ``` ## Requirements AppAuth supports Android API 16 (Jellybean) and above. Browsers which provide a custom tabs implementation are preferred by the library, but not required. Both Custom URI Schemes (all supported versions of Android) and App Links (Android M / API 23+) can be used with the library. In general, AppAuth can work with any Authorization Server (AS) that supports native apps as documented in [RFC 8252](https://tools.ietf.org/html/rfc8252), either through custom URI scheme redirects, or App Links. AS's that assume all clients are web-based or require clients to maintain confidentiality of the client secrets may not work well. ## Demo app A demo app is contained within this repository. For instructions on how to build and configure this app, see the [demo app readme](https://github.com/openid/AppAuth-Android/blob/master/app/README.md). ## Conceptual overview AppAuth encapsulates the authorization state of the user in the [net.openid.appauth.AuthState](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthState.java) class, and communicates with an authorization server through the use of the [net.openid.appauth.AuthorizationService](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationService.java) class. AuthState is designed to be easily persistable as a JSON string, using the storage mechanism of your choice (e.g. [SharedPreferences](https://developer.android.com/training/basics/data-storage/shared-preferences.html), [sqlite](https://developer.android.com/training/basics/data-storage/databases.html), or even just [in a file](https://developer.android.com/training/basics/data-storage/files.html)). AppAuth provides data classes which are intended to model the OAuth2 specification as closely as possible; this provides the greatest flexibility in interacting with a wide variety of OAuth2 and OpenID Connect implementations. Authorizing the user occurs via the user's web browser, and the request is described using instances of [AuthorizationRequest](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationRequest.java). The request is dispatched using [performAuthorizationRequest()](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationService.java#L159) on an AuthorizationService instance, and the response (an [AuthorizationResponse](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationResponse.java) instance) will be dispatched to the activity of your choice, expressed via an Intent. Token requests, such as obtaining a new access token using a refresh token, follow a similar pattern: [TokenRequest](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/TokenRequest.java) instances are dispatched using [performTokenRequest()](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationService.java#L252) on an AuthorizationService instance, and a [TokenResponse](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/TokenResponse.java) instance is returned via a callback. Responses can be provided to the [update()](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthState.java#L367) methods on AuthState in order to track and persist changes to the authorization state. Once in an authorized state, the [performActionWithFreshTokens()](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthState.java#L449) method on AuthState can be used to automatically refresh access tokens as necessary before performing actions that require valid tokens. ## Implementing the authorization code flow It is recommended that native apps use the [authorization code](https://tools.ietf.org/html/rfc6749#section-1.3.1) flow with a public client to gain authorization to access user data. This has the primary advantage for native clients that the authorization flow, which must occur in a browser, only needs to be performed once. This flow is effectively composed of four stages: 1. Discovering or specifying the endpoints to interact with the provider. 2. Authorizing the user, via a browser, in order to obtain an authorization code. 3. Exchanging the authorization code with the authorization server, to obtain a refresh token and/or ID token. 4. Using access tokens derived from the refresh token to interact with a resource server for further access to user data. At each step of the process, an AuthState instance can (optionally) be updated with the result to help with tracking the state of the flow. ### Authorization service configuration First, AppAuth must be instructed how to interact with the authorization service. This can be done either by directly creating an [AuthorizationServiceConfiguration](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationServiceConfiguration.java#L102) instance, or by retrieving an OpenID Connect discovery document. Directly specifying an AuthorizationServiceConfiguration involves providing the URIs of the authorization endpoint and token endpoint, and optionally a dynamic client registration endpoint (see "Dynamic client registration" for more info): ```java AuthorizationServiceConfiguration serviceConfig = new AuthorizationServiceConfiguration( Uri.parse("https://idp.example.com/auth"), // authorization endpoint Uri.parse("https://idp.example.com/token")); // token endpoint ``` Where available, using an OpenID Connect discovery document is preferable: ```java AuthorizationServiceConfiguration.fetchFromIssuer( Uri.parse("https://idp.example.com"), new AuthorizationServiceConfiguration.RetrieveConfigurationCallback() { public void onFetchConfigurationCompleted( @Nullable AuthorizationServiceConfiguration serviceConfiguration, @Nullable AuthorizationException ex) { if (ex != null) { Log.e(TAG, "failed to fetch configuration"); return; } // use serviceConfiguration as needed } }); ``` This will attempt to download a discovery document from the standard location under this base URI, `https://idp.example.com/.well-known/openid-configuration`. If the discovery document for your IDP is in some other non-standard location, you can instead provide the full URI as follows: ```java AuthorizationServiceConfiguration.fetchFromUrl( Uri.parse("https://idp.example.com/exampletenant/openid-config"), new AuthorizationServiceConfiguration.RetrieveConfigurationCallback() { ... } }); ``` If desired, this configuration can be used to seed an AuthState instance, to persist the configuration easily: ```java AuthState authState = new AuthState(serviceConfig); ``` ### Obtaining an authorization code An authorization code can now be acquired by constructing an AuthorizationRequest, using its Builder. In AppAuth, the builders for each data class accept the mandatory parameters via the builder constructor: ```java AuthorizationRequest.Builder authRequestBuilder = new AuthorizationRequest.Builder( serviceConfig, // the authorization service configuration MY_CLIENT_ID, // the client ID, typically pre-registered and static ResponseTypeValues.CODE, // the response_type value: we want a code MY_REDIRECT_URI); // the redirect URI to which the auth response is sent ``` Other optional parameters, such as the OAuth2 [scope string](https://tools.ietf.org/html/rfc6749#section-3.3) or OpenID Connect [login hint](http://openid.net/specs/openid-connect-core-1_0.html#rfc.section.3.1.2.1) are specified through set methods on the builder: ```java AuthorizationRequest authRequest = authRequestBuilder .setScope("openid email profile https://idp.example.com/custom-scope") .setLoginHint("jdoe@user.example.com") .build(); ``` This request can then be dispatched using one of two approaches. a `startActivityForResult` call using an Intent returned from the `AuthorizationService`, or by calling `performAuthorizationRequest` and providing pending intent for completion and cancelation handling activities. The `startActivityForResult` approach is simpler to use but may require more processing of the result: ```java private void doAuthorization() { AuthorizationService authService = new AuthorizationService(this); Intent authIntent = authService.getAuthorizationRequestIntent(authRequest); startActivityForResult(authIntent, RC_AUTH); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RC_AUTH) { AuthorizationResponse resp = AuthorizationResponse.fromIntent(data); AuthorizationException ex = AuthorizationException.fromIntent(data); // ... process the response or exception ... } else { // ... } } ``` If instead you wish to directly transition to another activity on completion or cancelation, you can use `performAuthorizationRequest`: ```java AuthorizationService authService = new AuthorizationService(this); authService.performAuthorizationRequest( authRequest, PendingIntent.getActivity(this, 0, new Intent(this, MyAuthCompleteActivity.class), 0), PendingIntent.getActivity(this, 0, new Intent(this, MyAuthCanceledActivity.class), 0)); ``` The intents may be customized to carry any additional data or flags required for the correct handling of the authorization response. #### Capturing the authorization redirect Once the authorization flow is completed in the browser, the authorization service will redirect to a URI specified as part of the authorization request, providing the response via query parameters. In order for your app to capture this response, it must register with the Android OS as a handler for this redirect URI. We recommend using a custom scheme based redirect URI (i.e. those of form `my.scheme:/path`), as this is the most widely supported across all versions of Android. To avoid conflicts with other apps, it is recommended to configure a distinct scheme using "reverse domain name notation". This can either match your service web domain (in reverse) e.g. `com.example.service` or your package name `com.example.app` or be something completely new as long as it's distinct enough. Using the package name of your app is quite common but it's not always possible if it contains illegal characters for URI schemes (like underscores) or if you already have another handler for that scheme - so just use something else. When a custom scheme is used, AppAuth can be easily configured to capture all redirects using this custom scheme through a manifest placeholder: ```groovy android.defaultConfig.manifestPlaceholders = [ 'appAuthRedirectScheme': 'com.example.app' ] ``` Alternatively, the redirect URI can be directly configured by adding an intent-filter for AppAuth's RedirectUriReceiverActivity to your AndroidManifest.xml: ```xml <activity android:name="net.openid.appauth.RedirectUriReceiverActivity" tools:node="replace"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="com.example.app"/> </intent-filter> </activity> ``` If an HTTPS redirect URI is required instead of a custom scheme, the same approach (modifying your AndroidManifest.xml) is used: ```xml <activity android:name="net.openid.appauth.RedirectUriReceiverActivity" tools:node="replace"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:scheme="https" android:host="app.example.com" android:path="/oauth2redirect"/> </intent-filter> </activity> ``` HTTPS redirects can be secured by configuring the redirect URI as an [app link](https://developer.android.com/training/app-links/index.html) in Android M and above. We recommend that a fallback page be configured at the same address to forward authorization responses to your app via a custom scheme, for older Android devices. #### Handling the authorization response Upon completion of the authorization flow, the completion Intent provided to performAuthorizationRequest will be triggered. The authorization response is provided to this activity via Intent extra data, which can be extracted using the `fromIntent()` methods on AuthorizationResponse and AuthorizationException respectively: ```java public void onCreate(Bundle b) { AuthorizationResponse resp = AuthorizationResponse.fromIntent(getIntent()); AuthorizationException ex = AuthorizationException.fromIntent(getIntent()); if (resp != null) { // authorization completed } else { // authorization failed, check ex for more details } // ... } ``` The response can be provided to the AuthState instance for easy persistence and further processing: ``` authState.update(resp, ex); ``` If the full redirect URI is required in order to extract additional information that AppAuth does not provide, this is also provided to your activity: ```java public void onCreate(Bundle b) { // ... Uri redirectUri = getIntent().getData(); // ... } ``` ### Exchanging the authorization code Given a successful authorization response carrying an authorization code, a token request can be made to exchange the code for a refresh token: ```java authService.performTokenRequest( resp.createTokenExchangeRequest(), new AuthorizationService.TokenResponseCallback() { @Override public void onTokenRequestCompleted( TokenResponse resp, AuthorizationException ex) { if (resp != null) { // exchange succeeded } else { // authorization failed, check ex for more details } } }); ``` The token response can also be used to update an AuthState instance: ```java authState.update(resp, ex); ``` ### Using access tokens Finally, the retrieved access token can be used to interact with a resource server. This can be done directly, by extracting the access token from a token response. However, in most cases, it is simpler to use the `performActionWithFreshTokens` utility method provided by AuthState: ```java authState.performActionWithFreshTokens(service, new AuthStateAction() { @Override public void execute( String accessToken, String idToken, AuthorizationException ex) { if (ex != null) { // negotiation for fresh tokens failed, check ex for more details return; } // use the access token to do something ... } }); ``` This also updates the AuthState object with current access, id, and refresh tokens. If you are storing your AuthState in persistent storage, you should write the updated copy in the callback to this method. ### Ending current session Given you have a logged in session and you want to end it. In that case you need to get: - `AuthorizationServiceConfiguration` - valid Open Id Token that you should get after authentication - End of session URI that should be provided within you OpenId service config First you have to build EndSessionRequest ```java EndSessionRequest endSessionRequest = new EndSessionRequest.Builder(authorizationServiceConfiguration) .setIdTokenHint(idToken) .setPostLogoutRedirectUri(endSessionRedirectUri) .build(); ``` This request can then be dispatched using one of two approaches. a `startActivityForResult` call using an Intent returned from the `AuthorizationService`, or by calling `performEndSessionRequest` and providing pending intent for completion and cancelation handling activities. The startActivityForResult approach is simpler to use but may require more processing of the result: ```java private void endSession() { AuthorizationService authService = new AuthorizationService(this); Intent endSessionItent = authService.getEndSessionRequestIntent(endSessionRequest); startActivityForResult(endSessionItent, RC_END_SESSION); } @Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { if (requestCode == RC_END_SESSION) { EndSessionResonse resp = EndSessionResonse.fromIntent(data); AuthorizationException ex = AuthorizationException.fromIntent(data); // ... process the response or exception ... } else { // ... } } ``` If instead you wish to directly transition to another activity on completion or cancelation, you can use `performEndSessionRequest`: ```java AuthorizationService authService = new AuthorizationService(this); authService.performEndSessionRequest( endSessionRequest, PendingIntent.getActivity(this, 0, new Intent(this, MyAuthCompleteActivity.class), 0), PendingIntent.getActivity(this, 0, new Intent(this, MyAuthCanceledActivity.class), 0)); ``` End session flow will also work involving browser mechanism that is described in authorization mechanism session. Handling response mechanism with transition to another activity should be as follows: ```java public void onCreate(Bundle b) { EndSessionResponse resp = EndSessionResponse.fromIntent(getIntent()); AuthorizationException ex = AuthorizationException.fromIntent(getIntent()); if (resp != null) { // authorization completed } else { // authorization failed, check ex for more details } // ... } ``` ### AuthState persistence Instances of `AuthState` keep track of the authorization and token requests and responses. This is the only object that you need to persist to retain the authorization state of the session. Typically, one would do this by storing the authorization state in SharedPreferences or some other persistent store private to the app: ```java @NonNull public AuthState readAuthState() { SharedPreferences authPrefs = getSharedPreferences("auth", MODE_PRIVATE); String stateJson = authPrefs.getString("stateJson", null); if (stateJson != null) { return AuthState.jsonDeserialize(stateJson); } else { return new AuthState(); } } public void writeAuthState(@NonNull AuthState state) { SharedPreferences authPrefs = getSharedPreferences("auth", MODE_PRIVATE); authPrefs.edit() .putString("stateJson", state.jsonSerializeString()) .apply(); } ``` The demo app has an [AuthStateManager](https://github.com/openid/AppAuth-Android/blob/master/app/java/net/openid/appauthdemo/AuthStateManager.java) type which demonstrates this in more detail. ## Advanced configuration AppAuth provides some advanced configuration options via [AppAuthConfiguration](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AppAuthConfiguration.java) instances, which can be provided to [AuthorizationService](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationService.java) during construction. ### Controlling which browser is used for authorization Some applications require explicit control over which browsers can be used for authorization - for example, to require that Chrome be used for second factor authentication to work, or require that some custom browser is used for authentication in an enterprise environment. Control over which browsers can be used can be achieved by defining a [BrowserMatcher](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/browser/BrowserMatcher.java), and supplying this to the builder of AppAuthConfiguration. A BrowserMatcher is suppled with a [BrowserDescriptor](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/browser/BrowserDescriptor.java) instance, and must decide whether this browser is permitted for the authorization flow. By default, [AnyBrowserMatcher](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/browser/AnyBrowserMatcher.java) is used. For your convenience, utility classes to help define a browser matcher are provided, such as: - [Browsers](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/browser/Browsers.java): contains a set of constants for the official package names and signatures of Chrome, Firefox and Samsung SBrowser. - [VersionedBrowserMatcher](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/browser/VersionedBrowserMatcher.java): will match a browser if it has a matching package name and signature, and a version number within a defined [VersionRange](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/browser/VersionRange.java). This class also provides some static instances for matching Chrome, Firefox and Samsung SBrowser. - [BrowserAllowList](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/browser/BrowserAllowList.java): takes a list of BrowserMatcher instances, and will match a browser if any of these child BrowserMatcher instances signals a match. - [BrowserDenyList](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/browser/BrowserDenyList.java): the inverse of BrowserAllowList - takes a list of browser matcher instances, and will match a browser if it _does not_ match any of these child BrowserMatcher instances. For instance, in order to restrict the authorization flow to using Chrome or SBrowser as a custom tab: ```java AppAuthConfiguration appAuthConfig = new AppAuthConfiguration.Builder() .setBrowserMatcher(new BrowserAllowList( VersionedBrowserMatcher.CHROME_CUSTOM_TAB, VersionedBrowserMatcher.SAMSUNG_CUSTOM_TAB)) .build(); AuthorizationService authService = new AuthorizationService(context, appAuthConfig); ``` Or, to prevent the use of a buggy version of the custom tabs in Samsung SBrowser: ```java AppAuthConfiguration appAuthConfig = new AppAuthConfiguration.Builder() .setBrowserMatcher(new BrowserDenyList( new VersionedBrowserMatcher( Browsers.SBrowser.PACKAGE_NAME, Browsers.SBrowser.SIGNATURE_SET, true, // when this browser is used via a custom tab VersionRange.atMost("5.3") ))) .build(); AuthorizationService authService = new AuthorizationService(context, appAuthConfig); ``` ### Customizing the connection builder for HTTP requests It can be desirable to customize how HTTP connections are made when performing token requests, for instance to use [certificate pinning](https://www.owasp.org/index.php/Certificate_and_Public_Key_Pinning) or to add additional trusted certificate authorities for an enterprise environment. This can be achieved in AppAuth by providing a custom [ConnectionBuilder](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/connectivity/ConnectionBuilder.java) instance. For example, to custom the SSL socket factory used, one could do the following: ```java AppAuthConfiguration appAuthConfig = new AppAuthConfiguration.Builder() .setConnectionBuilder(new ConnectionBuilder() { public HttpURLConnection openConnect(Uri uri) throws IOException { URL url = new URL(uri.toString()); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); if (connection instanceof HttpsUrlConnection) { HttpsURLConnection connection = (HttpsURLConnection) connection; connection.setSSLSocketFactory(MySocketFactory.getInstance()); } } }) .build(); ``` ### Issues with [ID Token](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/IdToken.java#L118) validation ID Token validation was introduced in `0.8.0` but not all authorization servers or configurations support it correctly. - For testing environments [setSkipIssuerHttpsCheck](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AppAuthConfiguration.java#L129) can be used to bypass the fact the issuer needs to be HTTPS. ```java AppAuthConfiguration appAuthConfig = new AppAuthConfiguration.Builder() .setSkipIssuerHttpsCheck(true) .build() ``` - For services that don't support nonce[s] resulting in **IdTokenException** `Nonce mismatch` just set nonce to `null` on the `AuthorizationRequest`. Please consider **raising an issue** with your Identity Provider and removing this once it is fixed. ```java AuthorizationRequest authRequest = authRequestBuilder .setNonce(null) .build(); ``` ## Dynamic client registration AppAuth supports the [OAuth2 dynamic client registration protocol](https://tools.ietf.org/html/rfc7591). In order to dynamically register a client, create a [RegistrationRequest](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/RegistrationRequest.java) and dispatch it using [performRegistrationRequest](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationService.java#L278) on your AuthorizationService instance. The registration endpoint can either be defined directly as part of your [AuthorizationServiceConfiguration](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/AuthorizationServiceConfiguration.java), or discovered from an OpenID Connect discovery document. ```java RegistrationRequest registrationRequest = new RegistrationRequest.Builder( serviceConfig, Arrays.asList(redirectUri)) .build(); ``` Requests are dispatched with the help of `AuthorizationService`. As this request is asynchronous the response is passed to a callback: ```java service.performRegistrationRequest( registrationRequest, new AuthorizationService.RegistrationResponseCallback() { @Override public void onRegistrationRequestCompleted( @Nullable RegistrationResponse resp, @Nullable AuthorizationException ex) { if (resp != null) { // registration succeeded, store the registration response AuthState state = new AuthState(resp); //proceed to authorization... } else { // registration failed, check ex for more details } } }); ``` ## Utilizing client secrets (DANGEROUS) We _strongly recommend_ you avoid using static client secrets in your native applications whenever possible. Client secrets derived via a dynamic client registration are safe to use, but static client secrets can be easily extracted from your apps and allow others to impersonate your app and steal user data. If client secrets must be used by the OAuth2 provider you are integrating with, we strongly recommend performing the code exchange step on your backend, where the client secret can be kept hidden. Having said this, in some cases using client secrets is unavoidable. In these cases, a [ClientAuthentication](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/ClientAuthentication.java) instance can be provided to AppAuth when performing a token request. This allows additional parameters (both HTTP headers and request body parameters) to be added to token requests. Two standard implementations of ClientAuthentication are provided: - [ClientSecretBasic](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/ClientSecretBasic.java): includes a client ID and client secret as an HTTP Basic Authorization header. - [ClientSecretPost](https://github.com/openid/AppAuth-Android/blob/master/library/java/net/openid/appauth/ClientSecretPost.java): includes a client ID and client secret as additional request parameters. So, in order to send a token request using HTTP basic authorization, one would write: ```java ClientAuthentication clientAuth = new ClientSecretBasic(MY_CLIENT_SECRET); TokenRequest req = ...; authService.performTokenRequest(req, clientAuth, callback); ``` This can also be done when using `performActionWithFreshTokens` on AuthState: ```java ClientAuthentication clientAuth = new ClientSecretPost(MY_CLIENT_SECRET); authState.performActionWithFreshTokens( authService, clientAuth, action); ``` ## Modifying or contributing to AppAuth This project requires the Android SDK for API level 25 (Nougat) to build, though the produced binaries only require API level 16 (Jellybean) to be used. We recommend that you fork and/or clone this repository to make modifications; downloading the source has been known to cause some developers problems. For contributors, see the additional instructions in [CONTRIBUTING.md](https://github.com/openid/AppAuth-Android/blob/master/CONTRIBUTING.md). ### Building from the Command line AppAuth for Android uses Gradle as its build system. In order to build the library and app binaries, run `./gradlew assemble`. The library AAR files are output to `library/build/outputs/aar`, while the demo app is output to `app/build/outputs/apk`. In order to run the tests and code analysis, run `./gradlew check`. ### Building from Android Studio In AndroidStudio, File -> New -> Import project. Select the root folder (the one with the `build.gradle` file).