Get LDAP User information from HttpServerletRequest in Jboss - java

My team is migrating a java application from Weblogic to Jboss, when the user has consumed the app, this calls the method getUserFromSession.
The problem is when we get ldap information because this code does not work in Jboss the return error is
java.lang.NoSuchMethodException: io.undertow.servlet.spec.HttpSessionImpl.getInternalAttribute(java.lang.String)
The code to change is as follows, can you help me with some option to get that information something similar to what is currently in place for weblogic
public static UserBean getUserFromSession(HttpServletRequest request) throws SessionExpiredException {
try {
Method methodSession = request.getSession().getClass().getMethod("getInternalAttribute", String.class);
Object authUser = null;
int attempts = 0;
while (authUser == null && attempts < 30) {
authUser = methodSession.invoke(request.getSession(), "weblogic.authuser");
if (authUser == null) {
attempts++;
Thread.sleep(4000);
}
}
if (authUser != null) {
ObjectMapper objectMapper = new ObjectMapper();
String authUserString = objectMapper.writeValueAsString(authUser);
Tools.addLogEntry("private_channel.log", authUserString);
if (!authUserString.contains("MAD_Extr_PrivateChannels_Aut")) {
Tools.addLogEntry("private_channel.log", "User does not have MAD_Extr_PrivateChannels_Aut role");
throw new Exception("Your user does not have a role assigned for Private Channel");
}
if (!authUserString.contains("air")) {
Tools.addLogEntry("private_channel.log", "User does not have air cn");
throw new Exception("Your user does not have an airline assigned");
}
TypeReference<HashMap> typeRef = new TypeReference<HashMap>() {
};
Map mapUser = objectMapper.readValue(authUserString, typeRef);
List principals = (List) mapUser.get("principals");
mapUser = (Map) principals.get(0);
String[] dn = mapUser.get("dn").toString().split(",");
Tools.addLogEntry("private_channel.log", "User dn: " + mapUser.get("dn"));
if (dn.length < 3) {
Tools.addLogEntry("private_channel.log", "User does not have 3 parts in dn");
throw new Exception("Your user does not have an airline properly");
}
UserBean response = new UserBean();
response.setAirlineCode(dn[2].replace("ou=", "").toUpperCase());
response.setUserName(dn[0].replace("cn=", ""));
Tools.addLogEntry("private_channel.log", "User name: " + mapUser.get("name"));
response.setUserId(mapUser.get("name").toString());
return response;
} else {
throw new SessionExpiredException();
}
} catch (Exception ex) {
throw new SessionExpiredException();
}
}

Related

Spring Rest API TransactionSystemException

