List of usage examples for com.vaadin.server VaadinRequest getParameter
public String getParameter(String parameter);
From source file:edu.kit.dama.ui.admin.AdminUIMainView.java
License:Apache License
@Override protected void init(VaadinRequest request) { try {// w w w . j a v a 2 s . c o m //might be OAuth redirect String pendingAuthId = null; AbstractLoginComponent.AUTH_MODE type = AbstractLoginComponent.AUTH_MODE.LOGIN; if (VaadinSession.getCurrent().getAttribute("auth_pending") != null) { pendingAuthId = (String) VaadinSession.getCurrent().getAttribute("auth_pending"); } else if (VaadinSession.getCurrent().getAttribute("registration_pending") != null) { pendingAuthId = (String) VaadinSession.getCurrent().getAttribute("registration_pending"); type = AbstractLoginComponent.AUTH_MODE.REGISTRATION; } doBasicSetup(); boolean isLandingPage = request.getParameter("landing") != null; String landingObjectId = request.getParameter("oid"); //setup header setupHeader(isLandingPage, landingObjectId); //setup login form setupLoginForm(type, pendingAuthId, request); if (pendingAuthId != null && !type.equals(AbstractLoginComponent.AUTH_MODE.REGISTRATION)) { //auth will redirect to start page so we'll stop here return; } mainLayout = new VerticalLayout(); mainLayout.setMargin(false); mainLayout.setSizeFull(); //setup login bar loginInformationBar = new LoginInformationBar(this); loginInformationBar.reload(); setContent(mainLayout); setSizeFull(); if (isLandingPage) { //setup landing page LOGGER.debug("Showing landing page."); setupLandingPage(request); } else { refreshMainLayout(); } INITIALIZING = false; } catch (Throwable t) { LOGGER.error("Failed to init app.", t); } }
From source file:edu.kit.dama.ui.admin.AdminUIMainView.java
License:Apache License
private void setupLandingPage(VaadinRequest request) { String oid = (String) request.getParameter("oid"); IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager(); DigitalObject result = null;/*from w w w.j a v a 2 s .co m*/ Role viewRole = Role.GUEST; boolean objectNotFound = false; boolean extendedAccess = false; try { mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext()); //check if object exists result = mdm.findSingleResult("SELECT o FROM DigitalObject o WHERE o.digitalObjectIdentifier=?1", new Object[] { oid }, DigitalObject.class); if (result == null) { //object does not exist objectNotFound = true; } else { //object does exist, check permission for current context try { viewRole = ResourceServiceLocal.getSingleton().getGrantRole(result.getSecurableResourceId(), UIHelper.getSessionContext().getUserId(), AuthorizationContext.factorySystemContext()); } catch (UnsupportedOperationException | EntityNotFoundException nogrants) { //no grant found, check group role try { viewRole = (Role) ResourceServiceLocal.getSingleton().getReferenceRestriction( new ReferenceId(result.getSecurableResourceId(), UIHelper.getSessionGroupId()), AuthorizationContext.factorySystemContext()); } catch (EntityNotFoundException ex) { viewRole = Role.NO_ACCESS; } } } if (objectNotFound) { //object not found, if user logged in, show error...otherwise show login page if (UIHelper.getSessionUser().getDistinguishedName().equals(Constants.WORLD_USER_ID)) { VaadinSession.getCurrent().setAttribute("from", UIHelper.getWebAppUrl().toString() + "?landing&oid=" + oid); updateView(VIEW.LOGIN); return; } else { throw new UnauthorizedAccessAttemptException("No object found for object id " + oid); } } else { //object not found, if role >= GUEST, show landing page...otherwise show login page if anonymous access if (!viewRole.atLeast(Role.GUEST)) { VaadinSession.getCurrent().setAttribute("from", UIHelper.getWebAppUrl().toString() + "?landing&oid=" + oid); updateView(VIEW.LOGIN); return; } } //http://localhost:8080/KITDM/?landing&oid=3b1243b2-df09-4a98-ad87-21b7cda74be9catch (UnauthorizedAccessAttemptException | ParserConfigurationException ex) { } catch (UnauthorizedAccessAttemptException ex) { //not found, should result in error page LOGGER.error("Failed to access digital object with id " + oid, ex); result = null; } finally { mdm.close(); } if (landingPage == null) { landingPage = new LandingPageComponent(); } landingPage.update(result, extendedAccess); updateView(VIEW.LANDING); }
From source file:edu.kit.dama.ui.admin.login.B2AccessLoginComponent.java
License:Apache License
@Override public void doLogin(VaadinRequest request) throws UnauthorizedAccessAttemptException { String clientId = DataManagerSettings.getSingleton().getStringProperty(B2ACCESS_CLIENT_ID_PROPERTY, null); String clientSecret = DataManagerSettings.getSingleton().getStringProperty(B2ACCESS_CLIENT_SECRET_PROPERTY, null);/*w w w .j av a 2 s. co m*/ if (request == null) { //set auth_pending attribute in order to be able to finish authentication later VaadinSession.getCurrent().setAttribute("auth_pending", getLoginIdentifier()); Page.getCurrent() .setLocation("https://unity.eudat-aai.fz-juelich.de:8443/oauth2-as/oauth2-authz?client_id=" + clientId + "&response_type=code&scope=/authenticate&redirect_uri=" + UIHelper.getWebAppUrl().toString()); } else { //delete auth_pending attribute as we'll finish now or never VaadinSession.getCurrent().setAttribute("auth_pending", null); //obtain remaining information and do redirect //do actual login LOGGER.debug("Obtaining OAuth2 code from URL parameter."); String code = request.getParameter("code"); MultivaluedMap formData = new MultivaluedMapImpl(); formData.putSingle("client_id", clientId); formData.putSingle("client_secret", clientSecret); formData.putSingle("grant_type", "authorization_code"); formData.putSingle("redirect_uri", UIHelper.getWebAppUrl().toString()); formData.putSingle("code", code); ClientConfig config = new DefaultClientConfig(); IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager(); mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext()); try { SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(null, new TrustManager[] { TRUST_MANAGER }, new SecureRandom()); config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(VERIFIER, ctx)); Client client = Client.create(config); WebResource webResource = client .resource("https://unity.eudat-aai.fz-juelich.de:8443/oauth2/token"); webResource.addFilter(new HTTPBasicAuthFilter("KITDM", "0kudH2O.")); LOGGER.debug("Obtaining access token."); ClientResponse response = webResource.header("Content-Type", "application/x-www-form-urlencoded") .accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, formData); if (response.getStatus() == 200) { LOGGER.debug("Response status is HTTP 200. Parsing JSON response."); String responseData = response.getEntity(String.class); JSONObject responseObject = new JSONObject(responseData); String access_token = responseObject.getString("access_token"); webResource = client.resource("https://unity.eudat-aai.fz-juelich.de:8443/oauth2/userinfo"); LOGGER.debug("Accessing B2Access UserInfo at {}." + webResource.getURI()); response = webResource.header("Content-Type", "application/x-www-form-urlencoded") .accept(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + access_token) .get(ClientResponse.class); if (response.getStatus() == 200) { JSONObject userInfoResponse = new JSONObject(response.getEntity(String.class)); String userId = userInfoResponse.getString("sub"); UserData result = mdm.findSingleResult( "Select u FROM UserData u WHERE u.distinguishedName=?1", new Object[] { userId }, UserData.class); if (result != null) { LOGGER.debug("User with distinguished name {} found. Logging in and redirecting user.", userId); UIHelper.login(new UserId(result.getDistinguishedName()), new GroupId(Constants.USERS_GROUP_ID)); } else { LOGGER.warn("No user found for ORCiD {}. Login denied.", userId); throw new UnauthorizedAccessAttemptException( "No user found for ORCiD '" + userId + "'."); } } else { //failed, not enough information to proceed! } } else { throw new HttpException("Failed to obtain access token from ORCiD service. Status is " + response.getStatus() + ", response data is: " + response.getEntity(String.class)); } //{"access_token":"84e8f8d0-1df6-43af-9456-6619ef514aed","token_type":"bearer","refresh_token":"2f5116b4-f046-4f69-99c5-097e6066a132","expires_in":631138518,"scope":"/authenticate","name":"Thomas Jejkal","orcid":"0000-0003-2804-688X"} //https://pub.orcid.org/v1.2/0000-0003-2804-688X/orcid-bio } catch (NoSuchAlgorithmException | KeyManagementException | HttpException ex) { LOGGER.error("Failed to access B2Access service.", ex); throw new UnauthorizedAccessAttemptException("Failed to login via B2Access.", ex); } finally { mdm.close(); } String fromPage = (String) VaadinSession.getCurrent().getAttribute("from"); if (fromPage != null) { VaadinSession.getCurrent().setAttribute("from", null); Page.getCurrent().setLocation(fromPage); } else { Page.getCurrent().setLocation(UIHelper.getWebAppUrl().toString()); } } }
From source file:edu.kit.dama.ui.admin.login.B2AccessLoginComponent.java
License:Apache License
@Override public void doRegistration(VaadinRequest request) throws UnauthorizedAccessAttemptException { String clientId = DataManagerSettings.getSingleton().getStringProperty(B2ACCESS_CLIENT_ID_PROPERTY, null); String clientSecret = DataManagerSettings.getSingleton().getStringProperty(B2ACCESS_CLIENT_SECRET_PROPERTY, null);//from ww w. j a va2s .c o m UserData result = new UserData(); if (request == null) { VaadinSession.getCurrent().setAttribute("registration_pending", getLoginIdentifier()); Page.getCurrent() .setLocation("https://unity.eudat-aai.fz-juelich.de:8443/oauth2-as/oauth2-authz?client_id=" + clientId + "&response_type=code&scope=write&redirect_uri=" + UIHelper.getWebAppUrl().toString()); } else { //delete auth_pending attribute as we'll finish now or never VaadinSession.getCurrent().setAttribute("registration_pending", null); //obtain remaining information and do redirect //do actual login LOGGER.debug("Obtaining OAuth2 code from URL parameter."); String code = request.getParameter("code"); MultivaluedMap formData = new MultivaluedMapImpl(); formData.putSingle("client_id", clientId); formData.putSingle("client_secret", clientSecret); formData.putSingle("grant_type", "authorization_code"); formData.putSingle("redirect_uri", UIHelper.getWebAppUrl().toString()); formData.putSingle("code", code); ClientConfig config = new DefaultClientConfig(); IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager(); mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext()); try { SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(null, new TrustManager[] { TRUST_MANAGER }, new SecureRandom()); config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(VERIFIER, ctx)); Client client = Client.create(config); WebResource webResource = client .resource("https://unity.eudat-aai.fz-juelich.de:8443/oauth2/token"); webResource.addFilter(new HTTPBasicAuthFilter("KITDM", "0kudH2O.")); LOGGER.debug("Obtaining access token."); ClientResponse response = webResource.header("Content-Type", "application/x-www-form-urlencoded") .accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, formData); if (response.getStatus() == 200) { String responseData = response.getEntity(String.class); JSONObject responseObject = new JSONObject(responseData); String access_token = responseObject.getString("access_token"); webResource = client.resource("https://unity.eudat-aai.fz-juelich.de:8443/oauth2/userinfo"); LOGGER.debug("Accessing B2Access UserInfo at {}." + webResource.getURI()); response = webResource.header("Content-Type", "application/x-www-form-urlencoded") .accept(MediaType.APPLICATION_JSON).header("Authorization", "Bearer " + access_token) .get(ClientResponse.class); if (response.getStatus() == 200) { JSONObject userInfoResponse = new JSONObject(response.getEntity(String.class)); try { String userId = userInfoResponse.getString("sub"); List<UserData> existingUsers = mdm.findResultList( "Select u FROM UserData u WHERE u.distinguishedName=?1", new Object[] { userId }, UserData.class); if (!existingUsers.isEmpty()) { //user for B2Access subject already exists...unable to continue throw new UnauthorizedAccessAttemptException( "There is already a user registered for the obtained B2Access id '" + userId + "'."); } result.setDistinguishedName(userId); } catch (JSONException ex) { //failed, not enough information to proceed! } } else { //failed, not enough information to proceed! } } else { //failed, not enough information to proceed! } } catch (NoSuchAlgorithmException | KeyManagementException | JSONException ex) { LOGGER.error("Failed to collect information from B2Access service.", ex); throw new UnauthorizedAccessAttemptException("Failed to collect information from B2Access service.", ex); } finally { mdm.close(); } setup(AUTH_MODE.REGISTRATION, result); } }
From source file:edu.kit.dama.ui.admin.login.OrcidLoginComponent.java
License:Apache License
@Override public void doLogin(VaadinRequest request) throws UnauthorizedAccessAttemptException { String clientId = DataManagerSettings.getSingleton().getStringProperty(ORCID_CLIENT_ID_PROPERTY, null); String clientSecret = DataManagerSettings.getSingleton().getStringProperty(ORCID_CLIENT_SECRET_PROPERTY, null);//from w w w. j av a 2s . c o m if (request == null) { //set auth_pending attribute in order to be able to finish authentication later VaadinSession.getCurrent().setAttribute("auth_pending", getLoginIdentifier()); Page.getCurrent().setLocation("https://orcid.org/oauth/authorize?client_id=" + clientId + "&response_type=code&scope=/authenticate&redirect_uri=" + UIHelper.getWebAppUrl().toString()); } else { //delete auth_pending attribute as we'll finish now or never VaadinSession.getCurrent().setAttribute("auth_pending", null); //obtain remaining information and do redirect //do actual login LOGGER.debug("Obtaining OAuth2 code from URL parameter."); String code = request.getParameter("code"); MultivaluedMap formData = new MultivaluedMapImpl(); formData.putSingle("client_id", clientId); formData.putSingle("client_secret", clientSecret); formData.putSingle("grant_type", "authorization_code"); formData.putSingle("redirect_uri", UIHelper.getWebAppUrl().toString()); formData.putSingle("code", code); ClientConfig config = new DefaultClientConfig(); IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager(); mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext()); try { SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(null, new TrustManager[] { TRUST_MANAGER }, new SecureRandom()); config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(VERIFIER, ctx)); Client client = Client.create(config); URI resourceUri = new URL("https://orcid.org/oauth/token").toURI(); WebResource webResource = client.resource(resourceUri); LOGGER.debug("Requesting OAuth2 access token."); ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, formData); if (response.getStatus() == 200) { LOGGER.debug("Response status is HTTP 200. Parsing JSON response."); String responseData = response.getEntity(String.class); JSONObject responseObject = new JSONObject(responseData); String orcid = responseObject.getString("orcid"); // String accessToken = responseObject.getString("access_token"); LOGGER.debug("Obtained ORCiD is {}.", orcid); ServiceAccessToken result = mdm.findSingleResult( "Select t FROM ServiceAccessToken t WHERE t.tokenKey=?1", new Object[] { CryptUtil.stringToSHA1(orcid) }, ServiceAccessToken.class); if (result != null) { LOGGER.debug("User with id {} found. Logging in and redirecting user.", result.getUserId()); UIHelper.login(new UserId(result.getUserId()), new GroupId(Constants.USERS_GROUP_ID)); } else { LOGGER.warn("No user found for ORCiD {}. Login denied.", orcid); throw new UnauthorizedAccessAttemptException( "No login credential found for ORCiD '" + orcid + "'."); } } else { throw new HttpException("Failed to obtain access token from ORCiD service. Status is " + response.getStatus() + ", response data is: " + response.getEntity(String.class)); } //{"access_token":"84e8f8d0-1df6-43af-9456-6619ef514aed","token_type":"bearer","refresh_token":"2f5116b4-f046-4f69-99c5-097e6066a132","expires_in":631138518,"scope":"/authenticate","name":"Thomas Jejkal","orcid":"0000-0003-2804-688X"} //https://pub.orcid.org/v1.2/0000-0003-2804-688X/orcid-bio } catch (NoSuchAlgorithmException | KeyManagementException | MalformedURLException | URISyntaxException | HttpException ex) { LOGGER.error("Failed to access ORCiD service.", ex); throw new UnauthorizedAccessAttemptException("Failed to login via ORCiD.", ex); } finally { mdm.close(); } String fromPage = (String) VaadinSession.getCurrent().getAttribute("from"); if (fromPage != null) { VaadinSession.getCurrent().setAttribute("from", null); Page.getCurrent().setLocation(fromPage); } else { Page.getCurrent().setLocation(UIHelper.getWebAppUrl().toString()); } } }
From source file:edu.kit.dama.ui.admin.login.OrcidLoginComponent.java
License:Apache License
@Override public void doRegistration(VaadinRequest request) throws UnauthorizedAccessAttemptException { String clientId = DataManagerSettings.getSingleton().getStringProperty(ORCID_CLIENT_ID_PROPERTY, null); String clientSecret = DataManagerSettings.getSingleton().getStringProperty(ORCID_CLIENT_SECRET_PROPERTY, null);// w ww . ja va2 s .co m UserData result = new UserData(); if (request == null) { VaadinSession.getCurrent().setAttribute("registration_pending", getLoginIdentifier()); Page.getCurrent().setLocation("https://orcid.org/oauth/authorize?client_id=" + clientId + "&response_type=code&scope=/authenticate&redirect_uri=" + UIHelper.getWebAppUrl().toString()); } else { //delete auth_pending attribute as we'll finish now or never VaadinSession.getCurrent().setAttribute("registration_pending", null); //obtain remaining information and do redirect //do actual login LOGGER.debug("Obtaining OAuth2 code from URL parameter."); String code = request.getParameter("code"); MultivaluedMap formData = new MultivaluedMapImpl(); formData.putSingle("client_id", clientId); formData.putSingle("client_secret", clientSecret); formData.putSingle("grant_type", "authorization_code"); formData.putSingle("redirect_uri", UIHelper.getWebAppUrl().toString()); formData.putSingle("code", code); ClientConfig config = new DefaultClientConfig(); IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager(); mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext()); try { SSLContext ctx = SSLContext.getInstance("TLS"); ctx.init(null, new TrustManager[] { TRUST_MANAGER }, new SecureRandom()); config.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(VERIFIER, ctx)); Client client = Client.create(config); WebResource webResource = client.resource("https://orcid.org/oauth/token"); LOGGER.debug("Obtaining access token."); ClientResponse response = webResource.accept(MediaType.APPLICATION_JSON).post(ClientResponse.class, formData); if (response.getStatus() == 200) { String responseData = response.getEntity(String.class); JSONObject responseObject = new JSONObject(responseData); String orcid = responseObject.getString("orcid"); List<UserData> existingUsers = mdm.findResultList( "Select u FROM UserData u WHERE u.distinguishedName=?1", new Object[] { orcid }, UserData.class); if (!existingUsers.isEmpty()) { //user for ORCiD already exists...unable to continue throw new UnauthorizedAccessAttemptException( "There is already a user registered for ORCiD " + orcid + "."); } LOGGER.debug("Requesting registration information for ORCiD {}.", orcid); result.setDistinguishedName(orcid); String access_token = responseObject.getString("access_token"); //https://pub.orcid.org/v1.2/0000-0003-2804-688X/orcid-bio webResource = client.resource("https://pub.orcid.org/v1.2/" + orcid + "/orcid-bio"); LOGGER.debug("Accessing ORCiD service at {}." + webResource.getURI()); response = webResource.accept(MediaType.APPLICATION_JSON) .header("Authentication", "Bearer " + access_token).get(ClientResponse.class); if (response.getStatus() == 200) { JSONObject orcidResponse = new JSONObject(response.getEntity(String.class)); //Sample response with mail visible //{"message-version":"1.2","orcid-profile":{"orcid":null,"orcid-id":null,"orcid-identifier":{"value":null,"uri":"http://orcid.org/0000-0003-2804-688X","path":"0000-0003-2804-688X","host":"orcid.org"},"orcid-deprecated":null,"orcid-preferences":{"locale":"EN"},"orcid-history":{"creation-method":"DIRECT","completion-date":null,"submission-date":{"value":1432891995500},"last-modified-date":{"value":1476705802439},"claimed":{"value":true},"source":null,"deactivation-date":null,"verified-email":{"value":true},"verified-primary-email":{"value":true},"visibility":null},"orcid-bio":{"personal-details":{"given-names":{"value":"Thomas","visibility":null},"family-name":{"value":"Jejkal","visibility":null},"credit-name":{"value":"Thomas Jejkal","visibility":"PUBLIC"},"other-names":null},"biography":null,"researcher-urls":null,"contact-details":{"email":[{"value":"thomas.jejkal@kit.edu","primary":true,"current":true,"verified":true,"visibility":"PUBLIC","source":"0000-0003-2804-688X","source-client-id":null}],"address":{"country":{"value":"DE","visibility":"PUBLIC"}}},"keywords":null,"external-identifiers":null,"delegation":null,"scope":null},"orcid-activities":null,"orcid-internal":null,"type":"USER","group-type":null,"client-type":null},"orcid-search-results":null,"error-desc":null} //Sample response with mail invisible //{"message-version":"1.2","orcid-profile":{"orcid":null,"orcid-id":null,"orcid-identifier":{"value":null,"uri":"http://orcid.org/0000-0003-2804-688X","path":"0000-0003-2804-688X","host":"orcid.org"},"orcid-deprecated":null,"orcid-preferences":{"locale":"EN"},"orcid-history":{"creation-method":"DIRECT","completion-date":null,"submission-date":{"value":1432891995500},"last-modified-date":{"value":1476705875890},"claimed":{"value":true},"source":null,"deactivation-date":null,"verified-email":{"value":true},"verified-primary-email":{"value":true},"visibility":null},"orcid-bio":{"personal-details":{"given-names":{"value":"Thomas","visibility":null},"family-name":{"value":"Jejkal","visibility":null},"credit-name":{"value":"Thomas Jejkal","visibility":"PUBLIC"},"other-names":null},"biography":null,"researcher-urls":null,"contact-details":{"email":[],"address":{"country":{"value":"DE","visibility":"PUBLIC"}}},"keywords":null,"external-identifiers":null,"delegation":null,"scope":null},"orcid-activities":null,"orcid-internal":null,"type":"USER","group-type":null,"client-type":null},"orcid-search-results":null,"error-desc":null} try { JSONObject orcidBio = orcidResponse.getJSONObject("orcid-profile") .getJSONObject("orcid-bio"); try { JSONObject personalDetails = orcidBio.getJSONObject("personal-details"); String lastName = personalDetails.getJSONObject("family-name").getString("value"); String firstName = personalDetails.getJSONObject("given-names").getString("value"); result.setFirstName(firstName); result.setLastName(lastName); } catch (JSONException ex) { //failed to collect personal information LOGGER.info( "No personal-details element found in ORCiD response entity. Skipping first and last name properties."); } try { JSONObject contactDetails = orcidBio.getJSONObject("contact-details"); String email = contactDetails.getJSONArray("email").getJSONObject(0) .getString("value"); result.setEmail(email); } catch (JSONException ex) { //failed to collect email LOGGER.info( "No contact-details element found in ORCiD response entity. Skipping email property."); } } catch (JSONException ex) { //failed to collect email LOGGER.info( "No orcid-profile and/or orcid-bio elements found in ORCiD response entity. No properties can be obtained."); } } else { LOGGER.warn("Failed to obtain user profile from ORCiD service. Status is " + response.getStatus() + ", response data is: " + response.getEntity(String.class)); } } else { //unable to obtain ORCiD id...unable to continue throw new UnauthorizedAccessAttemptException( "Failed to obtain access token from ORCiD service. Status is " + response.getStatus() + ", response data is: " + response.getEntity(String.class)); } //{"access_token":"84e8f8d0-1df6-43af-9456-6619ef514aed","token_type":"bearer","refresh_token":"2f5116b4-f046-4f69-99c5-097e6066a132","expires_in":631138518,"scope":"/authenticate","name":"Thomas Jejkal","orcid":"0000-0003-2804-688X"} } catch (NoSuchAlgorithmException | KeyManagementException | JSONException ex) { LOGGER.error("Failed to collect information from ORCiD service.", ex); throw new UnauthorizedAccessAttemptException("Failed to collect information from ORCiD service.", ex); } finally { mdm.close(); } setup(AUTH_MODE.REGISTRATION, result); } }
From source file:edu.kit.dama.ui.repo.MyVaadinUI.java
License:Apache License
@Override protected final void init(VaadinRequest request) { checkData();//from w w w . j av a 2 s.c o m LOGGER.info("Accessing path {}", request.getPathInfo()); if (null != request.getPathInfo()) { switch (request.getPathInfo()) { case REFERENCE_PATH: LOGGER.info("Using pid {}", request.getParameter("pid")); buildRefView(request.getParameter("pid")); break; case SEARCH_PATH: LOGGER.info("Using query {}", request.getParameter("q")); //search view WITH external query support buildSearchView(request.getParameter("q")); break; default: LOGGER.info("Unknown path info. Using default view."); //search view without external query support buildSearchView(null); } } else { LOGGER.info("No path info. Using default view."); buildSearchView(null); } setSizeFull(); }
From source file:edu.kit.dama.ui.repo.MyVaadinUI.java
License:Apache License
@Override protected final void refresh(VaadinRequest request) { if (searchField == null) { init(request);//from ww w. j a v a 2s. c o m return; } LOGGER.info("Refreshing path {}", request.getPathInfo()); if (null != request.getPathInfo()) { switch (request.getPathInfo()) { case SEARCH_PATH: LOGGER.info("Using query {}", request.getParameter("q")); if (request.getParameter("q") != null) { searchField.setValue(request.getParameter("q")); } else { searchField.setValue("*"); } doSearch(); break; default: LOGGER.info("Only SEARCH_PATH is supported in refresh mode."); } } }
From source file:edu.nps.moves.security.PasswordResetUI.java
License:Open Source License
@SuppressWarnings("serial") @Override/*from w w w . ja v a 2 s.co m*/ protected void init(VaadinRequest request) { Timestamp rightNow = new Timestamp(System.currentTimeMillis()); uuid = UUID.randomUUID(); String uid = request.getParameter(UUID_PARAM); System.out.println("uid = " + uid); VerticalLayout vLay = new VerticalLayout(); setContent(vLay); if (uid == null) { vLay.addComponent(new Label("Bad URL")); ; } else { HSess.init(); @SuppressWarnings("unchecked") List<PasswordReset> lis = HSess.get().createCriteria(PasswordReset.class) .add(Restrictions.eq(RESETCODE_COL, uid)).list(); if (lis == null || lis.isEmpty()) vLay.addComponent(new Label("Bad URL2")); else { PasswordReset pr = lis.get(0); Timestamp expireDate = pr.getExpireDate(); if (rightNow.getTime() > expireDate.getTime()) vLay.addComponent( new Label("PasswordReset request has timed out. Please initiate new request.")); else { handleChangeTL(pr.getUser()); HSess.close(); return; } } HSess.close(); } vLay.addComponent(new Button("Go to help page", new ClickListener() { @Override public void buttonClick(ClickEvent event) { HSess.init(); String troubleUrl = GameLinks.getTL().getTroubleLink(); HSess.close(); getPage().setLocation(troubleUrl); getSession().close(); } })); }
From source file:fr.amapj.view.engine.ui.AmapUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { logger.info("Demarrage d'une nouvelle session:" + getSession().getCsrfToken()); // Register broadcast listener SessionManager.register(this); ///* w w w .j a v a2s .c om*/ setErrorHandling(); // setLocale(Locale.FRANCE); // Rcupration du nom de la base et vrification de celui ci String dbName = getDbName(request); DataBaseInfo dataBaseInfo = DbUtil.findDataBaseFromName(dbName); if (dataBaseInfo == null) { String contextPath = AppConfiguration.getConf().getContextPath(); getPage().setLocation(contextPath + "/infoservlet/liste-amaps"); return; } if (dataBaseInfo.getState() != AppState.ON) { String contextPath = AppConfiguration.getConf().getContextPath(); getPage().setLocation(contextPath + "/infoservlet/maintenance"); return; } // Cration du contexte et enregistrement du nom de la base SessionManager.initSessionData(dataBaseInfo); // Mode test String testClass = getTestClass(); if (testClass != null) { invokeTestClass(testClass, request); return; } String username = request.getParameter("username"); String password = request.getParameter("password"); String sudo = request.getParameter("sudo"); String resetPasswordSalt = request.getParameter("resetPassword"); if (resetPasswordSalt != null) { saisieNewPassword(resetPasswordSalt); } // Affichage graphique Responsive.makeResponsive(this); setContent(root); root.setSizeFull(); addStyleName(ValoTheme.UI_WITH_MENU); // Construction de la page de login buildLoginView(username, password, sudo); }