Skip to content

Commit

Permalink
Shib: turn down logging #2916 #3034
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Mar 30, 2016
1 parent 643e455 commit af72a7b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 26 deletions.
20 changes: 10 additions & 10 deletions src/main/java/edu/harvard/iq/dataverse/Shib.java
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public void init() {

String usernameAssertion = getValueFromAssertion(ShibUtil.usernameAttribute);
internalUserIdentifer = ShibUtil.generateFriendlyLookingUserIdentifer(usernameAssertion, emailAddress);
logger.info("friendly looking identifer (backend will enforce uniqueness):" + internalUserIdentifer);
logger.fine("friendly looking identifer (backend will enforce uniqueness):" + internalUserIdentifer);

String affiliation = shibService.getAffiliation(shibIdp, shibService.getDevShibAccountType());
if (affiliation != null) {
Expand All @@ -211,8 +211,8 @@ public void init() {
AuthenticatedUser au = authSvc.lookupUser(shibAuthProvider.getId(), userPersistentId);
if (au != null) {
state = State.REGULAR_LOGIN_INTO_EXISTING_SHIB_ACCOUNT;
logger.info("Found user based on " + userPersistentId + ". Logging in.");
logger.info("Updating display info for " + au.getName());
logger.fine("Found user based on " + userPersistentId + ". Logging in.");
logger.fine("Updating display info for " + au.getName());
authSvc.updateAuthenticatedUser(au, displayInfo);
logInUserAndSetShibAttributes(au);
String prettyFacesHomePageString = getPrettyFacesHomePageString(false);
Expand All @@ -239,7 +239,7 @@ public void init() {
* eduPersonScopedAffiliation?
*/
// positionToPersist = "FIXME";
logger.info("Couldn't find authenticated user based on " + userPersistentId);
logger.fine("Couldn't find authenticated user based on " + userPersistentId);
visibleTermsOfUse = true;
/**
* Using the email address from the IdP, try to find an existing
Expand Down Expand Up @@ -271,7 +271,7 @@ public void init() {
}

}
logger.info("Debug summary: " + debugSummary + " (state: " + state + ").");
logger.fine("Debug summary: " + debugSummary + " (state: " + state + ").");
logger.fine("redirectPage: " + redirectPage);
}

Expand All @@ -289,7 +289,7 @@ public String confirmAndCreateAccount() {
logger.info("Couldn't create user " + userPersistentId + " due to exception: " + ex.getCause());
}
if (au != null) {
logger.info("created user " + au.getIdentifier());
logger.fine("created user " + au.getIdentifier());
logInUserAndSetShibAttributes(au);
} else {
JsfHelper.addErrorMessage("Couldn't create user.");
Expand All @@ -302,7 +302,7 @@ public String confirmAndConvertAccount() {
ShibAuthenticationProvider shibAuthProvider = new ShibAuthenticationProvider();
String lookupStringPerAuthProvider = userPersistentId;
UserIdentifier userIdentifier = new UserIdentifier(lookupStringPerAuthProvider, internalUserIdentifer);
logger.info("builtin username: " + builtinUsername);
logger.fine("builtin username: " + builtinUsername);
AuthenticatedUser builtInUserToConvert = shibService.canLogInAsBuiltinUser(builtinUsername, builtinPassword);
if (builtInUserToConvert != null) {
AuthenticatedUser au = authSvc.convertBuiltInToShib(builtInUserToConvert, shibAuthProvider.getId(), userIdentifier);
Expand All @@ -325,7 +325,7 @@ public String confirmAndConvertAccount() {
private void logInUserAndSetShibAttributes(AuthenticatedUser au) {
au.setShibIdentityProvider(shibIdp);
session.setUser(au);
logger.info("Groups for user " + au.getId() + " (" + au.getIdentifier() + "): " + getGroups(au));
logger.fine("Groups for user " + au.getId() + " (" + au.getIdentifier() + "): " + getGroups(au));
}

public List<String> getGroups(AuthenticatedUser au) {
Expand Down Expand Up @@ -355,7 +355,7 @@ private String getValueFromAssertion(String key) {
Object attribute = request.getAttribute(key);
if (attribute != null) {
String attributeValue = attribute.toString();
logger.info("The SAML assertion for \"" + key + "\" (optional) was \"" + attributeValue + "\".");
logger.fine("The SAML assertion for \"" + key + "\" (optional) was \"" + attributeValue + "\".");
if (!attributeValue.isEmpty()) {
return attributeValue;
}
Expand All @@ -382,7 +382,7 @@ private String getRequiredValueFromAssertion(String key) throws Exception {
if (attributeValue.isEmpty()) {
throw new Exception(key + " was empty");
}
logger.info("The SAML assertion for \"" + key + "\" (required) was \"" + attributeValue + "\".");
logger.fine("The SAML assertion for \"" + key + "\" (required) was \"" + attributeValue + "\".");
return attributeValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.ejb.EJBException;
Expand Down Expand Up @@ -149,7 +148,7 @@ public BuiltinUser findBuiltInUserByAuthUserIdentifier(String authUserIdentifier
}

public AuthenticatedUser canLogInAsBuiltinUser(String username, String password) {
logger.info("checking to see if " + username + " knows the password...");
logger.fine("checking to see if " + username + " knows the password...");
if (password == null) {
logger.info("password was null");
return null;
Expand All @@ -170,10 +169,10 @@ public AuthenticatedUser canLogInAsBuiltinUser(String username, String password)
String credentialsAuthProviderId = BuiltinAuthenticationProvider.PROVIDER_ID;
try {
AuthenticatedUser au = authSvc.authenticate(credentialsAuthProviderId, authReq);
logger.log(Level.INFO, "User authenticated: {0}", au.getEmail());
logger.fine("User authenticated:" + au.getEmail());
return au;
} catch (AuthenticationFailedException ex) {
logger.info("The username and/or password you entered is invalid. Need assistance accessing your account?" + ex.getResponse().getMessage());
logger.info("The username and/or password entered is invalid: " + ex.getResponse().getMessage());
return null;
} catch (EJBException ex) {
Throwable cause = ex;
Expand Down Expand Up @@ -216,7 +215,7 @@ public String getAffiliation(String shibIdp, DevShibAccountType devShibAccountTy
String devUrl = "http://localhost:8080/resources/dev/sample-shib-identities.json";
discoFeedUrl = devUrl;
}
logger.info("Trying to get affiliation from disco feed URL: " + discoFeedUrl);
logger.fine("Trying to get affiliation from disco feed URL: " + discoFeedUrl);
URL url = null;
try {
url = new URL(discoFeedUrl);
Expand Down Expand Up @@ -293,26 +292,26 @@ public Map<String, String> getRandomUser() throws JsonSyntaxException, JsonIOExc
try {
url = new URL(sURL);
} catch (MalformedURLException ex) {
Logger.getLogger(Shib.class.getName()).log(Level.SEVERE, null, ex);
logger.info("Exception: " + ex);
}
HttpURLConnection randomUserRequest = null;
try {
randomUserRequest = (HttpURLConnection) url.openConnection();
} catch (IOException ex) {
Logger.getLogger(Shib.class.getName()).log(Level.SEVERE, null, ex);
logger.info("Exception: " + ex);
}
try {
randomUserRequest.connect();
} catch (IOException ex) {
Logger.getLogger(Shib.class.getName()).log(Level.SEVERE, null, ex);
logger.info("Exception: " + ex);
}

JsonParser jp = new JsonParser();
JsonElement root = null;
try {
root = jp.parse(new InputStreamReader((InputStream) randomUserRequest.getContent()));
} catch (IOException ex) {
Logger.getLogger(Shib.class.getName()).log(Level.SEVERE, null, ex);
logger.info("Exception: " + ex);
}
if (root == null) {
return getRandomUserStatic();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public static String findSingleValue(String mayHaveMultipleValues) {
* @todo Is it possible to reach this line via a test? If not,
* remove this try/catch.
*/
logger.info("Couldn't find first part of " + singleValue);
logger.fine("Couldn't find first part of " + singleValue);
}
}
return singleValue;
Expand All @@ -133,16 +133,16 @@ public static String generateFriendlyLookingUserIdentifer(String usernameAsserti
* @todo Is it possible to reach this line via a test? If
* not, remove this try/catch.
*/
logger.info(ex + " parsing " + email);
logger.fine(ex + " parsing " + email);
}
} else {
boolean passedValidation = EMailValidator.isEmailValid(email, null);
logger.info("Odd email address. No @ sign ('" + email + "'). Passed email validation: " + passedValidation);
logger.fine("Odd email address. No @ sign ('" + email + "'). Passed email validation: " + passedValidation);
}
} else {
logger.info("email attribute not sent by IdP");
logger.fine("email attribute not sent by IdP");
}
logger.info("the best we can do is generate a random UUID");
logger.fine("the best we can do is generate a random UUID");
return UUID.randomUUID().toString();
}

Expand Down Expand Up @@ -301,7 +301,7 @@ public static Map<String, String> getRandomUserStatic() {
public static void printAttributes(HttpServletRequest request) {
List<String> shibValues = new ArrayList<>();
if (request == null) {
logger.info("HttpServletRequest was null. No shib values to print.");
logger.fine("HttpServletRequest was null. No shib values to print.");
return;
}
for (String attr : shibAttrs) {
Expand All @@ -320,7 +320,7 @@ public static void printAttributes(HttpServletRequest request) {
shibValues.add(attr + ": " + attrObject.toString());
}
}
logger.info("shib values: " + shibValues);
logger.fine("shib values: " + shibValues);
}

}

0 comments on commit af72a7b

Please sign in to comment.