I'm very new in spring development because I'm not a back developer.
I create a back to manage sports training.
I has several times a TransactionSystemException like
Exceptionorg.springframework.transaction.TransactionSystemException: Could not commit JPA transaction; nested exception is javax.persistence.RollbackException: Error while committing the transaction
I don't understand what it mean.
I have a class Person who contains a Coordinates object on #OneToOne relation.
Each class have a Service class that has a method of adding.
In PersonService's add method, I call the Coordinates add method which save and return saved object.
This is the add method of PersonClass
public ResponseService<ObjectCreatedModel<UUID, PersonneMorale>> add(PersonneMorale personneMorale) {
String messageErreur = TAG + " - add - ";
StatusReturn status = StatusReturn.ERROR;
String message = null;
ObjectCreatedModel<UUID, PersonneMorale> objectCreatedModel = null;
if (personneMorale != null) {
if (personneMorale.getId() == null) {
personneMorale.setId(UUID.randomUUID());
try {
// Gestion des coordonnees
ResponseService<ObjectCreatedModel<UUID, Coordonnees>> responseServiceCoordonnees =
coordonneesService.add(personneMorale.getCoordonnees());
if (responseServiceCoordonnees.isSuccess() || responseServiceCoordonnees.exist()) {
ResponseService<Coordonnees> responseServiceCoordonneesGet = coordonneesService
.getOne(responseServiceCoordonnees.getObjectReturn().getId());
Coordonnees coordonnees = responseServiceCoordonneesGet.getObjectReturn();
personneMorale.setCoordonnees(coordonnees);
personneMorale = personneMoraleRepository.save(personneMorale);
if (personneMorale != null) {
status = StatusReturn.SUCCESS;
objectCreatedModel = new ObjectCreatedModel<>(personneMorale.getId(), null);
} else {
message = messageErreur + StringResource.E_OCCURRED;
}
} else {
status = responseServiceCoordonnees.getStatusReturn();
message = responseServiceCoordonnees.getMessage();
}
} catch (ConstraintViolationException violationException) {
status = StatusReturn.EXCEPTION;
message = messageErreur + ConstraintViolationReader.extractException(violationException);
} catch (Exception ex) {
status = StatusReturn.EXCEPTION;
message = messageErreur + ex.toString();
}
} else {
message = messageErreur + StringResource.E_MUST_NULL;
}
} else {
message = messageErreur + StringResource.E_SET_PARAMETER;
}
return new ResponseService<>(status, message, objectCreatedModel);
}
This is the add method of CoordinatesService
public ResponseService<ObjectCreatedModel<UUID, Coordonnees>> add(Coordonnees coordonnees) {
StatusReturn status = StatusReturn.ERROR;
String message = "";
ObjectCreatedModel<UUID, Coordonnees> objectCreatedModel = null;
if (coordonnees != null) {
if (coordonnees.getIdCoordonnees() == null) {
try {
coordonnees.setIdCoordonnees(UUID.randomUUID());
Coordonnees coordonneesBase = coordonneesRepository.save(coordonnees);
if (coordonneesBase != null) {
status = StatusReturn.SUCCESS;
objectCreatedModel = new ObjectCreatedModel<>(coordonneesBase.getIdCoordonnees(), null);
} else {
message = StringResource.E_ERROR_OCCURRED;
}
} catch (ConstraintViolationException violationException) {
status = StatusReturn.EXCEPTION;
message = "Exception" + ConstraintViolationReader.extractException(violationException);
} catch (Exception ex) {
status = StatusReturn.EXCEPTION;
message = "Exception" + ex.toString();
}
} else {
message = "Coordonnées" + ErrorsString.ERROR_COMMON_ID_MUST_BE_EMPTY;
}
} else {
message = ErrorsString.ERROR_COORDINATES_MANDATORY;
}
return new ResponseService<>(status, message, objectCreatedModel);
}
The error occurs when CoordinatesService try to save coordinates and pass to the catch (Exception e)
Could you help me to understand what Transaction error mean with an example like my code please ?

createNewFile() not working and image not being stored

