1e41f4b71Sopenharmony_ci# Security Component Overview 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ciSecurity components are a set of ArkUI components provided with certain permissions. You can integrate the security components to your application UI. The security components come with automatic authorization, which eliminates the authorization dialog boxes. They can be used as special buttons that help implement authorization upon a click. 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci 7e41f4b71Sopenharmony_ciCompared with dynamic permission requesting, security components allow scenario-based authorization and simplify development and user operations. The security components stand out with the following features: 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci- Minimizes the authorization by allowing the user to control when to grant the permission. 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ci- Allows the authorization scenario to match the user's real intent. 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci- Reduces pop-up windows. 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci- Simplifies operations as you do not need to request permissions from AppGallery. 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciSecurity components collect only personal data necessary for implementing service functions and help develop transparent, optional, and controllable privacy compliance applications. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci 22e41f4b71Sopenharmony_ci## Security Components 23e41f4b71Sopenharmony_ci 24e41f4b71Sopenharmony_ciCurrently, the following security components are available: 25e41f4b71Sopenharmony_ci 26e41f4b71Sopenharmony_ci- [PasteButton](pastebutton.md) 27e41f4b71Sopenharmony_ci 28e41f4b71Sopenharmony_ci The **PasteButton** component comes with the pasteboard read privilege. After the component integrated into your application is tapped, no authorization dialog box will be displayed when your application reads data from the pasteboard. 29e41f4b71Sopenharmony_ci 30e41f4b71Sopenharmony_ci You can use this component for applications that need to read data from the pasteboard. 31e41f4b71Sopenharmony_ci 32e41f4b71Sopenharmony_ci- [SaveButton](savebutton.md) 33e41f4b71Sopenharmony_ci 34e41f4b71Sopenharmony_ci The **SaveButton** component comes with the privilege for writing data to the media library. When it is tapped, the application can access the **mediaLibrary** APIs within 10 seconds. 35e41f4b71Sopenharmony_ci 36e41f4b71Sopenharmony_ci You can use the **SaveButton** component when your application needs to save image or videos to the media library. This component allows for simpler operations than Pickers, which have to start a system application and have the user select a directory for saving the image or video. 37e41f4b71Sopenharmony_ci 38e41f4b71Sopenharmony_ci- [\<LocationButton>](locationbutton.md) 39e41f4b71Sopenharmony_ci 40e41f4b71Sopenharmony_ci The **\<LocationButton>** component comes with the precise location privilege. When it is tapped, the application running in the foreground can call the location service to obtain the precise location no matter whether the application has applied for or is granted with the precise location permission. 41e41f4b71Sopenharmony_ci 42e41f4b71Sopenharmony_ci You can use this component in applications that do not strongly depend on location (such as navigation and health applications) and applications that require location information only in certain foreground scenarios (such as locating city, clocking in/out, and sharing the location). If location information is required for a long period of time or in the background, you are advised to apply for the location permission for your application. 43e41f4b71Sopenharmony_ci 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci## Working Mechanism 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ciThe security component solution consists of the following: 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci- UI component: implements the style of fixed text and icons for users to identify and provides rich customization capabilities. 50e41f4b71Sopenharmony_ci 51e41f4b71Sopenharmony_ci- Component manager service: provides the component registration management capability, temporary authorization mechanism, and authorization validity period management to ensure that security components cannot be registered or used when the screen is locked or the application runs in the background. 52e41f4b71Sopenharmony_ci 53e41f4b71Sopenharmony_ci- Security hardening: prevents abuse of the authorization mechanism and protects user privacy with security mechanisms, such as randomizing addresses, verifying the challenge value, checking component information in the UI framework callback, checking the caller address, preventing component overriding, and verifying real click events. 54e41f4b71Sopenharmony_ci 55e41f4b71Sopenharmony_ciThe following figure illustrates the working mechanism. 56e41f4b71Sopenharmony_ci 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci1. After a security component is declared in .ets files, the JS engine parses the .ets files and creates the security component in the ArkUI framework. 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci2. The security component registers with the security component manager service, which checks the validity of the component information. 63e41f4b71Sopenharmony_ci 64e41f4b71Sopenharmony_ci3. When a user taps the security component, a click event is distributed to the security component. 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci4. The security component reports the click event to the security component manager service. 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci5. The security component manager service calls the permission manager service to perform temporary authorization based on the component type. 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci6. After the authorization is successful, the security component calls **OnClick()** to notify the application layer of the authorization success. 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci7. The application calls the related API to perform the operation, for example, obtain location information, read data from the pasteboard, or create a file in the media library. 73e41f4b71Sopenharmony_ci The permission usage and authorization validity period vary with the security component. For details, see the development guide of the specific security component. 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci8. The corresponding service calls the permission manager service or security component manager service to obtain the authorization result and return the authentication result. 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci 78e41f4b71Sopenharmony_ci## Constraints 79e41f4b71Sopenharmony_ci 80e41f4b71Sopenharmony_ciDue to the automatic authorization feature, many restrictions are imposed on security components to prevent user privacy from being obtained by malicious applications. The security components must be clearly visible on the application UI and can be clearly identified by users to prevent authorization failures. 81e41f4b71Sopenharmony_ci 82e41f4b71Sopenharmony_ciIf the authorization fails due to invalid component style, check the device error logs with the keyword "SecurityComponentCheckFail". 83e41f4b71Sopenharmony_ci 84e41f4b71Sopenharmony_ci> **NOTE** 85e41f4b71Sopenharmony_ci> Pay attention to logs of all levels related to the keyword. 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ciPossible causes include but are not limited to the following: 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci- The font or icon size is too small. 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci- The overall size of the security component is too large. 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci- The color transparency of the font, icon, and background buttons is too high. 94e41f4b71Sopenharmony_ci 95e41f4b71Sopenharmony_ci- The font or icon color is too close to the background button color. 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci- The security component cannot be displayed completely in a screen or window. 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_ci- The security component is blocked by another component or window. 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ci- The parent component of the security component has attributes that may cause improper display of the security component, such as deformation and blurring. 102