<commit_before># Carbon Security

Carbon Security project provides authentication and authorization implementation for carbon products based on [JAAS](#).
## Features:
* JAAS based authentication.
* JAAS based authorization.
* Built in login modules
  * Username Password login module
  * JWT login module
  * SAML login module
* Mechanism to plug-in custom Login modules, callback handlers in an OSGi environment.

## Getting Started

### Authentication

Following are the steps to authenticate a user with an in-built login module.

Add following entry to the `bin/carbon.sh` file to enable JAAS based authentication,
```
    -Djava.security.auth.login.config="$CARBON_HOME/conf/security/carbon-jaas.config"\
```

Configure `carbon-jaas.config` file at `conf/security` to specify the login module to be used for authentication. For example if you wish to use the Username Password login module, `carbon-jaas.config` should look like below.

```
CarbonSecurityConfig {
   org.wso2.carbon.security.jaas.modules.UsernamePasswordLoginModule required;
};
```
Similarly for JWT and SAML login modules, the following fully qualified class names can be used.

-  `org.wso2.carbon.security.jaas.modules.JWTLoginModule`
-  `org.wso2.carbon.security.jaas.modules.SAML2LoginModule`

The following code snippet shows how to perfrom a login using JAAS.

```java
CallbackHandler callbackHandler = new CarbonCallbackHandler(httpRequest);
LoginContext loginContext;
try {
    loginContext = new LoginContext("CarbonSecurityConfig", callbackHandler);
} catch (LoginException e) {
    //logic if initializing login context fails.
}
try {
    loginContext.login();
} catch (LoginException e) {
    //logic if login fails.
}
```<commit_msg>Updating README.md<commit_after># Carbon Security

Carbon Security project provides authentication and authorization implementation for carbon products based on [JAAS](#).
## Features:
* JAAS based authentication.
* JAAS based authorization.
* Built in login modules
  * Username Password login module
  * JWT login module
* Mechanism to plug-in custom Login modules, callback handlers in an OSGi environment.

## Getting Started

### Authentication

Following are the steps to authenticate a user with an in-built login module.

Add following entry to the `bin/carbon.sh` file to enable JAAS based authentication,
```
    -Djava.security.auth.login.config="$CARBON_HOME/conf/security/carbon-jaas.config"\
```

Configure `carbon-jaas.config` file at `conf/security` to specify the login module to be used for authentication. For example if you wish to use the Username Password login module, `carbon-jaas.config` should look like below.

```
CarbonSecurityConfig {
   org.wso2.carbon.security.jaas.modules.UsernamePasswordLoginModule required;
};
```
Similarly for JWT login module, the following fully qualified class name can be used.

-  `org.wso2.carbon.security.jaas.modules.JWTLoginModule`

The following code snippet shows how to perfrom a login using JAAS.

```java
CallbackHandler callbackHandler = new CarbonCallbackHandler(httpRequest);
LoginContext loginContext;
try {
    loginContext = new LoginContext("CarbonSecurityConfig", callbackHandler);
} catch (LoginException e) {
    //logic if initializing login context fails.
}
try {
    loginContext.login();
} catch (LoginException e) {
    //logic if login fails.
}
```
{'fraction_non_alphanumeric': 0.08616577221228384, 'fraction_numerical': 0.0017889087656529517, 'mean_word_length': 4.754716981132075, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7671827', 'n_tokens_mistral': 965, 'n_tokens_neox': 896, 'n_words': 343}