I am trying to save the images in my local machine and its information in the database. But no data is being inserted into the database. The file is being created but their is no content (is of 0 bytes).
I am using hibernate and spring mvc REST API. I am receiving data from an angular 7 app. The program is running on live server but not on my local machine.
On the local server I get this error and response
POST
http://localhost:8080/com_bmis_app_war_exploded/api/product/save/19
500 core.js:15724 ERROR TypeError: Cannot read property 'length' of
undefined
at AppService.push../src/app/app.service.ts.AppService.errorObjToMap
(app.service.ts:56)
at SafeSubscriber._error (edit-product.component.ts:240)
at SafeSubscriber.push../node_modules/rxjs/_esm5/internal/Subscriber.js.SafeSubscriber.__tryOrUnsub (Subscriber.js:192)...........
This is the response error:
HTTP Status 500 – Internal Server Error
Root
Causejava.lang.UnsupportedOperationException
java.base/sun.nio.fs.WindowsFileSystemProvider.readAttributes(WindowsFileSystemProvider.java:193)
java.base/java.nio.file.Files.readAttributes(Files.java:1763)
com.bmis.app.controller.ProductController.saveProduct(ProductController.java:329)
com.bmis.app.controller.ProductController.addProduct(ProductController.java:443)......................
This is my code:
private ResponseEntity saveProduct(Integer id, #Valid #RequestBody Product product, MultipartFile[] images, BindingResult bindingResult, HttpServletRequest request) throws IOException {
HashMap response = new HashMap();
boolean success = false;
List errors = new ArrayList();
HttpStatus httpStatus = HttpStatus.BAD_REQUEST;
String message = "";
Map data = new HashMap();
Slugify slg = new Slugify();
String directory = "C:/Users/dellm4700/Documents/images";
Set<ProductImage> productImages = new HashSet<>();
for (MultipartFile multipartFile : images) {
ProductImage productImage = new ProductImage();
productImage.setSize(multipartFile.getSize());
productImage.setExtension(multipartFile.getContentType());
productImage.setActualImageName(new Date().getTime() + multipartFile.getOriginalFilename());
productImage.setStandardImageName(multipartFile.getOriginalFilename());
productImage.setNameAtFilestore(slg.slugify(productImage.getActualImageName()));
productImage.setThumbnailImageName("thumb_"+ new Date().getTime() + multipartFile.getOriginalFilename());
productImage.setProduct(product);
productImages.add(productImage);
File imageFile = new File(directory + "/" + productImage.getActualImageName());
imageFile.setReadable(true, false);
imageFile.createNewFile();
Set<PosixFilePermission> perms = Files.readAttributes(imageFile.toPath(), PosixFileAttributes.class).permissions();
try {
multipartFile.transferTo(imageFile);
perms.add(PosixFilePermission.OTHERS_READ);
perms.add(PosixFilePermission.GROUP_READ);
perms.add(PosixFilePermission.OTHERS_READ);
Files.setPosixFilePermissions(imageFile.toPath(), perms);
} catch (IOException e) {
e.printStackTrace();
}
File thumbFile = new File(directory + "/" + productImage.getThumbnailImageName());
thumbFile.setReadable(true, false);
thumbFile.createNewFile();
Set<PosixFilePermission> thumbperms = Files.readAttributes(thumbFile.toPath(), PosixFileAttributes.class).permissions();
perms.add(PosixFilePermission.OTHERS_READ);
perms.add(PosixFilePermission.GROUP_READ);
perms.add(PosixFilePermission.OTHERS_READ);
Files.setPosixFilePermissions(thumbFile.toPath(), perms);
try {
Thumbnails.of(directory + "/" + productImage.getActualImageName())
.size(200, 200).keepAspectRatio(false)
.toFile(thumbFile);
} catch (IOException e) {
e.printStackTrace();
}
}
productImages.addAll(product.getProductImages());
product.setProductImages(productImages);
for (CustomAttribute customAttribute : product.getCustomAttributes()) {
customAttribute.setProduct(product);
}
Claims claims = (Claims) request.getAttribute("claims");
User user = userService.findById((Integer) claims.get("id"));
productValidator.validate(product, bindingResult);
if (id != null) {
Product sourceProduct = productService.findById(id);
// sourceProduct.getPrices().clear();
if (!(StringUtility.compare(sourceProduct.getName(), product.getName())) && (productService.findByName(product.getName()) != null)) {
bindingResult.rejectValue("name", null, "Product with same name already exists");
message = "Fill the form properly";
} else if (!(StringUtility.compare(sourceProduct.getBarcode(), product.getBarcode())) && (productService.findByBarCode(product.getBarcode()) != null)) {
message = "Fill the form properly";
bindingResult.rejectValue("barcode", null, "Product with same barcode already exists");
}
// DaoUtility.copyNonNullProperties(product, sourceProduct);
// product = sourceProduct;
} else {
if (productService.findByName(product.getName()) != null) {
message = "Fill the form properly";
bindingResult.rejectValue("name", null, "Product with same name already exists");
} else if (productService.findByBarCode(product.getBarcode()) != null) {
message = "Fill the form properly";
bindingResult.rejectValue("barcode", null, "Product with same barcode already exists");
}
}
try {
if (!bindingResult.hasErrors()) {
for (Price price : product.getPrices()) {
price.setProduct(product);
}
if (id == null) {
productService.save(product);
} else {
productService.update(product);
}
data.put("products", product);
success = true;
message = "Product Successfully added";
httpStatus = HttpStatus.OK;
} else {
for (FieldError error : bindingResult.getFieldErrors()) {
message = "Fill the form properly";
errors.add(new ErrorMessage(error.getField(), error.getDefaultMessage()));
}
}
} catch (Exception e) {
errors.add(new ErrorMessage("error", e.getMessage()));
}
response.put("success", success);
response.put("errors", errors);
response.put("message", message);
response.put("data", data);
return new ResponseEntity(response, httpStatus);
}
The problem actually was with PosixFilePermission class as this class only works with Linux based operating systems.
When used readAttributes() method it gave error as Linux has its own methods to get file attributes and windows has its own.

Check username and password in Ldap server through java

