Code Monkey home page Code Monkey logo

accessmanagerdemo's Introduction

Access Manager Demo

Article and code updated on 31/05/21

This project is a demonstration of how the Access Manager can be used within an application.

Access Manager provides the ability to restrict access to various part of an application, or even the whole application itself.

This access is restricted using a digit code defined when launching Access Manager for the first time.

Tested under NAOqi version 2.9.5

1.Prerequisites

  1. Go to the Access Manager page on Command Center Store, then add the application to your missions by clicking the "Add to My Missions" button.

  2. Then in the Client Tab on Command Center, click on the robot you want and add Access Manager version 2.1.2 to your robot.

  3. On your Pepper, start the "Update SoftBank Robotics applications" app then Check update now.

  4. Start Access Manager, then create a Digit Code. Write this Digit Code somewhere safe and the associated Recovery Code too (that will be displayed after you clicked Save Digit Code). If you lose both codes, you can get the recovery code on the robot's page on Command Center.

  5. You can now create applications using Access Manager digit code.

2.Set up

To restrict an access, just write down this piece of code (kotlin) right before opening the activity/fragment/application (set your own AUTHENTICATION_CODE) :

val intent = Intent()
intent.component = ComponentName(ACCESS_MANAGER_PACKAGE, AUTHENTICATION_ACTIVITY_PACKAGE)
val list: List<*> = this.packageManager.queryIntentActivities(intent,0)
if (list.isNotEmpty()) {
    startActivityForResult(intent,AUTHENTICATION_CODE)
}

with :

private val ACCESS_MANAGER_PACKAGE = "com.softbankrobotics.accessmanager"
    private val AUTHENTICATION_ACTIVITY_PACKAGE = "com.softbankrobotics.accessmanager.ui.authentication.AuthenticationActivity"

Then, in onActivityResult, handle the various cases, depending on the result, and grant the restricted access or deny it (-1 (RESULT_OK) if the code is correct, 0 otherwise). In this demo, if the code is correct, we set the fragment Granted, and the fragment Denied otherwise.

3.Notes

When calling the Intent Access Manager, Pepper will lose the focus of the demo app. Therefore, if you decide to open Access Manager and then go back to the application, you will have to handle the fact that Pepper will gain the focus again. Moreover, you will need to rebuild all actions which can be run(like Chat, Say, Animate,...) as they can only be run using the current qiContext. We suggest you to check if objects (Topic, QiChatBot, Animation, ...) are null in order to build only the necessary ones to avoid loosing time when focus is gained.

4.License

This project is licensed under the BSD 3-Clause "New" or "Revised" License - see the COPYING file for details.

accessmanagerdemo's People

Watchers

Emile Kroeger avatar James Cloos avatar Clement avatar Thomas Reny avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.