Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding userID via SSO #2

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,29 @@ These parameters are added to the transactions to which they apply:
* Login:LoginScreen:LoginDV:username
* NewSubmission:NewSubmissionScreen:ProductSettingsDV:DefaultBaseState

### Customer Specific Custom Parameters
* All ~ separated name value pairs in a POST parameter name that contains UserIdAndOrganization
* All ~ separated name value pairs in a POST parameter name that contains SectionCounter
* LOB (Line of Business) - Auto, Property, or Umbrella

### userID via SSO
* username was picked up via custom paramter above in environements with no SSO
* Once SSO was enabled the username was not being picked up
* Added functionality to parse 'SAMLResponse' Parameter to pull out userID
* Required to work with Java 1.6, so leveraged Base64Decoder.java

### Further Extending
* To find attributes that may be relevant to your customer I found the easiest way to determine what's available is leveraging Browser Dev Tools
* Chrome & IE both work
* As you click through the app you can see what Post Parameters are available.
* Once you determine which ones are relevant you can add them to the Custom Parameter list

### SAML Example
![SAML Example](https://github.com/newrelic-experimental/newrelic-java-guidewire/blob/SSO/images/parameters.png)

### Custom Params Example
![Custom Params Example](https://github.com/newrelic-experimental/newrelic-java-guidewire/blob/SSO/images/saml.png)

## Support

New Relic has open-sourced this project. This project is provided AS-IS WITHOUT WARRANTY OR DEDICATED SUPPORT. Issues and contributions should be reported to the project here on GitHub. We encourage you to bring your experiences and questions to the [Explorers Hub](https://discuss.newrelic.com) where our community members collaborate on solutions and new ideas.
Expand Down
Binary file added images/parameters.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/saml.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed src/.DS_Store
Binary file not shown.
Binary file removed src/main/java/javax/.DS_Store
Binary file not shown.
64 changes: 64 additions & 0 deletions src/main/java/javax/servlet/http/Base64Decoder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package javax.servlet.http;

import java.io.ByteArrayOutputStream;

public class Base64Decoder {
public static byte[] decode(String data) {
int[] tbl = {
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2,
3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30,
31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
48, 49, 50, 51, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1};
byte[] bytes = data.getBytes();
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
for (int i = 0; i < bytes.length; ) {
int b = 0;
if (tbl[bytes[i]] != -1) {
b = (tbl[bytes[i]] & 0xFF) << 18;
}
// skip unknown characters
else {
i++;
continue;
}

int num = 0;
if (i + 1 < bytes.length && tbl[bytes[i + 1]] != -1) {
b = b | ((tbl[bytes[i + 1]] & 0xFF) << 12);
num++;
}
if (i + 2 < bytes.length && tbl[bytes[i + 2]] != -1) {
b = b | ((tbl[bytes[i + 2]] & 0xFF) << 6);
num++;
}
if (i + 3 < bytes.length && tbl[bytes[i + 3]] != -1) {
b = b | (tbl[bytes[i + 3]] & 0xFF);
num++;
}

while (num > 0) {
int c = (b & 0xFF0000) >> 16;
buffer.write((char) c);
b <<= 8;
num--;
}
i += 4;
}
return buffer.toByteArray();
}

public static byte[] decode(byte[] data) {
return decode(new String(data));
}
}
Loading