I have to check if username and password gave from user are right matching with the Ldap server. I use two connection, in the first I retrieve dn from uid and in the second I connect to Ldap with dn and password.
I have a problem with retrieved dn, it doesn't have the right fields.
It returns
cn=Lu Ca+sn=Ca+uid=luca+userPassword={SSHA}OiMBVTTZBPqnohYch9\+ISeVv\+5ucgxMR: null:null:No attributes
and not
cn=Lu Ca+sn=Ca+uid=luca+userPassword={SSHA}OiMBVTTZBPqnohYch9\+ISeVv\+5ucgxMR,ou=people,dc=example,dc=com
As you can see, ou and dc are not returned so my second query fails.
This is my code
#Override
public void isAuthenticated(String username, String password) throws LdapException{
String dn;
Hashtable<String, Object> ldapEnv = new Hashtable<String, Object>();
ldapEnv.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
ldapEnv.put(Context.PROVIDER_URL, env.getRequiredProperty(PROPERTY_NAME_LDAP_URL));
ldapEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
ldapEnv.put(Context.SECURITY_PRINCIPAL, "uid=admin,ou=system");
ldapEnv.put(Context.SECURITY_CREDENTIALS, "secret");
String[] returnAttribute = {"dn"};
DirContext ctx = null;
NamingEnumeration<SearchResult> results = null;
try {
ctx = new InitialDirContext(ldapEnv);
SearchControls controls = new SearchControls();
controls.setReturningAttributes(returnAttribute);
controls.setSearchScope(SearchControls.SUBTREE_SCOPE);
String filter = "uid=" + username ;
results = ctx.search(env.getRequiredProperty(PROPERTY_NAME_LDAP_USERSEARCHBASE), filter, controls);
if (results.hasMore())
dn = results.nextElement().toString();
else throw new LdapException("Wrong username. Please retry!");
} catch (Exception e) {
throw new LdapException(e);
} finally {
try{
if (results != null)
results.close();
if (ctx != null)
ctx.close();
}catch(Exception e){
throw new LdapException(e);
}
}
Hashtable<String, Object> authEnv = new Hashtable<String, Object>();
authEnv.put(Context.INITIAL_CONTEXT_FACTORY,"com.sun.jndi.ldap.LdapCtxFactory");
authEnv.put(Context.PROVIDER_URL, env.getRequiredProperty(PROPERTY_NAME_LDAP_URL));
authEnv.put(Context.SECURITY_AUTHENTICATION, "simple");
authEnv.put(Context.SECURITY_PRINCIPAL, dn);
authEnv.put(Context.SECURITY_CREDENTIALS, password);
try {
new InitialDirContext(authEnv);
} catch (AuthenticationException authEx) {
throw new LdapException("Authentication error. Password was wrong");
} catch(Exception e){
throw new LdapException(e);
}
}
with this parameters
ldap.url=ldap://127.0.0.1:10389/dc=example,dc=com
ldap.userSearchBase=ou=people
I'm uing this value also for spring authentication but I have one method (send big file) that fails only if I use authentication so I would like to try to authenticate with java and not through Spring
Do you know why I have this problem? thanks
UPDATE: with
dn = results.nextElement().getNameInNamespace();
it works, is my codes robust?
This is jboss LDAP login module implementation you can compare you code:
full code link
protected void rolesSearch(LdapContext ctx, SearchControls constraints, String user, String userDN,
int recursionMax, int nesting) throws NamingException
{
LdapContext ldapCtx = ctx;
Object[] filterArgs = {user, sanitizeDN(userDN)};
boolean referralsExist = true;
while (referralsExist) {
NamingEnumeration results = ldapCtx.search(rolesCtxDN, roleFilter, filterArgs, constraints);
try
{
while (results.hasMore())
{
SearchResult sr = (SearchResult) results.next();
String dn;
if (sr.isRelative()) {
dn = canonicalize(sr.getName());
}
else {
dn = sr.getNameInNamespace();
}
if (nesting == 0 && roleAttributeIsDN && roleNameAttributeID != null)
{
if(parseRoleNameFromDN)
{
parseRole(dn);
}
else
{
// Check the top context for role names
String[] attrNames = {roleNameAttributeID};
Attributes result2 = null;
if (sr.isRelative()) {
result2 = ldapCtx.getAttributes(quoteDN(dn), attrNames);
}
else {
result2 = getAttributesFromReferralEntity(sr, user, userDN);
}
Attribute roles2 = (result2 != null ? result2.get(roleNameAttributeID) : null);
if( roles2 != null )
{
for(int m = 0; m < roles2.size(); m ++)
{
String roleName = (String) roles2.get(m);
addRole(roleName);
}
}
}
}
// Query the context for the roleDN values
String[] attrNames = {roleAttributeID};
Attributes result = null;
if (sr.isRelative()) {
result = ldapCtx.getAttributes(quoteDN(dn), attrNames);
}
else {
result = getAttributesFromReferralEntity(sr, user, userDN);
}
if (result != null && result.size() > 0)
{
Attribute roles = result.get(roleAttributeID);
for (int n = 0; n < roles.size(); n++)
{
String roleName = (String) roles.get(n);
if(roleAttributeIsDN && parseRoleNameFromDN)
{
parseRole(roleName);
}
else if (roleAttributeIsDN)
{
// Query the roleDN location for the value of roleNameAttributeID
String roleDN = quoteDN(roleName);
String[] returnAttribute = {roleNameAttributeID};
try
{
Attributes result2 = null;
if (sr.isRelative()) {
result2 = ldapCtx.getAttributes(roleDN, returnAttribute);
}
else {
result2 = getAttributesFromReferralEntity(sr, user, userDN);
}
Attribute roles2 = (result2 != null ? result2.get(roleNameAttributeID) : null);
if (roles2 != null)
{
for (int m = 0; m < roles2.size(); m++)
{
roleName = (String) roles2.get(m);
addRole(roleName);
}
}
}
catch (NamingException e)
{
PicketBoxLogger.LOGGER.debugFailureToQueryLDAPAttribute(roleNameAttributeID, roleDN, e);
}
}
else
{
// The role attribute value is the role name
addRole(roleName);
}
}
}
if (nesting < recursionMax)
{
rolesSearch(ldapCtx, constraints, user, dn, recursionMax, nesting + 1);
}
}
referralsExist = false;
}
catch (ReferralException e) {
ldapCtx = (LdapContext) e.getReferralContext();
}
finally
{
if (results != null)
results.close();
}
} // while (referralsExist)
}

Invalid credentials exception while Importing contact list from gmail contacts using Java in Linux only

I have using Google (GDATA) Gmail API for retrieving the contact list from gmail, It is working successfully on windows environment, but when I run the same code on Linux, I get error of Invalid Credentials.
I googled it, but can't get much help,
here is my code
public static String getGmailContactList() {
String response = "";
StringBuilder str = new StringBuilder();
String statusString = "";
ArrayList list = new ArrayList();
ContactsService myService = new ContactsService("");
String email = "xxxxx#gmail.com";
String password = "xxxxxxxx";
try
{
try
{
myService.setUserCredentials(email, password);
}
catch (AuthenticationException ex)
{
ex.printStackTrace();
//****I got exception here when using this code on LINUX ENVIORMENT** ***
}
response = printAllContacts(myService, email);
Iterator itr = list.iterator();
while (itr.hasNext())
{
ArrayList contact = (ArrayList) itr.next();
try
{
str.append(contact.get(1)).append(",");
}
catch (Exception e)
{
log.debug("Exception ocurred inside fethching gmail contact >
>
>
" + e);
str.append("no contacts found");
}
str.substring(0, str.length() - 1);
}
}
catch (Exception ae)
{
response = statusString;
log.debug("Exception ocurred inside ReadContacts : getGmailContactList()" + ae);
}
return response;
}
public static String printAllContacts(ContactsService myService, String emailSent)//
throws ServiceException, IOException
{
URL feedUrl = new URL("http://www.google.com/m8/feeds/contacts/" + emailSent + "/full");
Query myQuery = new Query(feedUrl);
myQuery.setMaxResults(100);
ContactFeed resultFeed = myService.getFeed(myQuery, ContactFeed.class);
String phones = null;
String emails = null;
log.debug(resultFeed.getTitle().getPlainText());
StringBuilder contacts = new StringBuilder();
contacts.append("<?xml version=\"1.0\"><Contacts>");
for (int i = 0; i < resultFeed.getEntries().size(); i++)
{
contacts.append("<Contact>");
ContactEntry entry = resultFeed.getEntries().get(i);
if (entry.hasName())
{
Name name = entry.getName();
if (name.hasFullName())
{
String fullNameToDisplay = name.getFullName().getValue();
if (name.getFullName().hasYomi())
{
fullNameToDisplay += " (" + name.getFullName().getYomi() + ")";
}
contacts.append("<Name>").append(fullNameToDisplay).append("</Name>");
}
else
{
contacts.append("<Name>").append("").append("</Name>");
}
}
else
{
contacts.append("<Name>").append("").append("</Name>");
}
StringBuilder emailIds = new StringBuilder();
if (entry.hasEmailAddresses())
{
List<Email> email = entry.getEmailAddresses();
if (email != null && email.size() > 0)
{
for (Email e : email)
{
emailIds.append(e.getAddress()).append(",");
}
emailIds.trimToSize();
if (emailIds.indexOf(",") != -1)
{
emails = emailIds.substring(0, emailIds.lastIndexOf(","));
}
contacts.append("<Email>").append(emails).append("</Email>");
}
else
{
contacts.append("<Email>").append("").append("</Email>");
}
}
else
{
contacts.append("<Email>").append("").append("</Email>");
}
contacts.append("</Contact>");
}
contacts.append("</Contacts>");
return contacts.toString();
}
so where I am lacking behind, some sort of help will be appriciated
here is the stack trace
com.google.gdata.client.GoogleService$InvalidCredentialsException: Invalid credentials
at com.google.gdata.client.GoogleAuthTokenFactory.getAuthException(GoogleAuthTokenFactory.java:660)
at com.google.gdata.client.GoogleAuthTokenFactory.getAuthToken(GoogleAuthTokenFactory.java:560)
at com.google.gdata.client.GoogleAuthTokenFactory.setUserCredentials(GoogleAuthTokenFactory.java:397)
at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:364)
at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:319)
at com.google.gdata.client.GoogleService.setUserCredentials(GoogleService.java:303)
at com.gmail.ReadContacts.getGmailContactList(ReadContacts.java:55)

security realm authorize one login attempt

i'm using glassfish 3.1.1 with ejb 3.0 and a swing client and i have configured a jdbc realm for security purpose.
Everything work fine except one thing, if the user fail to log (wrong login or password) the login dialog is never showed again and the client send automatically the old login/password to the server .
How can i fix this ?
Thanks.
edit this the code of the authentification handler
public class ociCallBackHandler implements javax.security.auth.callback.CallbackHandler {
public void handle(Callback[] callbacks) {
try {
String login = null;
char[] mdp = null;
while (login == null || login.length() < 2) {
ArrayList out = GuiLogin.getLogin();
login = (String) out.get(0);
mdp = (char[]) out.get(1);
}
for (int i = 0; i < callbacks.length; i++) {
System.out.println("dans boucle");
if (callbacks[i] instanceof TextOutputCallback) {
// display the message according to the specified type
TextOutputCallback toc = (TextOutputCallback) callbacks[i];
switch (toc.getMessageType()) {
case TextOutputCallback.INFORMATION:
System.out.println("info");
System.out.println(toc.getMessage());
break;
case TextOutputCallback.ERROR:
System.out.println("error");
System.out.println("ERROR: " + toc.getMessage());
break;
case TextOutputCallback.WARNING:
System.out.println("warning");
System.out.println("WARNING: " + toc.getMessage());
break;
default:
System.out.println("inconuue");
throw new IOException("Unsupported message type: "
+ toc.getMessageType());
}
} else if (callbacks[i] instanceof TextInputCallback) {
System.out.println("textINputCallback");
TextInputCallback tic = (TextInputCallback) callbacks[i];
System.err.print(tic.getPrompt());
System.err.flush();
tic.setText("read");
} else if (callbacks[i] instanceof NameCallback) {
// prompt the user for a username
NameCallback nc = (NameCallback) callbacks[i];
nc.setName(login);
} else if (callbacks[i] instanceof PasswordCallback) {
// prompt the user for sensitive information
PasswordCallback pc = (PasswordCallback) callbacks[i];
pc.setPassword(mdp);
} else {
throw new UnsupportedCallbackException(callbacks[i], "Unrecognized Callback");
}
}
} catch (Exception e) {
System.out.println("exceptionn");
System.out.println(e);
}
}
}

Categories